diff --git a/digits/dataset/images/classification/views.py b/digits/dataset/images/classification/views.py index 18a55b566..4e836b243 100644 --- a/digits/dataset/images/classification/views.py +++ b/digits/dataset/images/classification/views.py @@ -7,7 +7,7 @@ from digits import utils from digits.utils.forms import fill_form_if_cloned, save_form_to_job from digits.utils.routing import request_wants_json, job_from_request -from digits.webapp import app, scheduler, autodoc +from digits.webapp import app, scheduler from digits.dataset import tasks from forms import ImageClassificationDatasetForm from job import ImageClassificationDatasetJob @@ -254,7 +254,7 @@ def from_files(job, form): @app.route(NAMESPACE + '/new', methods=['GET']) -@autodoc('datasets') +@utils.auth.requires_login def image_classification_dataset_new(): """ Returns a form for a new ImageClassificationDatasetJob @@ -268,7 +268,7 @@ def image_classification_dataset_new(): @app.route(NAMESPACE + '.json', methods=['POST']) @app.route(NAMESPACE, methods=['POST']) -@autodoc(['datasets', 'api']) +@utils.auth.requires_login(redirect=False) def image_classification_dataset_create(): """ Creates a new ImageClassificationDatasetJob @@ -289,6 +289,7 @@ def image_classification_dataset_create(): job = None try: job = ImageClassificationDatasetJob( + username = utils.auth.get_username(), name = form.dataset_name.data, image_dims = ( int(form.resize_height.data), @@ -328,7 +329,6 @@ def show(job): return flask.render_template('datasets/images/classification/show.html', job=job) @app.route(NAMESPACE + '/summary', methods=['GET']) -@autodoc('datasets') def image_classification_dataset_summary(): """ Return a short HTML summary of a DatasetJob @@ -364,7 +364,6 @@ def entries(self): yield item @app.route(NAMESPACE + '/explore', methods=['GET']) -@autodoc('datasets') def image_classification_dataset_explore(): """ Returns a gallery consisting of the images of one of the dbs diff --git a/digits/dataset/images/generic/views.py b/digits/dataset/images/generic/views.py index 82cf0a643..2a6ec42e8 100644 --- a/digits/dataset/images/generic/views.py +++ b/digits/dataset/images/generic/views.py @@ -2,9 +2,10 @@ import flask +from digits import utils from digits.utils.forms import fill_form_if_cloned, save_form_to_job from digits.utils.routing import request_wants_json, job_from_request -from digits.webapp import app, scheduler, autodoc +from digits.webapp import app, scheduler from digits.dataset import tasks from forms import GenericImageDatasetForm from job import GenericImageDatasetJob @@ -12,7 +13,7 @@ NAMESPACE = '/datasets/images/generic' @app.route(NAMESPACE + '/new', methods=['GET']) -@autodoc('datasets') +@utils.auth.requires_login def generic_image_dataset_new(): """ Returns a form for a new GenericImageDatasetJob @@ -26,7 +27,7 @@ def generic_image_dataset_new(): @app.route(NAMESPACE + '.json', methods=['POST']) @app.route(NAMESPACE, methods=['POST']) -@autodoc(['datasets', 'api']) +@utils.auth.requires_login(redirect=False) def generic_image_dataset_create(): """ Creates a new GenericImageDatasetJob @@ -47,8 +48,9 @@ def generic_image_dataset_create(): job = None try: job = GenericImageDatasetJob( - name = form.dataset_name.data, - mean_file = form.prebuilt_mean_file.data.strip(), + username = utils.auth.get_username(), + name = form.dataset_name.data, + mean_file = form.prebuilt_mean_file.data.strip(), ) if form.method.data == 'prebuilt': @@ -118,7 +120,6 @@ def show(job): return flask.render_template('datasets/images/generic/show.html', job=job) @app.route(NAMESPACE + '/summary', methods=['GET']) -@autodoc('datasets') def generic_image_dataset_summary(): """ Return a short HTML summary of a DatasetJob diff --git a/digits/dataset/images/views.py b/digits/dataset/images/views.py index ead29069f..6edbece9f 100644 --- a/digits/dataset/images/views.py +++ b/digits/dataset/images/views.py @@ -8,14 +8,13 @@ import digits from digits import utils -from digits.webapp import app, autodoc +from digits.webapp import app import classification.views import generic.views NAMESPACE = '/datasets/images' @app.route(NAMESPACE + '/resize-example', methods=['POST']) -@autodoc('datasets') def image_dataset_resize_example(): """ Resizes the example image, and returns it as a string of png data diff --git a/digits/dataset/views.py b/digits/dataset/views.py index 7bc20152a..67b8dfbc4 100644 --- a/digits/dataset/views.py +++ b/digits/dataset/views.py @@ -3,7 +3,7 @@ import flask import werkzeug.exceptions -from digits.webapp import app, scheduler, autodoc +from digits.webapp import app, scheduler from digits.utils.routing import request_wants_json import images.views import images as dataset_images @@ -12,7 +12,6 @@ @app.route(NAMESPACE + '.json', methods=['GET']) @app.route(NAMESPACE + '', methods=['GET']) -@autodoc(['datasets', 'api']) def datasets_show(job_id): """ Show a DatasetJob diff --git a/digits/job.py b/digits/job.py index 91bcc1539..a15724afb 100644 --- a/digits/job.py +++ b/digits/job.py @@ -42,10 +42,11 @@ def load(cls, job_id): task.detect_snapshots() return job - def __init__(self, name): + def __init__(self, name, username): """ Arguments: name -- name of this job + username -- creator of this job """ super(Job, self).__init__() @@ -53,6 +54,7 @@ def __init__(self, name): self._id = '%s-%s' % (time.strftime('%Y%m%d-%H%M%S'), os.urandom(2).encode('hex')) self._dir = os.path.join(config_value('jobs_dir'), self._id) self._name = name + self.username = username self.pickver_job = PICKLE_VERSION self.tasks = [] self.exception = None @@ -76,6 +78,8 @@ def __setstate__(self, state): """ Used when loading a pickle file """ + if 'username' not in state: + state['username'] = None self.__dict__ = state def json_dict(self, detailed=False): diff --git a/digits/model/images/classification/views.py b/digits/model/images/classification/views.py index a93d662e7..c50d2bfe0 100644 --- a/digits/model/images/classification/views.py +++ b/digits/model/images/classification/views.py @@ -12,7 +12,7 @@ from digits.config import config_value from digits import utils from digits.utils.routing import request_wants_json, job_from_request -from digits.webapp import app, scheduler, autodoc +from digits.webapp import app, scheduler from digits.dataset import ImageClassificationDatasetJob from digits import frameworks from forms import ImageClassificationModelForm @@ -24,7 +24,7 @@ NAMESPACE = '/models/images/classification' @app.route(NAMESPACE + '/new', methods=['GET']) -@autodoc('models') +@utils.auth.requires_login def image_classification_model_new(): """ Return a form for a new ImageClassificationModelJob @@ -50,7 +50,7 @@ def image_classification_model_new(): @app.route(NAMESPACE + '.json', methods=['POST']) @app.route(NAMESPACE, methods=['POST']) -@autodoc(['models', 'api']) +@utils.auth.requires_login(redirect=False) def image_classification_model_create(): """ Create a new ImageClassificationModelJob @@ -88,6 +88,7 @@ def image_classification_model_create(): job = None try: job = ImageClassificationModelJob( + username = utils.auth.get_username(), name = form.model_name.data, dataset_id = datasetJob.id(), ) @@ -235,7 +236,6 @@ def show(job): return flask.render_template('models/images/classification/show.html', job=job, framework_ids = [fw.get_id() for fw in frameworks.get_frameworks()]) @app.route(NAMESPACE + '/large_graph', methods=['GET']) -@autodoc('models') def image_classification_model_large_graph(): """ Show the loss/accuracy graph, but bigger @@ -246,7 +246,6 @@ def image_classification_model_large_graph(): @app.route(NAMESPACE + '/classify_one.json', methods=['POST']) @app.route(NAMESPACE + '/classify_one', methods=['POST', 'GET']) -@autodoc(['models', 'api']) def image_classification_model_classify_one(): """ Classify one image and return the top 5 classifications @@ -304,7 +303,6 @@ def image_classification_model_classify_one(): @app.route(NAMESPACE + '/classify_many.json', methods=['POST']) @app.route(NAMESPACE + '/classify_many', methods=['POST', 'GET']) -@autodoc(['models', 'api']) def image_classification_model_classify_many(): """ Classify many images and return the top 5 classifications for each @@ -389,7 +387,6 @@ def image_classification_model_classify_many(): ) @app.route(NAMESPACE + '/top_n', methods=['POST']) -@autodoc('models') def image_classification_model_top_n(): """ Classify many images and show the top N images per category by confidence diff --git a/digits/model/images/generic/views.py b/digits/model/images/generic/views.py index 2777f1072..f8b1f0ebe 100644 --- a/digits/model/images/generic/views.py +++ b/digits/model/images/generic/views.py @@ -12,7 +12,7 @@ from digits import utils from digits.utils.routing import request_wants_json, job_from_request from digits.utils.forms import fill_form_if_cloned, save_form_to_job -from digits.webapp import app, scheduler, autodoc +from digits.webapp import app, scheduler from digits.dataset import GenericImageDatasetJob from forms import GenericImageModelForm from job import GenericImageModelJob @@ -22,7 +22,7 @@ NAMESPACE = '/models/images/generic' @app.route(NAMESPACE + '/new', methods=['GET']) -@autodoc('models') +@utils.auth.requires_login def generic_image_model_new(): """ Return a form for a new GenericImageModelJob @@ -47,7 +47,7 @@ def generic_image_model_new(): @app.route(NAMESPACE + '.json', methods=['POST']) @app.route(NAMESPACE, methods=['POST']) -@autodoc(['models', 'api']) +@utils.auth.requires_login(redirect=False) def generic_image_model_create(): """ Create a new GenericImageModelJob @@ -84,6 +84,7 @@ def generic_image_model_create(): job = None try: job = GenericImageModelJob( + username = utils.auth.get_username(), name = form.model_name.data, dataset_id = datasetJob.id(), ) @@ -218,7 +219,6 @@ def show(job): return flask.render_template('models/images/generic/show.html', job=job) @app.route(NAMESPACE + '/large_graph', methods=['GET']) -@autodoc('models') def generic_image_model_large_graph(): """ Show the loss/accuracy graph, but bigger @@ -229,7 +229,6 @@ def generic_image_model_large_graph(): @app.route(NAMESPACE + '/infer_one.json', methods=['POST']) @app.route(NAMESPACE + '/infer_one', methods=['POST', 'GET']) -@autodoc(['models', 'api']) def generic_image_model_infer_one(): """ Infer one image @@ -280,7 +279,6 @@ def generic_image_model_infer_one(): @app.route(NAMESPACE + '/infer_many.json', methods=['POST']) @app.route(NAMESPACE + '/infer_many', methods=['POST', 'GET']) -@autodoc(['models', 'api']) def generic_image_model_infer_many(): """ Infer many images diff --git a/digits/model/views.py b/digits/model/views.py index 179570977..217d61208 100644 --- a/digits/model/views.py +++ b/digits/model/views.py @@ -12,7 +12,7 @@ import digits -from digits.webapp import app, scheduler, autodoc +from digits.webapp import app, scheduler from digits.utils import time_filters from digits.utils.routing import request_wants_json from . import ModelJob @@ -25,7 +25,6 @@ NAMESPACE = '/models/' @app.route(NAMESPACE, methods=['GET']) -@autodoc(['models']) def models_index(): column_attrs = list(get_column_attrs()) raw_jobs = [j for j in scheduler.jobs.values() if isinstance(j, ModelJob)] @@ -82,7 +81,6 @@ def models_index(): @app.route(NAMESPACE + '.json', methods=['GET']) @app.route(NAMESPACE + '', methods=['GET']) -@autodoc(['models', 'api']) def models_show(job_id): """ Show a ModelJob @@ -106,7 +104,6 @@ def models_show(job_id): 'Invalid job type') @app.route(NAMESPACE + 'customize', methods=['POST']) -@autodoc('models') def models_customize(): """ Returns a customized file for the ModelJob based on completed form fields @@ -147,7 +144,6 @@ def models_customize(): }) @app.route(NAMESPACE + 'visualize-network', methods=['POST']) -@autodoc('models') def models_visualize_network(): """ Returns a visualization of the custom network as a string of PNG data @@ -162,7 +158,6 @@ def models_visualize_network(): return ret @app.route(NAMESPACE + 'visualize-lr', methods=['POST']) -@autodoc('models') def models_visualize_lr(): """ Returns a JSON object of data used to create the learning rate graph @@ -217,7 +212,6 @@ def models_visualize_lr(): defaults={'extension': 'tar.gz'}) @app.route(NAMESPACE + '/download.', methods=['GET', 'POST']) -@autodoc('models') def models_download(job_id, extension): """ Return a tarball of all files required to run the model diff --git a/digits/templates/job.html b/digits/templates/job.html index cc182b256..e8ff0aa70 100644 --- a/digits/templates/job.html +++ b/digits/templates/job.html @@ -91,7 +91,9 @@

{{ job.name() }}

+ {% if job | has_permission('edit') %} + {% endif %}