Skip to content

Commit d5d6e39

Browse files
committed
feat: allow passing inline json
1 parent 41c46ea commit d5d6e39

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/sasctl/pzmm/import_model.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,21 @@ def get_model_properties(
2222
model_files: Union[str, Path, None] = None,
2323
):
2424
if type(model_files) is dict:
25-
model = model_files["ModelProperties.json"]
26-
input_var = model_files["inputVar.json"]
27-
output_var = model_files["outputVar.json"]
25+
try:
26+
model = json.loads(model_files["ModelProperties.json"])
27+
except json.JSONDecodeError:
28+
model = model_files["ModelProperties.json"]
29+
30+
try:
31+
input_var = json.loads(model_files["inputVar.json"])
32+
except json.JSONDecodeError:
33+
input_var = model_files["inputVar.json"]
34+
35+
try:
36+
output_var = json.loads(model_files["outputVar.json"])
37+
except json.JSONDecodeError:
38+
output_var = model_files["outputVar.json"]
39+
2840
else:
2941
with open(Path(model_files) / "ModelProperties.json") as f:
3042
model = json.load(f)
@@ -319,9 +331,7 @@ def import_model(
319331
if isinstance(model_files, dict):
320332
zip_io_file = zm.zip_files(model_files, model_prefix, is_viya4=False)
321333
else:
322-
zip_io_file = zm.zip_files(
323-
Path(model_files), model_prefix, is_viya4=False
324-
)
334+
zip_io_file = zm.zip_files(Path(model_files), model_prefix, is_viya4=False)
325335
if cls.notebook_output:
326336
print(f"All model files were zipped to {Path(model_files)}.")
327337

0 commit comments

Comments
 (0)