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())
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())
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())
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())
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())
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())
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())
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)
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())
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())
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
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
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
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
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