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

Add fromwdl to janisdk #58

Merged
merged 2 commits into from
Jun 14, 2023
Merged

Add fromwdl to janisdk #58

merged 2 commits into from
Jun 14, 2023

Conversation

illusional
Copy link
Member

Blocked by release of janis-core v0.11.5: PMCC-BioinformaticsCore/janis-core#102

Copy link

@mr-c mr-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My personal script also caught exceptions and exposed the file name, line number, and columns of errors; does that happen as well here?

try:
    WdlParser.from_doc(sys.argv[1]).translate("cwl");
except MultipleValidationErrors as err:
    for exc in err.exceptions:
        print(exc, file=sys.stderr)
        print(exc.pos, file=sys.stderr)
        print(exc.node, file=sys.stderr)
except ValidationError as exc:
    print(exc, file=sys.stderr)
    print(exc.pos, file=sys.stderr)
    print(exc.node, file=sys.stderr)

parser.add_argument("wdlfile", help="The path to the WDL file")

parser.add_argument(
"translation", default="janis", choices=["wdl", "wdl", "janis"], nargs="?"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdl and wdl?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

find-replace ftw 🤦

illusional added a commit to PMCC-BioinformaticsCore/janis-core that referenced this pull request Sep 1, 2021
Comment on lines 30 to 35
translated = tool.translate(
args.translation,
to_console=args.output is None,
to_disk=args.output is not None,
export_path=args.output,
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. I was thinking that the "try/except ValidationError" logic would go here. But I see that this function returns the translation, so it might be intended to be used outside of the CLI where printing to stderr would be appropriate. Maybe amend the ValidationError class to always include the pos and node information would be a nicer solution? That way everyone wins.

@kinow
Copy link
Contributor

kinow commented Oct 28, 2021

Was testing a WDL workflow with the wdl-cwl-translator, then decided to try the fromwdl (remembering seeing the fromcwl). I saw all the code was already prepared in janis and janis-core, but it wasn't available in janisdk yet. So my +1

That workflow in the issue linked didn't work, but I believe that's for a future enhancement. The error reported was:

(venv) kinow@ranma:~/Development/python/workspace/janis$ janisdk fromwdl ../warp/pipelines/skylab/build_indices/BuildIndices.wdl 
2021-10-28T17:21:35 [INFO]: Loading WDL file: ../warp/pipelines/skylab/build_indices/BuildIndices.wdl
Traceback (most recent call last):
  File "/home/kinow/Development/python/workspace/janis/venv/bin/janisdk", line 33, in <module>
    sys.exit(load_entry_point('janis-pipelines', 'console_scripts', 'janisdk')())
  File "/home/kinow/Development/python/workspace/janis/janisdk/main.py", line 27, in process_args
    return cmds[args.command](args)
  File "/home/kinow/Development/python/workspace/janis/janisdk/fromwdl/__init__.py", line 26, in do_fromwdl
    tool = WdlParser.from_doc(args.wdlfile)
  File "/home/kinow/Development/python/workspace/janis-core/janis_core/ingestion/fromwdl.py", line 43, in from_doc
    return parser.from_loaded_object(d.workflow)
  File "/home/kinow/Development/python/workspace/janis-core/janis_core/ingestion/fromwdl.py", line 55, in from_loaded_object
    return self.from_loaded_workflow(obj)
  File "/home/kinow/Development/python/workspace/janis-core/janis_core/ingestion/fromwdl.py", line 64, in from_loaded_workflow
    self.add_call_to_wf(wf, call)
  File "/home/kinow/Development/python/workspace/janis-core/janis_core/ingestion/fromwdl.py", line 18, in wrapper
    return func(*args, **kwargs)
  File "/home/kinow/Development/python/workspace/janis-core/janis_core/ingestion/fromwdl.py", line 93, in add_call_to_wf
    task = self.from_loaded_object(call.callee)
  File "/home/kinow/Development/python/workspace/janis-core/janis_core/ingestion/fromwdl.py", line 53, in from_loaded_object
    return self.from_loaded_task(obj)
  File "/home/kinow/Development/python/workspace/janis-core/janis_core/ingestion/fromwdl.py", line 254, in from_loaded_task
    outputs=[self.parse_command_tool_output(o) for o in obj.outputs],
  File "/home/kinow/Development/python/workspace/janis-core/janis_core/ingestion/fromwdl.py", line 254, in <listcomp>
    outputs=[self.parse_command_tool_output(o) for o in obj.outputs],
  File "/home/kinow/Development/python/workspace/janis-core/janis_core/ingestion/fromwdl.py", line 438, in parse_command_tool_output
    sel = self.translate_expr(outp.expr)
  File "/home/kinow/Development/python/workspace/janis-core/janis_core/ingestion/fromwdl.py", line 294, in translate_expr
    raise Exception(f"Unsupported WDL expression type: {expr} ({type(expr)})")
Exception: Unsupported WDL expression type: {"genome_fa": genome_fa, "annotation_gtf": annotation_gtf} (<class 'WDL.Expr.Struct'>)

(Note: I patched janis-core and janis to have fromwdl, it was before I found this PR 👍 )

@rlupat rlupat merged commit bc59add into master Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants