예제 #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()
예제 #2
0
파일: views.py 프로젝트: iwalkdaline/DIGITS
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')
예제 #3
0
파일: views.py 프로젝트: Cloud-CV/DIGITS
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()
예제 #4
0
파일: views.py 프로젝트: iwalkdaline/DIGITS
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()
예제 #5
0
파일: views.py 프로젝트: Rusianka/DIGITS
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
예제 #6
0
파일: views.py 프로젝트: xiaozhuka/DIGITS
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
예제 #7
0
파일: views.py 프로젝트: Rusianka/DIGITS
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())
예제 #8
0
파일: views.py 프로젝트: xiaozhuka/DIGITS
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())
예제 #9
0
파일: views.py 프로젝트: CVML/DIGITS
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())
예제 #10
0
파일: views.py 프로젝트: Rusianka/DIGITS
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)
예제 #11
0
파일: views.py 프로젝트: 52191114/DIGITS
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
예제 #12
0
파일: views.py 프로젝트: yanweifu/DIGITS
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
예제 #13
0
파일: views.py 프로젝트: xiaozhuka/DIGITS
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)
예제 #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())
예제 #15
0
파일: views.py 프로젝트: RadicoLabs/DIGITS
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())
예제 #16
0
파일: views.py 프로젝트: Rusianka/DIGITS
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)
예제 #17
0
파일: views.py 프로젝트: Cloud-CV/DIGITS
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')
예제 #18
0
파일: views.py 프로젝트: xiaozhuka/DIGITS
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)
예제 #19
0
파일: views.py 프로젝트: iwalkdaline/DIGITS
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')
예제 #20
0
파일: views.py 프로젝트: Cloud-CV/DIGITS
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)
예제 #21
0
파일: views.py 프로젝트: Cloud-CV/DIGITS
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')
예제 #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)
예제 #23
0
파일: views.py 프로젝트: iwalkdaline/DIGITS
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)
예제 #24
0
파일: views.py 프로젝트: iwalkdaline/DIGITS
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')
예제 #25
0
파일: views.py 프로젝트: Cloud-CV/DIGITS
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))
예제 #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)
예제 #27
0
파일: views.py 프로젝트: iwalkdaline/DIGITS
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))
예제 #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))
예제 #29
0
파일: views.py 프로젝트: Cloud-CV/DIGITS
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')