Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Related Jobs in Dataset and Model view #767

Merged
merged 1 commit into from May 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Related Jobs Feature
Reduced complexity of implementation

Newline fixes

Removed a print

Fixes

Fixed link for future resilience

Typo
  • Loading branch information
TimZaman committed May 23, 2016
commit eeddff2828040f311a4b56837de9ba6f7b36faba
4 changes: 2 additions & 2 deletions digits/dataset/generic/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ def create(extension_id):
raise


def show(job):
def show(job, related_jobs=None):
"""
Called from digits.dataset.views.show()
"""
return flask.render_template('datasets/generic/show.html', job=job)
return flask.render_template('datasets/generic/show.html', job=job, related_jobs=related_jobs)


def summary(job):
Expand Down
5 changes: 2 additions & 3 deletions digits/dataset/images/classification/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,11 @@ def create():
scheduler.delete_job(job)
raise

def show(job):
def show(job, related_jobs=None):
"""
Called from digits.dataset.views.datasets_show()
"""
return flask.render_template('datasets/images/classification/show.html', job=job)

return flask.render_template('datasets/images/classification/show.html', job=job, related_jobs=related_jobs)

def summary(job):
"""
Expand Down
4 changes: 2 additions & 2 deletions digits/dataset/images/generic/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ def create():
scheduler.delete_job(job)
raise

def show(job):
def show(job, related_jobs=None):
"""
Called from digits.dataset.views.datasets_show()
"""
return flask.render_template('datasets/images/generic/show.html', job=job)
return flask.render_template('datasets/images/generic/show.html', job=job, related_jobs=related_jobs)


def summary(job):
Expand Down
8 changes: 5 additions & 3 deletions digits/dataset/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@ def show(job_id):
if job is None:
raise werkzeug.exceptions.NotFound('Job not found')

related_jobs = scheduler.get_related_jobs(job)

if request_wants_json():
return flask.jsonify(job.json_dict(True))
else:
if isinstance(job, dataset_images.ImageClassificationDatasetJob):
return dataset_images.classification.views.show(job)
return dataset_images.classification.views.show(job, related_jobs=related_jobs)
elif isinstance(job, dataset_images.GenericImageDatasetJob):
return dataset_images.generic.views.show(job)
return dataset_images.generic.views.show(job, related_jobs=related_jobs)
elif isinstance(job, generic.GenericDatasetJob):
return generic.views.show(job)
return generic.views.show(job, related_jobs=related_jobs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you forgot to add this parameter to the show() function in digits/dataset/generic/views.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah that's because the file digits/dataset/generic/views.py is brand new. Didn't catch that, well spotted.

else:
raise werkzeug.exceptions.BadRequest('Invalid job type')

Expand Down
4 changes: 2 additions & 2 deletions digits/model/images/classification/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,11 @@ def create():
# If there are multiple jobs launched, go to the home page.
return flask.redirect('/')

def show(job):
def show(job, related_jobs=None):
"""
Called from digits.model.views.models_show()
"""
return flask.render_template('models/images/classification/show.html', job=job, framework_ids = [fw.get_id() for fw in frameworks.get_frameworks()])
return flask.render_template('models/images/classification/show.html', job=job, framework_ids = [fw.get_id() for fw in frameworks.get_frameworks()], related_jobs=related_jobs)

@blueprint.route('/large_graph', methods=['GET'])
def large_graph():
Expand Down
4 changes: 2 additions & 2 deletions digits/model/images/generic/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ def create(extension_id=None):
# If there are multiple jobs launched, go to the home page.
return flask.redirect('/')

def show(job):
def show(job, related_jobs=None):
"""
Called from digits.model.views.models_show()
"""
return flask.render_template('models/images/generic/show.html', job=job)
return flask.render_template('models/images/generic/show.html', job=job, related_jobs=related_jobs)

@blueprint.route('/large_graph', methods=['GET'])
def large_graph():
Expand Down
6 changes: 4 additions & 2 deletions digits/model/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,15 @@ def show(job_id):
if job is None:
raise werkzeug.exceptions.NotFound('Job not found')

related_jobs = scheduler.get_related_jobs(job)

if request_wants_json():
return flask.jsonify(job.json_dict(True))
else:
if isinstance(job, model_images.ImageClassificationModelJob):
return model_images.classification.views.show(job)
return model_images.classification.views.show(job, related_jobs=related_jobs)
elif isinstance(job, model_images.GenericImageModelJob):
return model_images.generic.views.show(job)
return model_images.generic.views.show(job, related_jobs=related_jobs)
else:
raise werkzeug.exceptions.BadRequest(
'Invalid job type')
Expand Down
23 changes: 23 additions & 0 deletions digits/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,29 @@ def get_job(self, job_id):
return None
return self.jobs.get(job_id, None)

def get_related_jobs(self, job):
"""
Look through self.jobs to try to find the Jobs
whose parent contains job
"""
related_jobs = []

if isinstance(job, ModelJob):
datajob = job.dataset
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates! If you don't mind a couple more comments... there you can do:

related_jobs.append(datajob)

so you can take lines 233-235 out.

related_jobs.append(datajob)
elif isinstance(job, DatasetJob):
datajob = job
else:
raise ValueError("Unhandled job type %s" % job.job_type())

for j in self.jobs.values():
# Any model that shares (this/the same) dataset should be added too:
if isinstance(j, ModelJob):
if datajob == j.train_task().dataset:
related_jobs.append(j)

return related_jobs

def abort_job(self, job_id):
"""
Aborts a running Job
Expand Down
47 changes: 47 additions & 0 deletions digits/templates/job.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,53 @@ <h4 class="panel-title">
</div>
<div class="gpu-utilization-info" style="display:none;"></div>


<!-- Related jobs -->
{% if related_jobs is not none and related_jobs|length > 0 %}
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
Related jobs
</h4>
</div>
<div class="panel-collapse">
<div class="panel-body">
<div class="panel-group">
<!-- Related model jobs -->
{% for r_job in related_jobs %}
{% if prev_job_model != r_job.job_type() %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might have been more explicit to call this prev_job_type but I don't think it's a big deal

<h4 class="panel-title" style="margin:10px">{{r_job.job_type()}}</h4>
{% set prev_job_model = r_job.job_type() %}
{% endif %}
<div id="{{r_job.id()}}-status" class="panel panel-{{ r_job.status.css }}">
<div class="panel-heading">
<h4 class="panel-title">
<a href="{{ url_for('digits.views.show_job', job_id=r_job.id()) }}">
{{ r_job.name() }}
<small>{{r_job.status.name}}</small>
</a>
<a data-toggle="collapse" href="#{{r_job.id()}}-status-collapse" style="float:right">
<span class="caret"></span>
</a>
</h4>
</div>
<div id="{{r_job.id()}}-status-collapse" class="panel-collapse collapse">
<div class="panel-body">
<div class="task-statuses">
{% with updates = r_job.status_history %}
{% include "status_updates.html" %}
{% endwith %}
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
{% endif %}

<div id="notes-information" class="panel panel-default">
<div class="panel-heading">
<h4>Notes</h4>
Expand Down