1111from __future__ import annotations
1212
1313import inspect
14+ import json
1415import logging
1516import sys
1617from importlib import import_module
@@ -163,7 +164,7 @@ def copy_uijson_relatives_only(
163164 with Workspace .create (workspace_path ) as new_workspace :
164165 ifile .copy_relatives (new_workspace )
165166 temp_json = ifile .ui_json .copy ()
166- temp_json ["geoh5" ] = workspace_path
167+ temp_json ["geoh5" ] = new_workspace
167168 if monitoring_directory is not None :
168169 temp_json ["monitoring_directory" ] = str (monitoring_directory )
169170 new_input_file = InputFile (ui_json = temp_json )
@@ -194,7 +195,8 @@ def copy_uijson_and_workspace(
194195
195196 :return: Path to the new ui.json file.
196197 """
197- uijson_path = Path (uijson_path )
198+ uijson_path = Path (uijson_path ).resolve ()
199+ destination = Path (destination ).resolve ()
198200 uijson_dict = load_ui_json_as_dict (uijson_path )
199201
200202 orig_geoh5 = Path (str (uijson_dict .get ("geoh5" )))
@@ -203,17 +205,16 @@ def copy_uijson_and_workspace(
203205 )
204206 copy (orig_geoh5 , Path (str (workspace_path )))
205207
206- with Workspace (workspace_path ):
207- uijson_dict ["geoh5" ] = workspace_path
208- if monitoring_directory is not None :
209- uijson_dict ["monitoring_directory" ] = str (monitoring_directory )
210- new_input_file = InputFile (ui_json = uijson_dict )
208+ uijson_dict ["geoh5" ] = str (workspace_path )
209+ if monitoring_directory is not None :
210+ uijson_dict ["monitoring_directory" ] = str (monitoring_directory )
211211
212- uijson_path_name = new_input_file .write_ui_json (
213- path = str (destination ), name = new_workspace_name or uijson_path .name
214- )
212+ output_uijson = destination / (new_workspace_name or uijson_path .name )
215213
216- return uijson_path_name
214+ with open (output_uijson , "w" , encoding = "utf8" ) as out_file :
215+ json .dump (uijson_dict , out_file , indent = 4 )
216+
217+ return output_uijson
217218
218219
219220def run_from_outgroup_name (
0 commit comments