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
Show file tree
Hide file tree
Changes from 1 commit
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
37 changes: 37 additions & 0 deletions janisdk/fromwdl/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
def add_fromwdl_args(parser):
parser.description = (
"Parse a WDL command line tool / workflow and write it as a Janis file"
)

parser.add_argument(
"-o",
"--output",
help="Directory to output the workflow / tools to, otherwise this is written to stdout",
)

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 🤦

)

return parser


def do_fromwdl(args):
from janis_core import WdlParser, Logger


Logger.info(f"Loading WDL file: {args.wdlfile}")
tool = WdlParser.from_doc(args.wdlfile)

Logger.info(f"Loaded {tool.type()}: {tool.versioned_id()}")

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.


return translated
4 changes: 3 additions & 1 deletion janisdk/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

from janisdk.container import do_container, add_container_args
from janisdk.fromcwl import do_fromcwl, add_fromcwl_args
from janisdk.fromwdl import do_fromwdl, add_fromwdl_args
from janisdk.runtest import runner as test_runner

from janis_assistant.management.configuration import JanisConfiguration


def process_args():
cmds = {"container": do_container, "run-test": do_runtest, "fromcwl": do_fromcwl}
cmds = {"container": do_container, "run-test": do_runtest, "fromcwl": do_fromcwl, "fromwdl": do_fromwdl}

parser = argparse.ArgumentParser(description="Execute a workflow")
subparsers = parser.add_subparsers(help="subcommand help", dest="command")
Expand All @@ -20,6 +21,7 @@ def process_args():
add_container_args(subparsers.add_parser("container"))
test_runner.add_runtest_args(subparsers.add_parser("run-test"))
add_fromcwl_args(subparsers.add_parser("fromcwl"))
add_fromwdl_args(subparsers.add_parser("fromwdl"))

args = parser.parse_args()
return cmds[args.command](args)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Version information is found in the __init__ file of `janis/`
DESCRIPTION = "Contains classes and helpers to build a workflow, and provide options to convert to CWL / WDL"

JANIS_CORE_VERSION = "v0.11.4"
JANIS_CORE_VERSION = "v0.11.5"
JANIS_ASSISTANT_VERSION = "v0.11.7"
JANIS_UNIX_VERSION = "v0.11.0"
JANIS_BIOINFORMATICS_VERSION = "v0.11.1"
Expand Down