Skip to content
Snippets Groups Projects
Commit 7ee78564 authored by Yves Noirjean's avatar Yves Noirjean
Browse files

obis: added option to set experiment id when obis init

parent d28606d6
No related branches found
No related tags found
No related merge requests found
......@@ -131,37 +131,41 @@ def set_property(data_mgmt, prop, value, is_global):
return CommandResult(returncode=0, output="")
def init_data_impl(ctx, sample_id, folder, name):
def init_data_impl(ctx, sample_id, experiment_id, folder, name):
"""Shared implementation for the init_data command."""
click_echo("init_data {}".format(folder))
data_mgmt = shared_data_mgmt(ctx.obj)
name = name if name != "" else None
result = data_mgmt.init_data(folder, name, create=True)
if not sample_id or result.failure():
if (not sample_id and not experiment_id) or result.failure():
return check_result("init_data", result)
with dm.cd(folder):
return check_result("init_data", set_property(data_mgmt, 'sample_id', sample_id, False))
if sample_id:
return check_result("init_data", set_property(data_mgmt, 'sample_id', sample_id, False))
if experiment_id:
return check_result("init_data", set_property(data_mgmt, 'experiment_id', experiment_id, False))
# TODO test and add param for experiment
@cli.command()
@click.pass_context
@click.option('-o', '--sample_id', help='Set the id of the owning object.')
@click.option('-si', '--sample_id', help='Set the id of the owning sample.')
@click.option('-ei', '--experiment_id', help='Set the id of the owning experiment.')
@click.argument('folder', type=click.Path(exists=False, file_okay=False))
@click.argument('name', default="")
def init(ctx, sample_id, folder, name):
def init(ctx, sample_id, experiment_id, folder, name):
"""Initialize the folder as a data folder (alias for init_data)."""
return init_data_impl(ctx, sample_id, folder, name)
return init_data_impl(ctx, sample_id, experiment_id, folder, name)
# TODO test and add param for experiment
@cli.command()
@click.pass_context
@click.option('-o', '--sample_id', help='Set the id of the owning object.')
@click.option('-si', '--sample_id', help='Set the id of the owning sample.')
@click.option('-ei', '--experiment_id', help='Set the id of the owning experiment.')
@click.argument('folder', type=click.Path(exists=False, file_okay=False))
@click.argument('name', default="")
def init_data(ctx, sample_id, folder, name):
def init_data(ctx, sample_id, experiment_id, folder, name):
"""Initialize the folder as a data folder."""
return init_data_impl(ctx, sample_id, folder, name)
return init_data_impl(ctx, sample_id, experiment_id, folder, name)
@cli.command()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment