|
32 | 32 | ResolveType,
|
33 | 33 | json_dumps,
|
34 | 34 | )
|
| 35 | +from schema_salad.fetcher import Fetcher |
35 | 36 |
|
36 | 37 | from ruamel.yaml.comments import CommentedMap, CommentedSeq
|
37 | 38 |
|
@@ -318,8 +319,11 @@ def fast_parser(
|
318 | 319 | fileuri: Optional[str],
|
319 | 320 | uri: str,
|
320 | 321 | loadingContext: LoadingContext,
|
| 322 | + fetcher: Fetcher, |
321 | 323 | ) -> Tuple[Union[CommentedMap, CommentedSeq], CommentedMap]:
|
322 |
| - lopt = cwl_v1_2.LoadingOptions(idx=loadingContext.codegen_idx, fileuri=fileuri) |
| 324 | + lopt = cwl_v1_2.LoadingOptions( |
| 325 | + idx=loadingContext.codegen_idx, fileuri=fileuri, fetcher=fetcher |
| 326 | + ) |
323 | 327 |
|
324 | 328 | if uri not in loadingContext.codegen_idx:
|
325 | 329 | cwl_v1_2.load_document_with_metadata(
|
@@ -359,18 +363,26 @@ def fast_parser(
|
359 | 363 | # Need to match the document loader's index with the fast parser index
|
360 | 364 | # Get the base URI (no fragments) for documents that use $graph
|
361 | 365 | nofrag = urllib.parse.urldefrag(uri)[0]
|
362 |
| - objects, loadopt = loadingContext.codegen_idx[nofrag] |
363 |
| - fileobj = cmap( |
364 |
| - cast( |
365 |
| - Union[int, float, str, Dict[str, Any], List[Any], None], |
366 |
| - cwl_v1_2.save(objects, relative_uris=False), |
| 366 | + |
| 367 | + flag = "fastparser-idx-from:" + nofrag |
| 368 | + if not loadingContext.loader.idx.get(flag): |
| 369 | + objects, loadopt = loadingContext.codegen_idx[nofrag] |
| 370 | + fileobj = cmap( |
| 371 | + cast( |
| 372 | + Union[int, float, str, Dict[str, Any], List[Any], None], |
| 373 | + cwl_v1_2.save(objects, relative_uris=False), |
| 374 | + ) |
367 | 375 | )
|
368 |
| - ) |
369 |
| - visit_class( |
370 |
| - fileobj, |
371 |
| - ("CommandLineTool", "Workflow", "ExpressionTool"), |
372 |
| - partial(update_index, loadingContext.loader), |
373 |
| - ) |
| 376 | + visit_class( |
| 377 | + fileobj, |
| 378 | + ("CommandLineTool", "Workflow", "ExpressionTool"), |
| 379 | + partial(update_index, loadingContext.loader), |
| 380 | + ) |
| 381 | + loadingContext.loader.idx[flag] = flag |
| 382 | + for u in lopt.imports: |
| 383 | + loadingContext.loader.idx["import:" + u] = "import:" + u |
| 384 | + for u in lopt.includes: |
| 385 | + loadingContext.loader.idx["include:" + u] = "include:" + u |
374 | 386 |
|
375 | 387 | return cast(
|
376 | 388 | Union[CommentedMap, CommentedSeq],
|
@@ -519,7 +531,9 @@ def resolve_and_validate_document(
|
519 | 531 | #
|
520 | 532 | processobj, metadata = document_loader.resolve_ref(uri)
|
521 | 533 | elif loadingContext.fast_parser:
|
522 |
| - processobj, metadata = fast_parser(workflowobj, fileuri, uri, loadingContext) |
| 534 | + processobj, metadata = fast_parser( |
| 535 | + workflowobj, fileuri, uri, loadingContext, document_loader.fetcher |
| 536 | + ) |
523 | 537 | else:
|
524 | 538 | document_loader.resolve_all(workflowobj, fileuri)
|
525 | 539 | processobj, metadata = document_loader.resolve_ref(uri)
|
@@ -594,7 +608,9 @@ def make_tool(
|
594 | 608 | and isinstance(uri, str)
|
595 | 609 | and not loadingContext.skip_resolve_all
|
596 | 610 | ):
|
597 |
| - resolveduri, metadata = fast_parser(None, None, uri, loadingContext) |
| 611 | + resolveduri, metadata = fast_parser( |
| 612 | + None, None, uri, loadingContext, loadingContext.loader.fetcher |
| 613 | + ) |
598 | 614 | else:
|
599 | 615 | resolveduri, metadata = loadingContext.loader.resolve_ref(uri)
|
600 | 616 |
|
|
0 commit comments