How to use the renku.core.management.config.RENKU_HOME 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_datasets.py View on Github external
def test_dataset_create_exception_refs(runner, project, client):
    """Test untracked/unstaged exception raise in dirty renku home dir."""
    with (client.path / 'a').open('w') as fp:
        fp.write('a')

    datasets_dir = client.path / RENKU_HOME / DatasetsApiMixin.DATASETS
    if not datasets_dir.exists():
        datasets_dir.mkdir()

    with (datasets_dir / 'a').open('w') as fp:
        fp.write('a')

    refs_dir = client.path / RENKU_HOME / LinkReference.REFS
    if not refs_dir.exists():
        refs_dir.mkdir()

    with (refs_dir / 'b').open('w') as fp:
        fp.write('b')

    result = runner.invoke(cli, ['dataset', 'create', 'dataset'])
    assert 1 == result.exit_code
    assert 'a' in result.output
github SwissDataScienceCenter / renku-python / tests / cli / test_migrate.py View on Github external
def test_correct_relative_path(isolated_runner, old_project):
    """Check if path on dataset has been correctly migrated."""
    result = isolated_runner.invoke(cli, ['migrate', 'datasets'])
    assert 0 == result.exit_code

    client = LocalClient(path=old_project['path'])
    assert client.datasets

    for ds in client.datasets.values():
        assert not Path(ds.path).is_absolute()
        assert ds.path.startswith(RENKU_HOME)
github SwissDataScienceCenter / renku-python / renku / core / models / cwl / command_line_tool.py View on Github external
import attr
import click

from renku.core import errors

from ...management.config import RENKU_HOME
from ..datastructures import DirectoryTree
from .ascwl import CWLClass, mapped
from .parameter import CommandInputParameter, CommandLineBinding, \
    CommandOutputParameter
from .process import Process
from .types import PATH_OBJECTS, Directory, File

STARTED_AT = int(time.time() * 1000)

RENKU_TMP_DIR = os.path.join(RENKU_HOME, 'tmp')
RENKU_FILELIST_PATH = os.getenv('RENKU_FILELIST_PATH', RENKU_TMP_DIR)
INDIRECT_INPUTS_LIST = os.path.join(RENKU_FILELIST_PATH, 'inputs.txt')
INDIRECT_OUTPUTS_LIST = os.path.join(RENKU_FILELIST_PATH, 'outputs.txt')


def convert_arguments(value):
    """Convert arguments from various input formats."""
    if isinstance(value, (list, tuple)):
        return [
            CommandLineBinding(**item) if isinstance(item, dict) else item
            for item in value
        ]
    return shlex.split(value)


@attr.s
github SwissDataScienceCenter / renku-python / renku / core / management / datasets.py View on Github external
if is_remote:
        is_git = u.path.endswith('.git')
    else:
        try:
            Repo(u.path, search_parent_directories=True)
        except GitError:
            pass
        else:
            is_git = True

    return is_remote, is_git


DATASET_METADATA_PATHS = [
    Path(RENKU_HOME) / Path(DatasetsApiMixin.DATASETS),
    Path(RENKU_HOME) / Path(LinkReference.REFS),
]
github SwissDataScienceCenter / renku-python / renku / core / commands / init.py View on Github external
def validate_template(template_path):
    """Validate a local template.

    :param template_path: path of the template to validate
    """
    # TODO: implement a better check
    required_folders = [RENKU_HOME]
    required_files = ['{0}/renku.ini'.format(RENKU_HOME), 'Dockerfile']
    for folder in required_folders:
        if not Path(template_path, folder).is_dir():
            raise errors.InvalidTemplateError(
                'Folder {0} is required for the template to be valid'.
                format(folder)
            )
    for file in required_files:
        if not Path(template_path, file).is_file():
            raise errors.InvalidTemplateError(
                'File {0} is required for the template to be valid'.
                format(file)
            )
    return True
github SwissDataScienceCenter / renku-python / renku / core / errors.py View on Github external
def __init__(self, repo):
        """Build a custom message."""
        super(DirtyRenkuDirectory, self).__init__((
            'The renku directory {0} contains uncommitted changes.\n'
            'Please use "git" command to resolve.\n'
            'Files within {0} directory '
            'need to be manually committed or removed.'
        ).format(RENKU_HOME) + '\n\n' + str(repo.git.status()) + '\n\n')
github SwissDataScienceCenter / renku-python / renku / core / commands / client.py View on Github external
def new_func(*args, **kwargs):
        ctx = click.get_current_context(silent=True)
        if ctx is None:
            client = LocalClient(
                path=default_path(),
                renku_home=RENKU_HOME,
                use_external_storage=True,
            )
            ctx = click.Context(click.Command(method))
        else:
            client = ctx.ensure_object(LocalClient)

        stack = contextlib.ExitStack()

        # Handle --isolation option:
        if get_git_isolation():
            client = stack.enter_context(client.worktree())

        transaction = client.transaction(
            clean=clean,
            commit=commit,
            commit_empty=commit_empty,
github SwissDataScienceCenter / renku-python / renku / core / management / repository.py View on Github external
default=default_path,
        converter=path_converter,
    )

    @path.validator
    def _check_path(self, _, value):
        """Check the path exists and it is a directory."""
        if not (value.exists() and value.is_dir()):
            raise ValueError('Define an existing directory.')


@attr.s
class RepositoryApiMixin(GitCore):
    """Client for handling a local repository."""

    renku_home = attr.ib(default=RENKU_HOME)
    """Define a name of the Renku folder (default: ``.renku``)."""

    renku_path = attr.ib(init=False)
    """Store a ``Path`` instance of the Renku folder."""

    parent = attr.ib(default=None)
    """Store a pointer to the parent repository."""

    METADATA = 'metadata.yml'
    """Default name of Renku config file."""

    LOCK_SUFFIX = '.lock'
    """Default suffix for Renku lock file."""

    WORKFLOW = 'workflow'
    """Directory for storing workflow in Renku."""
github SwissDataScienceCenter / renku-python / renku / core / management / datasets.py View on Github external
if is_remote:
        is_git = u.path.endswith('.git')
    else:
        try:
            Repo(u.path, search_parent_directories=True)
        except GitError:
            pass
        else:
            is_git = True

    return is_remote, is_git


DATASET_METADATA_PATHS = [
    Path(RENKU_HOME) / Path(DatasetsApiMixin.DATASETS),
    Path(RENKU_HOME) / Path(LinkReference.REFS),
]
github SwissDataScienceCenter / renku-python / renku / cli / __init__.py View on Github external
    default=RENKU_HOME,
    help='Location of the Renku directory.'
)
@option_use_external_storage
@click.option(
    '--disable-version-check',
    envvar='RENKU_DISABLE_VERSION_CHECK',
    is_flag=True,
    default=False,
    callback=check_version,
    expose_value=False,
    help='Do not periodically check PyPI for a new version of renku.',
)
@click.pass_context
def cli(ctx, path, renku_home, use_external_storage):
    """Check common Renku commands used in various situations."""
    ctx.obj = LocalClient(