Exemple #1
0
def edit_job(job_id):
    """
    Edit a job's name and/or notes
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound("Job not found")

    # Edit name
    if "job_name" in flask.request.form:
        name = flask.request.form["job_name"].strip()
        if not name:
            raise werkzeug.exceptions.BadRequest("name cannot be blank")
        job._name = name
        logger.info('Set name to "%s".' % job.name(), job_id=job.id())

    # Edit notes
    if "job_notes" in flask.request.form:
        notes = flask.request.form["job_notes"].strip()
        if not notes:
            notes = None
        job._notes = notes
        logger.info("Updated notes.", job_id=job.id())

    return "%s updated." % job.job_type()
Exemple #2
0
def clone_job(clone):
    """
    Clones a job with the id <clone>, populating the creation page with data saved in <clone>
    """

    ## <clone> is the job_id to clone

    job = scheduler.get_job(clone)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    if isinstance(job, dataset.ImageClassificationDatasetJob):
        return flask.redirect(
            flask.url_for('image_classification_dataset_new') + '?clone=' +
            clone)
    if isinstance(job, dataset.GenericImageDatasetJob):
        return flask.redirect(
            flask.url_for('generic_image_dataset_new') + '?clone=' + clone)
    if isinstance(job, model.ImageClassificationModelJob):
        return flask.redirect(
            flask.url_for('image_classification_model_new') + '?clone=' +
            clone)
    if isinstance(job, model.GenericImageModelJob):
        return flask.redirect(
            flask.url_for('generic_image_model_new') + '?clone=' + clone)
    else:
        raise werkzeug.exceptions.BadRequest('Invalid job type')
Exemple #3
0
def edit_job(job_id):
    """
    Edit a job's name and/or notes
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    # Edit name
    if 'job_name' in flask.request.form:
        name = flask.request.form['job_name'].strip()
        if not name:
            raise werkzeug.exceptions.BadRequest('name cannot be blank')
        job._name = name
        logger.info('Set name to "%s".' % job.name(), job_id=job.id())

    # Edit notes
    if 'job_notes' in flask.request.form:
        notes = flask.request.form['job_notes'].strip()
        if not notes:
            notes = None
        job._notes = notes
        logger.info('Updated notes.', job_id=job.id())

    return '%s updated.' % job.job_type()
Exemple #4
0
def edit_job(job_id):
    """
    Edit a job's name and/or notes
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    # Edit name
    if 'job_name' in flask.request.form:
        name = flask.request.form['job_name'].strip()
        if not name:
            raise werkzeug.exceptions.BadRequest('name cannot be blank')
        job._name = name
        logger.info('Set name to "%s".' % job.name(), job_id=job.id())

    # Edit notes
    if 'job_notes' in flask.request.form:
        notes = flask.request.form['job_notes'].strip()
        if not notes:
            notes = None
        job._notes = notes
        logger.info('Updated notes.', job_id=job.id())

    return '%s updated.' % job.job_type()
Exemple #5
0
def delete_job(job_id):
    job = scheduler.get_job(job_id)
    if not job:
        return 'Job not found!', 404
    if scheduler.delete_job(job_id):
        return 'Job deleted.'
    else:
        return 'Job could not deleted!', 403
Exemple #6
0
def delete_job(job_id):
    job = scheduler.get_job(job_id)
    if not job:
        return 'Job not found!', 404
    if scheduler.delete_job(job_id):
        return 'Job deleted.'
    else:
        return 'Job could not deleted!', 403
Exemple #7
0
def edit_job(job_id):
    job = scheduler.get_job(job_id)

    if job is None:
        abort(404)

    old_name = job.name()
    job._name = request.form['job_name']
    return 'Changed job name from "%s" to "%s"' % (old_name, job.name())
Exemple #8
0
def edit_job(job_id):
    job = scheduler.get_job(job_id)

    if job is None:
        abort(404)

    old_name = job.name()
    job._name = request.form['job_name']
    return 'Changed job name from "%s" to "%s"' % (old_name, job.name())
Exemple #9
0
def edit_job(job_id):
    """
    Edit the name of a job
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    old_name = job.name()
    job._name = flask.request.form['job_name']
    return 'Changed job name from "%s" to "%s"' % (old_name, job.name())
Exemple #10
0
def job_status(job_id):
    job = scheduler.get_job(job_id)
    result = {}
    if job is None:
        result['error'] = 'Job not found.'
    else:
        result['error'] = None
        result['status'] = job.status.name
        result['name'] = job.name()
        result['type'] = job.job_type()
    return json.dumps(result)
Exemple #11
0
def delete_job(job_id):
    job = scheduler.get_job(job_id)
    if not job:
        return 'Job not found!', 404
    try:
        if scheduler.delete_job(job_id):
            return 'Job deleted.'
        else:
            return 'Job could not be deleted! Check log for more details', 403
    except errors.DeleteError as e:
        return e.__str__(), 403
Exemple #12
0
def delete_job(job_id):
    job = scheduler.get_job(job_id)
    if not job:
        return 'Job not found!', 404
    try:
        if scheduler.delete_job(job_id):
            return 'Job deleted.'
        else:
            return 'Job could not be deleted! Check log for more details', 403
    except errors.DeleteError as e:
        return e.__str__(), 403
Exemple #13
0
def job_status(job_id):
    job = scheduler.get_job(job_id)
    result = {}
    if job is None:
        result['error'] = 'Job not found.'
    else:
        result['error'] = None
        result['status'] = job.status.name
        result['name'] = job.name()
        result['type'] = job.job_type()
    return json.dumps(result)
Exemple #14
0
def edit_job(job_id):
    """
    Edit the name of a job
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    old_name = job.name()
    job._name = flask.request.form['job_name']
    return 'Changed job name from "%s" to "%s"' % (old_name, job.name())
Exemple #15
0
def edit_job_notes(job_id):
    """
    Edit the notes of a job
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound("Job not found")

    old_notes = job.notes()
    job._notes = flask.request.form["job_notes"]
    return 'Changed job notes from "%s" to "%s"' % (old_notes, job.notes())
Exemple #16
0
def show_job(job_id):
    job = scheduler.get_job(job_id)

    if job is None:
        abort(404)

    if isinstance(job, dataset.DatasetJob):
        return redirect(url_for('datasets_show', job_id=job_id))
    if isinstance(job, model.ModelJob):
        return redirect(url_for('models_show', job_id=job_id))
    else:
        abort(404)
Exemple #17
0
def abort_job(job_id):
    """
    Aborts a running job
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    if scheduler.abort_job(job_id):
        return 'Job aborted.'
    else:
        raise werkzeug.exceptions.Forbidden('Job not aborted')
Exemple #18
0
def show_job(job_id):
    job = scheduler.get_job(job_id)

    if job is None:
        abort(404)

    if isinstance(job, dataset.DatasetJob):
        return redirect(url_for('datasets_show', job_id=job_id))
    if isinstance(job, model.ModelJob):
        return redirect(url_for('models_show', job_id=job_id))
    else:
        abort(404)
Exemple #19
0
def abort_job(job_id):
    """
    Aborts a running job
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    if scheduler.abort_job(job_id):
        return 'Job aborted.'
    else:
        raise werkzeug.exceptions.Forbidden('Job not aborted')
Exemple #20
0
def job_status(job_id):
    """
    Returns a JSON objecting representing the status of a job
    """
    job = scheduler.get_job(job_id)
    result = {}
    if job is None:
        result['error'] = 'Job not found.'
    else:
        result['error'] = None
        result['status'] = job.status.name
        result['name'] = job.name()
        result['type'] = job.job_type()
    return json.dumps(result)
Exemple #21
0
def show_job(job_id):
    """
    Redirects to the appropriate /datasets/ or /models/ page
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    if isinstance(job, dataset.DatasetJob):
        return flask.redirect(flask.url_for('datasets_show', job_id=job_id))
    if isinstance(job, model.ModelJob):
        return flask.redirect(flask.url_for('models_show', job_id=job_id))
    else:
        raise werkzeug.exceptions.BadRequest('Invalid job type')
Exemple #22
0
def job_status(job_id):
    """
    Returns a JSON objecting representing the status of a job
    """
    job = scheduler.get_job(job_id)
    result = {}
    if job is None:
        result["error"] = "Job not found."
    else:
        result["error"] = None
        result["status"] = job.status.name
        result["name"] = job.name()
        result["type"] = job.job_type()
    return json.dumps(result)
Exemple #23
0
def job_status(job_id):
    """
    Returns a JSON objecting representing the status of a job
    """
    job = scheduler.get_job(job_id)
    result = {}
    if job is None:
        result['error'] = 'Job not found.'
    else:
        result['error'] = None
        result['status'] = job.status.name
        result['name'] = job.name()
        result['type'] = job.job_type()
    return json.dumps(result)
Exemple #24
0
def show_job(job_id):
    """
    Redirects to the appropriate /datasets/ or /models/ page
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    if isinstance(job, dataset.DatasetJob):
        return flask.redirect(flask.url_for('datasets_show', job_id=job_id))
    if isinstance(job, model.ModelJob):
        return flask.redirect(flask.url_for('models_show', job_id=job_id))
    else:
        raise werkzeug.exceptions.BadRequest('Invalid job type')
Exemple #25
0
def delete_job(job_id):
    """
    Deletes a job
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    try:
        if scheduler.delete_job(job_id):
            return 'Job deleted.'
        else:
            raise werkzeug.exceptions.Forbidden('Job not deleted')
    except errors.DeleteError as e:
        raise werkzeug.exceptions.Forbidden(str(e))
Exemple #26
0
def show_job(job_id):
    """
    Redirects to the appropriate /datasets/ or /models/ page
    """
    job = scheduler.get_job(job_id)

    if job is None:
        abort(404)

    if isinstance(job, dataset.DatasetJob):
        return redirect(url_for('datasets_show', job_id=job_id))
    if isinstance(job, model.ModelJob):
        return redirect(url_for('models_show', job_id=job_id))
    else:
        abort(404)
Exemple #27
0
def delete_job(job_id):
    """
    Deletes a job
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    try:
        if scheduler.delete_job(job_id):
            return 'Job deleted.'
        else:
            raise werkzeug.exceptions.Forbidden('Job not deleted')
    except errors.DeleteError as e:
        raise werkzeug.exceptions.Forbidden(str(e))
Exemple #28
0
def delete_job(job_id):
    """
    Deletes a job
    """
    job = scheduler.get_job(job_id)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    if not utils.auth.has_permission(job, 'delete'):
        raise werkzeug.exceptions.Forbidden()

    try:
        if scheduler.delete_job(job_id):
            return 'Job deleted.'
        else:
            raise werkzeug.exceptions.Forbidden('Job not deleted')
    except utils.errors.DeleteError as e:
        raise werkzeug.exceptions.Forbidden(str(e))
Exemple #29
0
def clone_job(clone):
    """
    Clones a job with the id <clone>, populating the creation page with data saved in <clone>
    """

    ## <clone> is the job_id to clone

    job = scheduler.get_job(clone)
    if job is None:
        raise werkzeug.exceptions.NotFound('Job not found')

    if isinstance(job, dataset.ImageClassificationDatasetJob):
        return flask.redirect(flask.url_for('image_classification_dataset_new') + '?clone=' + clone)
    if isinstance(job, dataset.GenericImageDatasetJob):
        return flask.redirect(flask.url_for('generic_image_dataset_new') + '?clone=' + clone)
    if isinstance(job, model.ImageClassificationModelJob):
        return flask.redirect(flask.url_for('image_classification_model_new') + '?clone=' + clone)
    if isinstance(job, model.GenericImageModelJob):
        return flask.redirect(flask.url_for('generic_image_model_new') + '?clone=' + clone)
    else:
        raise werkzeug.exceptions.BadRequest('Invalid job type')