Skip to content

Commit dac9ef0

Browse files
authored
Merge pull request #301 from umccr/bugfix/don-t-delete-output-dir
2 parents 3ceefb9 + b748ecb commit dac9ef0

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ dependencies = [
3131
"pandas >= 2.1.4, < 3",
3232
"pydot >= 1.4.2, < 2",
3333
"PyJWT >= 2.8.0, < 3",
34-
"PyJWT >= 2.8.0, < 3",
3534
"python_dateutil >= 2.8.2, < 3",
3635
"Requests >= 2.31.0, < 3",
3736
"ruamel.base >= 1.0.0, < 2",

scripts/create_typescript_interface_from_schema.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@
3838

3939

4040
# Helper functions
41-
def camel_case(s: str) -> str:
41+
def to_pascal_case(s: str) -> str:
4242
"""
4343
Convert "bclconvert_settings" to "BclconvertSettings"
4444
:param s:
4545
:return:
4646
"""
47-
s = re.sub(r"[_|-]+", " ", s).title().replace(" ", "")
47+
s = re.sub(r"[_-]+", " ", s).title().replace(" ", "")
4848
return ''.join(s)
4949

5050

@@ -141,9 +141,13 @@ def sanitise_schema_types(schema_json: Dict, schema_path: Path, schema_name: Uni
141141

142142
# Other local vars
143143
if schema_name is None:
144-
schema_name: str = camel_case(schema_path.stem.split("__", 1)[0])
144+
schema_name: str = to_pascal_case(schema_path.stem.split("__", 1)[0])
145145
sanitised_schema: Dict = {}
146146

147+
if schema_json.get("fields") is None:
148+
print("Warning - No fields found in schema")
149+
return sanitised_schemas, imported_interfaces, new_enum_classes
150+
147151
field: Dict
148152
for field in schema_json.get("fields"):
149153
# Get basics
@@ -207,11 +211,16 @@ def sanitise_schema_types(schema_json: Dict, schema_path: Path, schema_name: Uni
207211
# Collect symbols
208212
symbols = [
209213
Path(symbol).name
214+
if isinstance(symbol, str)
215+
else symbol
210216
for symbol in field_type.get("symbols")
211217
]
212218

213219
# Collect new field type name
214-
new_field_type = camel_case(Path(field_type.get("symbols")[0]).parent.name)
220+
if field_type.get("name") is not None:
221+
new_field_type = to_pascal_case(Path(field_type.get("name")).name)
222+
else:
223+
new_field_type = to_pascal_case(Path(field_type.get("symbols")[0]).parent.name)
215224

216225
field_type = new_field_type
217226

@@ -232,14 +241,14 @@ def sanitise_schema_types(schema_json: Dict, schema_path: Path, schema_name: Uni
232241
re_new_enum_classes: List
233242
re_sanitised_schemas, re_imported_interfaces, re_new_enum_classes = \
234243
sanitise_schema_types(field_type, schema_path,
235-
schema_name=camel_case(Path(field_type.get("name")).name))
244+
schema_name=to_pascal_case(Path(field_type.get("name")).name))
236245
sanitised_schemas.update(re_sanitised_schemas)
237246
imported_interfaces.update(re_imported_interfaces)
238247
new_enum_classes.extend(re_new_enum_classes)
239-
field_type = camel_case(Path(field_type.get("name")).name)
248+
field_type = to_pascal_case(Path(field_type.get("name")).name)
240249
else:
241250
# Add to list of interfaces to import
242-
new_interface_name = camel_case(Path(field_type.get("name")).name)
251+
new_interface_name = to_pascal_case(Path(field_type.get("name")).name)
243252
imported_interfaces[new_interface_name] = field_type.get("name")
244253
field_type = new_interface_name
245254

@@ -309,7 +318,7 @@ def write_interface_file(schema_dicts: Dict, imported_interfaces: Dict,
309318
for _enum in enum_classes:
310319
interface_h.write("export enum %s {\n" % _enum.get("name"))
311320
for index, symbol in enumerate(_enum.get("symbols")):
312-
interface_h.write("\t\"%s\" = \"%s\"" % (symbol, symbol))
321+
interface_h.write("\t\"%s\" = %s" % (symbol, json.dumps(symbol)))
313322
if not index == len(_enum.get("symbols")) - 1:
314323
# Add comma
315324
interface_h.write(",")

src/cwl_ica/utils/cwl_workflow_helper_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def zip_workflow(cwl_obj: CWLWorkflow, output_zip_path: Path):
238238
all_workflow_paths = collect_objects_by_print_deps(cwl_obj.cwl_file_path)
239239

240240
# Create a temporary directory
241-
output_tempdir_obj = TemporaryDirectory()
241+
output_tempdir_obj = TemporaryDirectory(delete=False)
242242
output_tempdir = Path(output_tempdir_obj.name) / output_zip_path.stem
243243

244244
# And we want to make sure it doesn't already exist

0 commit comments

Comments
 (0)