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 from_json(config, attach, connect, file): """ Create an job from json file representation. """ payload = json.loads(file.read()) job = config.trainml.run(config.trainml.client.jobs.create_json(payload)) click.echo("Created.", file=config.stdout) if attach or connect: if job.type == "notebook": click.echo("Waiting for job to start...", file=config.stdout) config.trainml.run(job.wait_for("running")) click.echo("Launching...", file=config.stdout) browse(job.notebook_url) else: if connect: config.trainml.run(job.connect()) if attach: config.trainml.run(job.attach())
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 donate_link(): browse("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=EXQQ6WC5VR666")
def block_explorers(): """ use system browser to open block explorers """ print("opening block explorers for client test accounts...") for coin, account in TEST.items(): if coin == "bts": browse(BITSHARES_EXPLORER + account["public"], 1) # 1 = open a new window elif coin == "xrp": browse(RIPPLE_EXPLORER + account["public"], 2) # 2 = open a new tab elif coin == "eos": browse(EOSIO_EXPLORER + account["public"], 2) print("opening block explorers for ripple gateway deposit accounts...") for idx, account in enumerate(GATE["xrp"]): browse(RIPPLE_EXPLORER + account["public"], int(bool(idx)) + 1) print("opening block explorers for eosio gateway deposit accounts...") for idx, account in enumerate(GATE["eos"]): browse(EOSIO_EXPLORER + account["public"], int(bool(idx)) + 1) print("opening block explorers for bitshares asset issuer accounts...") browse(BITSHARES_EXPLORER + GATE["uia"]["eos"]["issuer_public"], 1) browse(BITSHARES_EXPLORER + GATE["uia"]["xrp"]["issuer_public"], 2) print("done")
def notebook( config, attach, connect, disk_size, gpu_count, gpu_type, data_dir, dataset, public_dataset, environment, custom_image, env, key, apt_packages, pip_packages, conda_packages, model_dir, git_uri, model_id, name, ): """ Create a notebook. """ datasets = [dict(id=item, type="existing") for item in dataset ] + [dict(id=item, type="public") for item in public_dataset] options = dict( data=dict(datasets=datasets), environment=dict( type="CUSTOM" if custom_image else environment, custom_image=custom_image, worker_key_types=[k for k in key], ), ) try: envs = [{ "key": e.split("=")[0], "value": e.split("=")[1] } for e in env] options["environment"]["env"] = envs except IndexError: raise click.UsageError( "Invalid environment variable format. Must be in 'KEY=VALUE' format." ) if apt_packages or pip_packages or conda_packages: options["environment"]["packages"] = dict() if apt_packages: options["environment"]["packages"]["apt"] = apt_packages.split(",") if pip_packages: options["environment"]["packages"]["pip"] = pip_packages.split(",") if conda_packages: options["environment"]["packages"]["conda"] = conda_packages.split( ",") if data_dir: click.echo("Creating Dataset..", file=config.stdout) new_dataset = config.trainml.run( config.trainml.client.datasets.create(f"Job - {name}", "local", data_dir)) if attach: config.trainml.run(new_dataset.attach(), new_dataset.connect()) config.trainml.run(new_dataset.disconnect()) else: config.trainml.run(new_dataset.connect()) config.trainml.run(new_dataset.wait_for("ready")) config.trainml.run(new_dataset.disconnect()) options["data"]["datasets"].append( dict(id=new_dataset.id, type="existing")) if git_uri: options["model"] = dict(source_type="git", source_uri=git_uri) if model_id: options["model"] = dict(source_type="trainml", source_uri=model_id) if model_dir: options["model"] = dict(source_type="local", source_uri=model_dir) job = config.trainml.run( config.trainml.client.jobs.create( name=name, type="notebook", gpu_type=gpu_type, gpu_count=gpu_count, disk_size=disk_size, **options, )) click.echo("Created Job.", file=config.stdout) if model_dir: config.trainml.run(job.wait_for("waiting for data/model download")) if attach or connect: click.echo("Waiting for job to start...", file=config.stdout) config.trainml.run(job.connect(), job.attach()) config.trainml.run(job.disconnect()) click.echo("Launching...", file=config.stdout) browse(job.notebook_url) else: config.trainml.run(job.connect()) config.trainml.run(job.wait_for("running")) config.trainml.run(job.disconnect()) elif attach or connect: click.echo("Waiting for job to start...", file=config.stdout) config.trainml.run(job.wait_for("running")) click.echo("Launching...", file=config.stdout) browse(job.notebook_url)
def onKADE(self, event): from webbrowser import open as browse browse("http://kadevice.com")
def donate_link(): browse( "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=EXQQ6WC5VR666" )