コード例 #1
0
def start_workspace(id_, start_with_latest_version=False, **kwargs):
    """Start a job
    :param id_: The ID of the workspace resource
    :type id_: str
    :param start_with_latest_version: Start job with the latest revision of the project
    :type start_with_latest_version: bool

    :rtype: StatusSerializer
    """
    w = get_workspace_object(id_)
    check_workspace_permission(w, kwargs["token_info"])
    stub = get_workspaces_services_stub()

    if start_with_latest_version:
        w.spec.revision = get_latest_project_revision(w.metadata.project)
        w = stub.Update(w)

    response = stub.Start(job_pb2.ID(id=w.id))

    if response.status != 200:
        return ErrorSerializer(status=response.status,
                               title="Api Error",
                               detail=response.message), response.status

    return StatusSerializer.from_dict(util.deserialize_protobuf(response))
コード例 #2
0
def delete_hardwaretier(id_, **kwargs):
    """Delete HardwareTier
    :param id_: The ID of the hardware resource
    :type id_: str

    :rtype: StatusSerializer
    """
    stub = get_environments_services_stub()
    response = stub.DeleteHardwareTier(job_pb2.ID(id=id_))

    if response.status != 200:
        return ErrorSerializer(status=response.status,
                               title="Api Error",
                               detail=response.message), response.status

    return StatusSerializer.from_dict(util.deserialize_protobuf(response))
コード例 #3
0
def delete_project(id_, **kwargs):
    """Delete a project
    :param id_: The ID of the project object to be deleted
    :type id_: str

    :rtype: StatusSerializer
    """
    proj = get_project_object(id_)
    check_project_permission(proj, kwargs["token_info"])
    stub = get_projects_services_stub()
    response = stub.Delete(project_pb2.ID(id=proj.id))

    if response.status != 200:
        return ErrorSerializer(status=response.status,
                               title="Api Error",
                               detail=response.message), response.status

    return StatusSerializer.from_dict(util.deserialize_protobuf(response))
コード例 #4
0
def delete_workspace(id_, **kwargs):
    """Delete a workspace
    :param id_: The ID of the workspace resource
    :type id_: str

    :rtype: StatusSerializer
    """
    w = get_workspace_object(id_)
    check_workspace_permission(w, kwargs["token_info"])

    stub = get_workspaces_services_stub()
    response = stub.Delete(job_pb2.ID(id=id_))

    if response.status != 200:
        return ErrorSerializer(status=response.status,
                               title="Api Error",
                               detail=response.message), response.status

    return StatusSerializer.from_dict(util.deserialize_protobuf(response))
コード例 #5
0
def submit_experiment(body, **kwargs):
    """Submit an experiment

    :param body: experiment payload
    :type body: dict | bytes

    :rtype: StatusSerializer
    """

    serializer = ExperimentSerializer.from_dict(body)
    check_experiment_permission(serializer, kwargs["token_info"])
    stub = get_experiments_services_stub()
    response = stub.Submit(job_pb2.Experiment(**body))

    if response.status != 200:
        return ErrorSerializer(status=response.status,
                               title="Api Error",
                               detail=response.message), response.status

    return StatusSerializer.from_dict(util.deserialize_protobuf(response))
コード例 #6
0
def stop_experiment(id_, **kwargs):
    """Stop a running experiment.

    :param id_: The ID of the experiment resource
    :type id_: str

    :rtype: StatusSerializer
    """

    exp = get_experiment_object(id_)
    check_experiment_permission(exp, kwargs["token_info"])

    stub = get_experiments_services_stub()
    response = stub.Stop(job_pb2.ID(id=id_))

    if response.status != 200:
        return ErrorSerializer(status=response.status,
                               title="Api Error",
                               detail=response.message), response.status

    return StatusSerializer.from_dict(util.deserialize_protobuf(response))