How to use the renku.cli.cli function in renku

To help you get started, we’ve selected a few renku examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SwissDataScienceCenter / renku-python / tests / cli / test_show.py View on Github external
def test_show_outputs_with_directory(runner, client, run):
    """Output files in directory are not shown as separate outputs."""
    base_sh = [
        'bash', '-c', 'DIR="$0"; mkdir -p "$DIR"; '
        'for x in "$@"; do touch "$DIR/$x"; done'
    ]

    assert 0 == run(args=['run'] + base_sh + ['output', 'foo', 'bar'])
    assert (client.path / 'output' / 'foo').exists()
    assert (client.path / 'output' / 'bar').exists()

    cmd = ['show', 'outputs']
    result = runner.invoke(cli, cmd)
    assert 0 == result.exit_code
    assert {'output'} == set(result.output.strip().split('\n'))

    result = runner.invoke(cli, cmd + ['output'])
    assert 0 == result.exit_code
    assert {'output'} == set(result.output.strip().split('\n'))

    result = runner.invoke(cli, cmd + ['output/foo'])
    assert 0 == result.exit_code
    assert {'output'} == set(result.output.strip().split('\n'))

    result = runner.invoke(cli, cmd + ['output/foo', 'output/bar'])
    assert 0 == result.exit_code
    assert {'output'} == set(result.output.strip().split('\n'))
github SwissDataScienceCenter / renku-python / tests / cli / test_run.py View on Github external
def test_run_simple(runner, project):
    """Test tracking of run command."""
    cmd = ['echo', 'test']
    result = runner.invoke(cli, ['run', '--no-output'] + cmd)
    assert 0 == result.exit_code

    # There are no output files.
    result = runner.invoke(cli, ['log'])
    assert 1 == len(result.output.strip().split('\n'))

    # Display tools with no outputs.
    result = runner.invoke(cli, ['log', '--no-output'])
    assert '.renku/workflow/' in result.output
github SwissDataScienceCenter / renku-python / tests / cli / test_migrate.py View on Github external
def test_status_with_old_repository(isolated_runner, old_project):
    """Test status on all old repositories created by old version of renku."""
    runner = isolated_runner
    result = runner.invoke(cli, ['status'])
    assert 0 == result.exit_code

    output = result.output.split('\n')
    assert output.pop(0) == 'On branch master'
    assert output.pop(0) == 'All files were generated from the latest inputs.'
github SwissDataScienceCenter / renku-python / tests / cli / test_rerun.py View on Github external
data.write_text('data')

    # Empty destination
    destination = cwd / 'destination'
    source_wc = cwd / 'destination_source.wc'
    # Non empty destination
    invalid_destination = cwd / 'invalid_destination'
    invalid_destination.mkdir(parents=True)
    (invalid_destination / 'non_empty').touch()

    repo = git.Repo(project)
    repo.git.add('--all')
    repo.index.commit('Created source directory')

    cmd = ['run', 'cp', '-LRf', str(source), str(destination)]
    result = runner.invoke(cli, cmd, catch_exceptions=False)
    assert 0 == result.exit_code

    destination_source = destination / data.name
    assert destination_source.exists()

    # check that the output in subdir is added to LFS
    with (cwd / '.gitattributes').open() as f:
        gitattr = f.read()
    assert str(destination.relative_to(cwd)) + '/**' in gitattr
    assert destination_source.name in subprocess.check_output([
        'git', 'lfs', 'ls-files'
    ]).decode()

    cmd = ['run', 'wc']
    assert 0 == run(args=cmd, stdin=destination_source, stdout=source_wc)
github SwissDataScienceCenter / renku-python / tests / cli / test_remove.py View on Github external
def test_remove_dataset_file(isolated_runner, client, tmpdir):
    """Test remove of a file that belongs to a dataset."""
    runner = isolated_runner

    # create a dataset
    result = runner.invoke(cli, ['dataset', 'create', 'testing'])
    assert 0 == result.exit_code
    assert 'OK' in result.output

    source = tmpdir.join('remove_dataset.file')
    source.write('data')

    result = runner.invoke(cli, ['dataset', 'add', 'testing', source.strpath])
    assert 0 == result.exit_code

    assert (client.path / client.datadir / 'testing' /
            'remove_dataset.file').exists()

    result = runner.invoke(cli, ['doctor'])
    assert 0 == result.exit_code

    result = runner.invoke(cli, ['rm', 'data'])
github SwissDataScienceCenter / renku-python / tests / cli / test_log.py View on Github external
test_paths = []
    for i in range(3):
        new_file = tmpdir.join('file_{0}'.format(i))
        new_file.write(str(i))
        paths.append(str(new_file))
        test_paths.append(str(new_file.relto(tmpdir.join('..'))))

    # add data
    result = runner.invoke(
        cli,
        ['dataset', 'add', 'my-dataset'] + paths,
    )
    assert 0 == result.exit_code

    result = runner.invoke(
        cli, ['log', '--strict', '--format={}'.format(format)]
    )

    assert 0 == result.exit_code, result.output
    assert all(p in result.output for p in test_paths)
github SwissDataScienceCenter / renku-python / tests / cli / test_log.py View on Github external
def test_run_log_strict(runner, project, run_shell, format):
    """Test log output of run command."""
    # Run a shell command with pipe.
    result = run_shell('renku run echo "a" > output')

    # Assert created output file.
    result = runner.invoke(
        cli, ['log', '--strict', '--format={}'.format(format)]
    )
    assert 0 == result.exit_code, result.output
    assert '.renku/workflow/' in result.output
github SwissDataScienceCenter / renku-python / tests / core / commands / test_doctor.py View on Github external
def test_git_hooks(runner, project):
    """Test detection of not-installed git hooks."""
    # Initially, every thing is OK
    result = runner.invoke(cli, ['doctor'])
    assert 0 == result.exit_code
    assert 'Everything seems to be ok.' in result.output

    result = runner.invoke(cli, ['githooks', 'uninstall'])
    assert 0 == result.exit_code

    result = runner.invoke(cli, ['doctor'])
    assert 1 == result.exit_code
    assert 'Git hooks are not installed.' in result.output
github SwissDataScienceCenter / renku-python / tests / cli / test_datasets.py View on Github external
def test_datasets_create_clean(runner, project, client):
    """Test creating a dataset in clean repository."""
    # create a dataset
    result = runner.invoke(cli, ['dataset', 'create', 'dataset'])
    assert 0 == result.exit_code
    assert 'OK' in result.output

    dataset = client.load_dataset(name='dataset')
    assert dataset

    staged = client.repo.index.diff('HEAD')
    for file_path in staged:
        assert 'datasets' not in file_path

    untracked = client.repo.untracked_files
    for file_path in untracked:
        assert 'datasets' not in file_path
github SwissDataScienceCenter / renku-python / tests / cli / test_range_queries.py View on Github external
def test_limit_log(runner, project, run):
    """Test naming of CWL tools and workflows."""
    cwd = Path(project)
    data = cwd / 'data.txt'
    output = cwd / 'output.txt'

    assert 0 == run(args=('run', 'echo', 'hello'), stdout=data)
    assert data.exists()

    assert 0 == run(args=('run', 'wc', '-c'), stdin=data, stdout=output)
    assert output.exists()

    cmd = ['log', '--revision', 'HEAD^..', output.name]
    result = runner.invoke(cli, cmd)
    assert 0 == result.exit_code
    assert data.name not in result.output
    assert output.name in result.output

    cmd = ['log', '--revision', 'HEAD^']
    result = runner.invoke(cli, cmd)
    assert 0 == result.exit_code
    assert data.name in result.output
    assert output.name not in result.output