Exemplo n.º 1
0
def training(job_name, package_path, module_name, image_tag, dataset_path, num_gpu, user_args):
    dst_path = ''
    job_id = None
    project = os.getenv('PROJECT', None)
    if project is None:
        click.echo("PROJECT not defined, use '{}' as project name".format(job_name))
        project = job_name
    if package_path:
        if not os.path.exists(package_path):
            click.echo('--package-path: {} not exists!'.format(package_path))
            return
    try:
        args = [a for a in user_args]
        api = MyelindlApi()
        result = api.job_create(
            project=project,
            pkg_path=package_path,
            image_tag=image_tag,
            dataset_path=dataset_path,
            job_name=job_name,
            module_name=module_name,
            num_gpu=num_gpu,
            user_args=' '.join(args),
        )
        job_id = result['id']
        click.echo('Job id: {}'.format(job_id))
        result = api.job_train(job_id)
        click.echo('Job {}: {}'.format(job_name, result))
    except MyelindlApiError as e:
        if job_id:
            api.job_delete(job_id)
        click.echo("submit failed, %s"% str(e))
Exemplo n.º 2
0
def delete(job_id):
    try:
        api = MyelindlApi()
        result = api.job_delete(job_id)
        click.echo(result)
    except Exception, e:
        click.echo("failed, {}".format(e))