Skip to content

Commit

Permalink
Improve CWL parsing performance
Browse files Browse the repository at this point in the history
This commit, combined with common-workflow-language/cwl-utils#355,
improves CWL parsing performance by removing useless propagation of the
`LoadingOptions` object when parsing child CWL documents.
  • Loading branch information
GlassOfWhiskey committed Feb 12, 2025
1 parent e86d21c commit 7d9fe03
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions streamflow/cwl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,13 @@ def process_embedded_tool(
):
run_command = cwl_element.run
inner_context = dict(context)
# If the `run` options contains an inline CWL object
if cwl_utils.parser.is_process(run_command):
# Add the CWL version, which is not present by default
run_command.cwlVersion = context["version"]
# Process `stdout` and `stderr` directives
cwl_utils.parser.utils.convert_stdstreams_to_files(run_command)
# Compute the prefix of the inner CWL element
if ":" in run_command.id.split("#")[-1]:
cwl_step_name = get_name(
name_prefix,
Expand All @@ -734,19 +738,23 @@ def process_embedded_tool(
run_command.id,
preserve_cwl_prefix=True,
)
# Otherwise, the `run` options contains an URI
else:
run_command = cwl_element.loadingOptions.fetcher.urljoin(
cwl_element.loadingOptions.fileuri, run_command
)
# Fetch and translare the target file
run_command = cwl_utils.parser.load_document_by_uri(
run_command, loadingOptions=cwl_element.loadingOptions
path=cwl_element.loadingOptions.fetcher.urljoin(
base_url=cwl_element.loadingOptions.fileuri, url=run_command
),
)
# Process `stdout` and `stderr` directives
cwl_utils.parser.utils.convert_stdstreams_to_files(run_command)
# Compute the prefix of the inner CWL element
inner_cwl_name_prefix = (
get_name(posixpath.sep, posixpath.sep, run_command.id)
if "#" in run_command.id
else posixpath.sep
)
# Set the inner CWL version, which may differ from the outer one
inner_context |= {"version": run_command.cwlVersion}
return run_command, inner_cwl_name_prefix, inner_context

Expand Down

0 comments on commit 7d9fe03

Please sign in to comment.