示例#1
0
def disconnect(config, dataset):
    """
    Disconnect and clean-up dataset upload.

    DATASET may be specified by name or ID, but ID is preferred.
    """
    datasets = config.trainml.run(config.trainml.client.datasets.list())

    found = search_by_id_name(dataset, datasets)
    if None is found:
        raise click.UsageError("Cannot find specified dataset.")

    return config.trainml.run(found.disconnect())
示例#2
0
def remove(config, dataset):
    """
    Remove a dataset.

    DATASET may be specified by name or ID, but ID is preferred.
    """
    datasets = config.trainml.run(config.trainml.client.datasets.list())

    found = search_by_id_name(dataset, datasets)
    if None is found:
        raise click.UsageError("Cannot find specified dataset.")

    return config.trainml.run(found.remove())
示例#3
0
def disconnect(config, job):
    """
    Disconnect and clean-up job.

    JOB may be specified by name or ID, but ID is preferred.
    """
    jobs = config.trainml.run(config.trainml.client.jobs.list())

    found = search_by_id_name(job, jobs)
    if None is found:
        raise click.UsageError("Cannot find specified job.")

    return config.trainml.run(found.disconnect())
示例#4
0
def remove(config, project):
    """
    Remove a project.

    PROJECT may be specified by name or ID, but ID is preferred.
    """
    projects = config.trainml.run(config.trainml.client.projects.list())

    found = search_by_id_name(project, projects)
    if None is found:
        raise click.UsageError("Cannot find specified project.")

    return config.trainml.run(found.remove())
示例#5
0
def remove(config, model):
    """
    Remove a model.

    MODEL may be specified by name or ID, but ID is preferred.
    """
    models = config.trainml.run(config.trainml.client.models.list())

    found = search_by_id_name(model, models)
    if None is found:
        raise click.UsageError("Cannot find specified model.")

    return config.trainml.run(found.remove())
示例#6
0
def disconnect(config, model):
    """
    Disconnect and clean-up model upload.

    MODEL may be specified by name or ID, but ID is preferred.
    """
    models = config.trainml.run(config.trainml.client.models.list())

    found = search_by_id_name(model, models)
    if None is found:
        raise click.UsageError("Cannot find specified model.")

    return config.trainml.run(found.disconnect())
示例#7
0
def remove(config, id):
    """Remove connection."""
    connections = config.trainml.run(config.trainml.client.connections.list())

    found = search_by_id_name(id, connections)
    if None is found:
        raise click.UsageError("Connection ID specified does not exist.")

    if found.type == "dataset":
        this = config.trainml.run(config.trainml.client.datasets.get(id))
    elif found.type == "job":
        this = config.trainml.run(config.trainml.client.jobs.get(id))
    else:
        raise click.UsageError("Unknown connection type.")

    return config.trainml.run(this.disconnect())
示例#8
0
def connect(config, job, attach):
    """
    Connect to job.

    JOB may be specified by name or ID, but ID is preferred.
    """
    jobs = config.trainml.run(config.trainml.client.jobs.list())

    found = search_by_id_name(job, jobs)
    if None is found:
        raise click.UsageError("Cannot find specified job.")

    if found.type != "notebook":
        try:
            if attach:
                config.trainml.run(found.connect(), found.attach())
                return config.trainml.run(found.disconnect())
            else:
                return config.trainml.run(found.connect())
        except:
            try:
                config.trainml.run(found.disconnect())
            except:
                pass
            raise
    else:
        if found.status == "waiting for data/model download":
            try:
                if attach:
                    config.trainml.run(found.connect(), found.attach())
                    config.trainml.run(found.disconnect())
                    click.echo("Launching...", file=config.stdout)
                    browse(found.notebook_url)
                else:
                    return config.trainml.run(found.connect())
            except:
                try:
                    config.trainml.run(found.disconnect())
                except:
                    pass
                raise
        else:
            config.trainml.run(found.wait_for("running"))
            click.echo("Launching...", file=config.stdout)
            browse(found.notebook_url)
示例#9
0
def stop(config, job, wait):
    """
    Stop a running job.

    JOB may be specified by name or ID, but ID is preferred.
    """
    jobs = config.trainml.run(config.trainml.client.jobs.list())

    found = search_by_id_name(job, jobs)
    if None is found:
        raise click.UsageError("Cannot find specified job.")

    if wait:
        config.trainml.run(found.stop())
        click.echo("Waiting for job to stop...", file=config.stdout)
        return config.trainml.run(found.wait_for("stopped"))
    else:
        return config.trainml.run(found.stop())
示例#10
0
def start(config, job, connect):
    """
    Start a previously stopped job.

    JOB may be specified by name or ID, but ID is preferred.
    """
    jobs = config.trainml.run(config.trainml.client.jobs.list())

    found = search_by_id_name(job, jobs)
    if None is found:
        raise click.UsageError("Cannot find specified job.")

    if connect:
        config.trainml.run(found.start())
        click.echo("Waiting for job to start...", file=config.stdout)
        config.trainml.run(found.wait_for("running"))
        click.echo("Launching...", file=config.stdout)
        browse(found.notebook_url)
    else:
        return config.trainml.run(found.start())
示例#11
0
def attach(config, dataset):
    """
    Attach to dataset and show creation logs.

    DATASET may be specified by name or ID, but ID is preferred.
    """
    datasets = config.trainml.run(config.trainml.client.datasets.list())

    found = search_by_id_name(dataset, datasets)
    if None is found:
        raise click.UsageError("Cannot find specified dataset.")

    try:
        config.trainml.run(found.attach())
        return config.trainml.run(found.disconnect())
    except:
        try:
            config.trainml.run(found.disconnect())
        except:
            pass
        raise
示例#12
0
def attach(config, job):
    """
    Attach to job and show logs.

    JOB may be specified by name or ID, but ID is preferred.
    """
    jobs = config.trainml.run(config.trainml.client.jobs.list())

    found = search_by_id_name(job, jobs)
    if None is found:
        raise click.UsageError("Cannot find specified job.")

    try:
        config.trainml.run(found.attach())
        return config.trainml.run(found.disconnect())
    except:
        try:
            config.trainml.run(found.disconnect())
        except:
            pass
        raise
示例#13
0
def attach(config, model):
    """
    Attach to model and show creation logs.

    MODEL may be specified by name or ID, but ID is preferred.
    """
    models = config.trainml.run(config.trainml.client.models.list())

    found = search_by_id_name(model, models)
    if None is found:
        raise click.UsageError("Cannot find specified model.")

    try:
        config.trainml.run(found.attach())
        return config.trainml.run(found.disconnect())
    except:
        try:
            config.trainml.run(found.disconnect())
        except:
            pass
        raise
示例#14
0
def connect(config, dataset, attach):
    """
    Connect local source to dataset and begin upload.

    DATASET may be specified by name or ID, but ID is preferred.
    """
    datasets = config.trainml.run(config.trainml.client.datasets.list())

    found = search_by_id_name(dataset, datasets)
    if None is found:
        raise click.UsageError("Cannot find specified dataset.")

    try:
        if attach:
            config.trainml.run(found.connect(), found.attach())
            return config.trainml.run(found.disconnect())
        else:
            return config.trainml.run(found.connect())
    except:
        try:
            config.trainml.run(found.disconnect())
        except:
            pass
        raise
示例#15
0
def connect(config, model, attach):
    """
    Connect local source to model and begin upload.

    MODEL may be specified by name or ID, but ID is preferred.
    """
    models = config.trainml.run(config.trainml.client.models.list())

    found = search_by_id_name(model, models)
    if None is found:
        raise click.UsageError("Cannot find specified model.")

    try:
        if attach:
            config.trainml.run(found.connect(), found.attach())
            return config.trainml.run(found.disconnect())
        else:
            return config.trainml.run(found.connect())
    except:
        try:
            config.trainml.run(found.disconnect())
        except:
            pass
        raise