Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions geoapps_utils/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from __future__ import annotations

import inspect
import json
import logging
import sys
from importlib import import_module
Expand Down Expand Up @@ -163,7 +164,7 @@ def copy_uijson_relatives_only(
with Workspace.create(workspace_path) as new_workspace:
ifile.copy_relatives(new_workspace)
temp_json = ifile.ui_json.copy()
temp_json["geoh5"] = workspace_path
temp_json["geoh5"] = new_workspace
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why new_workspace?
We don't want to store the path where the workspace is created?
Maybe it ends up doing the same thing?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By providing the current active workspace, we can skip re-opening the file again during the InputFile instantiation.

if monitoring_directory is not None:
temp_json["monitoring_directory"] = str(monitoring_directory)
new_input_file = InputFile(ui_json=temp_json)
Expand Down Expand Up @@ -194,7 +195,8 @@ def copy_uijson_and_workspace(

:return: Path to the new ui.json file.
"""
uijson_path = Path(uijson_path)
uijson_path = Path(uijson_path).resolve()
destination = Path(destination).resolve()
uijson_dict = load_ui_json_as_dict(uijson_path)

orig_geoh5 = Path(str(uijson_dict.get("geoh5")))
Expand All @@ -203,17 +205,16 @@ def copy_uijson_and_workspace(
)
copy(orig_geoh5, Path(str(workspace_path)))

with Workspace(workspace_path):
uijson_dict["geoh5"] = workspace_path
if monitoring_directory is not None:
uijson_dict["monitoring_directory"] = str(monitoring_directory)
new_input_file = InputFile(ui_json=uijson_dict)
uijson_dict["geoh5"] = str(workspace_path)
if monitoring_directory is not None:
uijson_dict["monitoring_directory"] = str(monitoring_directory)

uijson_path_name = new_input_file.write_ui_json(
path=str(destination), name=new_workspace_name or uijson_path.name
)
output_uijson = destination / (new_workspace_name or uijson_path.name)

return uijson_path_name
with open(output_uijson, "w", encoding="utf8") as out_file:
json.dump(uijson_dict, out_file, indent=4)

return output_uijson


def run_from_outgroup_name(
Expand Down
Loading