|
20 | 20 | from schema_salad.sourceline import cmap
|
21 | 21 |
|
22 | 22 | from .process import shortname, uniquename
|
| 23 | +from .context import LoadingContext |
| 24 | +from .load_tool import fetch_document, resolve_and_validate_document |
23 | 25 |
|
24 | 26 |
|
25 | 27 | def flatten_deps(d, files): # type: (Any, Set[str]) -> None
|
@@ -121,14 +123,37 @@ def import_embed(d, seen):
|
121 | 123 |
|
122 | 124 | def pack(
|
123 | 125 | document_loader: Loader,
|
124 |
| - processobj, # type: Union[Dict[str, Any], List[Dict[str, Any]]] |
| 126 | + startingobj, # type: Union[Dict[str, Any], List[Dict[str, Any]]] |
125 | 127 | uri, # type: str
|
126 | 128 | metadata, # type: Dict[str, str]
|
127 | 129 | rewrite_out=None, # type: Optional[Dict[str, str]]
|
128 | 130 | ): # type: (...) -> Dict[str, Any]
|
129 | 131 |
|
| 132 | + # The workflow document we have in memory right now may have been |
| 133 | + # updated to the internal CWL version. We need to reload the |
| 134 | + # document to go back to its original version. |
| 135 | + # |
| 136 | + # What's going on here is that the updater replaces the |
| 137 | + # documents/fragments in the index with updated ones, the |
| 138 | + # index is also used as a cache, so we need to go through the |
| 139 | + # loading process with an empty index and updating turned off |
| 140 | + # so we have the original un-updated documents. |
| 141 | + # |
130 | 142 | document_loader = SubLoader(document_loader)
|
131 |
| - document_loader.idx = {} |
| 143 | + loadingContext = LoadingContext() |
| 144 | + loadingContext.do_update = False |
| 145 | + loadingContext.loader = document_loader |
| 146 | + loadingContext.loader.idx = {} |
| 147 | + loadingContext.metadata = {} |
| 148 | + loadingContext, docobj, uri = fetch_document(uri, loadingContext) |
| 149 | + loadingContext, uri = resolve_and_validate_document( |
| 150 | + loadingContext, docobj, uri, preprocess_only=True |
| 151 | + ) |
| 152 | + if loadingContext.loader is None: |
| 153 | + raise Exception("loadingContext.loader cannot be none") |
| 154 | + processobj, metadata = loadingContext.loader.resolve_ref(uri) |
| 155 | + document_loader = loadingContext.loader |
| 156 | + |
132 | 157 | if isinstance(processobj, MutableMapping):
|
133 | 158 | document_loader.idx[processobj["id"]] = CommentedMap(processobj.items())
|
134 | 159 | elif isinstance(processobj, MutableSequence):
|
|
0 commit comments