示例#1
0
def publish(data_dir, name, id, type, description):

    if not os.path.exists(data_dir):
        click.echo('data-dir: {} not exists!'.format(data_dir))

    temp_dir = 'mlt_tmp-{}'.format(str(uuid.uuid1())[:8])
    try:
        api = MyelindlApi()
        api.data_upload(data_dir, temp_dir)

        dataset_id = id if id else ''
        dataset_type = type if type else 'file'

        result = api.publish_dataset(
            id=dataset_id,
            type=dataset_type,
            name=name,
            description=description,
            data_dir=temp_dir,
        )

        click.echo('Dataset {} published with id {}'.format(
            name, result['id']))
    except MyelindlApiError as e:
        click.echo(u'Dataset publish fail, due to {}'.format(str(e)))
        raise
示例#2
0
def push(tag, model_dir, description, type):
    if not os.path.exists(model_dir):
        click.echo('model-dir: {} not exists!'.format(model_dir))

    temp_dir = 'mlt_tmp-{}'.format(str(uuid.uuid1())[:8])
    try:
        api = MyelindlApi()
        api.data_upload(model_dir, temp_dir)

        dataset_id = id if id else ''
        dataset_type = type if type else 'file'
        
        result = api.model_push(
            tag,
            temp_dir,
            description,
            type,
        )
        click.echo( 'Model {} pushed.'.format(tag))
    except MyelindlApiError as e:
        print str(e)
        click.echo( 'Dataset publish fail, due to {}'.format(str(e)))
        raise