How to use the renku.core.models.cwl.ascwl.CWLClass.from_cwl 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 / core / commands / test_cli.py View on Github external
repo = client.repo
    greeting = client.path / 'greeting.txt'

    assert 0 == run(args=('run', 'echo', 'hello'), stdout=greeting)

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

    # There should be only one command line tool.
    tools = list(client.workflow_path.glob('*_echo.cwl'))
    assert 1 == len(tools)

    tool_path = tools[0]
    with tool_path.open('r') as f:
        command_line_tool = CWLClass.from_cwl(yaml.safe_load(f))

    # Simulate a manual edit.
    command_line_tool.inputs[0].default = 'ahoj'
    command_line_tool.stdout = 'pozdrav.txt'

    with tool_path.open('w') as f:
        yaml.dump(
            ascwl(
                command_line_tool,
                filter=lambda _, x: x is not None,
                basedir=client.workflow_path,
            ),
            stream=f,
            default_flow_style=False
        )
github SwissDataScienceCenter / renku-python / renku / core / models / provenance / activities.py View on Github external
def _load(step):
            """Load step definition."""
            if isinstance(step.run, WORKFLOW_STEP_RUN_TYPES):
                return step.run

            if self.commit:
                import yaml
                data = (self.commit.tree / basedir /
                        step.run).data_stream.read()
                return CWLClass.from_cwl(yaml.safe_load(data))

            return CWLClass.from_yaml(step.run)
github SwissDataScienceCenter / renku-python / renku / core / models / cwl / parameter.py View on Github external
def convert_default(value):
    """Convert a default value."""
    if isinstance(value, dict):
        return CWLClass.from_cwl(value)
    return value
github SwissDataScienceCenter / renku-python / renku / core / management / repository.py View on Github external
if len(commit.parents) > 1:
            return Activity(commit=commit, client=self)

        if path is None:
            for file_ in commit.stats.files.keys():
                # Find a process (CommandLineTool or Workflow)
                if self.is_cwl(file_):
                    if path is not None:
                        # Regular activity since it edits multiple CWL files
                        return Activity(commit=commit, client=self)

                    path = file_

        if path:
            data = (commit.tree / path).data_stream.read()
            process = CWLClass.from_cwl(
                yaml.safe_load(data), __reference__=Path(path)
            )

            return process.create_run(
                commit=commit,
                client=self,
                process=process,
                path=path,
            )

        return Activity(commit=commit, client=self)
github SwissDataScienceCenter / renku-python / renku / core / models / cwl / workflow.py View on Github external
def convert_run(value):
    """Convert value to CWLClass if dict is given."""
    if isinstance(value, dict):
        return CWLClass.from_cwl(value)
    return value