Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: accept workflow file location #137

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions reana_workflow_engine_yadage/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os

import click
import yadageschemas
from reana_commons.config import (REANA_LOG_FORMAT, REANA_LOG_LEVEL,
REANA_WORKFLOW_UMASK)
from reana_commons.utils import check_connection_to_job_controller
Expand Down Expand Up @@ -45,13 +46,17 @@ def load_json(ctx, param, value):
@click.option('--workflow-json',
help='JSON representation of workflow object to be run.',
callback=load_json)
@click.option('--workflow-file',
help='Path to the workflow file. This field is used when'
' no workflow JSON has been passed.')
@click.option('--workflow-parameters',
help='JSON representation of workflow_parameters received by'
' the workflow.',
callback=load_json)
def run_yadage_workflow(workflow_uuid,
workflow_workspace,
workflow_json=None,
workflow_file=None,
workflow_parameters=None):
"""Run a ``yadage`` workflow."""
log.info('getting socket..')
Expand All @@ -73,6 +78,28 @@ def run_yadage_workflow(workflow_uuid,
# When `yadage` resolves the workflow file from a remote repository:
# i.e. github:reanahub/reana-demo-root6-roofit/workflow.yaml
workflow_kwargs = dict(workflow=workflow, toplevel=toplevel)
elif workflow_file:
workflow_file_abs_path = os.path.join(
workflow_workspace, workflow_file)
if os.path.exists(workflow_file_abs_path):
schema_name = 'yadage/workflow-schema'
schemadir = None

specopts = {
'toplevel': workflow_workspace,
'schema_name': schema_name,
'schemadir': schemadir,
'load_as_ref': False,
}

validopts = {
'schema_name': schema_name,
'schemadir': schemadir,
}
workflow_json = yadageschemas.load(
spec=workflow_file, specopts=specopts, validopts=validopts,
validate=True)
workflow_kwargs = dict(workflow_json=workflow_json)

dataopts = {'initdir': workflow_workspace}

Expand Down