Skip to content

Commit

Permalink
Migrate CWL parsing from cwltool to cwl-utils (#58)
Browse files Browse the repository at this point in the history
This commit replaces the `cwltool` parser with the faster
auto-generated parser included in `cwl-utils`. Starting from
this commit, `cwltool` is no more a StreamFlow requirement.
  • Loading branch information
GlassOfWhiskey authored Dec 10, 2024
1 parent d3cdd43 commit 9a3ab42
Show file tree
Hide file tree
Showing 23 changed files with 1,018 additions and 827 deletions.
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ antlr4-python3-runtime==4.13.2
asyncssh==2.18.0
bcrypt==4.2.1
cachetools==5.5.0
cwltool==3.1.20240708091337
cwl-utils==0.35
cwl-utils==0.36
importlib-metadata==8.5.0
Jinja2==3.1.4
jsonschema==4.23.0
Expand Down
22 changes: 9 additions & 13 deletions streamflow/cwl/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
import os
from pathlib import PurePosixPath

import cwltool.context
import cwltool.load_tool
import cwltool.loghandler
import cwltool.main
import cwltool.utils
import cwl_utils.parser
import cwl_utils.parser.utils

from streamflow.config.config import WorkflowConfig
from streamflow.core.context import StreamFlowContext
from streamflow.cwl.requirement.docker.translator import CWLDockerTranslatorConfig
from streamflow.cwl.translator import CWLTranslator
from streamflow.cwl.utils import load_cwl_inputs, load_cwl_workflow
from streamflow.log_handler import logger
from streamflow.workflow.executor import StreamFlowExecutor

Expand Down Expand Up @@ -60,14 +56,14 @@ async def main(
):
# Parse input arguments
cwl_args = _parse_args(workflow_config, context)
# Configure log level
if args.quiet:
# noinspection PyProtectedMember
cwltool.loghandler._logger.setLevel(logging.WARNING)
# Load CWL workflow definition
cwl_definition, loading_context = load_cwl_workflow(cwl_args[0])
cwl_definition = cwl_utils.parser.load_document_by_uri(cwl_args[0])
if len(cwl_args) == 2:
cwl_inputs = load_cwl_inputs(loading_context, cwl_definition, cwl_args[1])
cwl_inputs = cwl_utils.parser.utils.load_inputfile_by_uri(
version=cwl_definition.cwlVersion,
path=cwl_args[1],
loadingOptions=cwl_definition.loadingOptions,
)
else:
cwl_inputs = {}
# Transpile CWL workflow to the StreamFlow representation
Expand All @@ -79,8 +75,8 @@ async def main(
output_directory=args.outdir,
cwl_definition=cwl_definition,
cwl_inputs=cwl_inputs,
cwl_inputs_path=cwl_args[1] if len(cwl_args) == 2 else None,
workflow_config=workflow_config,
loading_context=loading_context,
)
if logger.isEnabledFor(logging.INFO):
logger.info("Building workflow execution plan")
Expand Down
Loading

0 comments on commit 9a3ab42

Please sign in to comment.