|
9 | 9 | from pathlib import Path |
10 | 10 | from typing import List, MutableSequence, Optional, Set |
11 | 11 |
|
12 | | -from cwltool.context import LoadingContext, RuntimeContext |
13 | | -from cwltool.load_tool import ( |
14 | | - fetch_document, |
15 | | - resolve_and_validate_document, |
16 | | - resolve_tool_uri, |
17 | | -) |
18 | | -from cwltool.loghandler import _logger as _cwltoollogger |
19 | | -from cwltool.main import print_pack |
20 | | -from cwltool.process import use_standard_schema |
21 | 12 | from cwlupgrader import main as cwlupgrader |
22 | 13 | from ruamel import yaml |
23 | 14 | from schema_salad.sourceline import add_lc_filename |
24 | 15 |
|
| 16 | +from cwl_utils.loghandler import _logger as _cwlutilslogger |
| 17 | +from cwl_utils.pack import pack |
| 18 | + |
25 | 19 | _logger = logging.getLogger("cwl-normalizer") # pylint: disable=invalid-name |
26 | 20 | defaultStreamHandler = logging.StreamHandler() # pylint: disable=invalid-name |
27 | 21 | _logger.addHandler(defaultStreamHandler) |
28 | 22 | _logger.setLevel(logging.INFO) |
29 | | -_cwltoollogger.setLevel(100) |
| 23 | +_cwlutilslogger.setLevel(100) |
30 | 24 |
|
31 | 25 | from cwl_utils import cwl_v1_2_expression_refactor |
32 | 26 | from cwl_utils.parser.cwl_v1_2 import load_document_by_yaml, save |
@@ -127,29 +121,7 @@ def run(args: argparse.Namespace) -> int: |
127 | 121 | else: |
128 | 122 | with tempfile.TemporaryDirectory() as tmpdirname: |
129 | 123 | path = Path(tmpdirname) / Path(document).name |
130 | | - with open(path, "w") as handle: |
131 | | - yaml.main.round_trip_dump(result, handle) |
132 | | - # TODO replace the cwltool based packing with a parser_v1_2 based packer |
133 | | - runtimeContext = RuntimeContext() |
134 | | - loadingContext = LoadingContext() |
135 | | - use_standard_schema("v1.2") |
136 | | - # loadingContext.construct_tool_object = workflow.default_make_tool |
137 | | - # loadingContext.resolver = tool_resolver |
138 | | - loadingContext.do_update = False |
139 | | - uri, tool_file_uri = resolve_tool_uri( |
140 | | - str(path), |
141 | | - resolver=loadingContext.resolver, |
142 | | - fetcher_constructor=loadingContext.fetcher_constructor, |
143 | | - ) |
144 | | - loadingContext, workflowobj, uri = fetch_document(uri, loadingContext) |
145 | | - loadingContext, uri = resolve_and_validate_document( |
146 | | - loadingContext, |
147 | | - workflowobj, |
148 | | - uri, |
149 | | - preprocess_only=True, |
150 | | - skip_schemas=True, |
151 | | - ) |
152 | | - packed = print_pack(loadingContext, uri) |
| 124 | + packed = pack(str(path)) |
153 | 125 | output = Path(args.dir) / Path(document).name |
154 | 126 | with open(output, "w", encoding="utf-8") as output_filehandle: |
155 | 127 | output_filehandle.write(packed) |
|
0 commit comments