Skip to content

Commit a454593

Browse files
Liang YuGitHub Enterprise
authored andcommitted
Remove runconfig.yaml.log (#828)
* yamlargparse tweaks and updates removed runconfig.yaml.log generated before yaml is read for log path fixed reading of nonsensical file in persistence add more details to docstrings in parser arguments * fixed logging bug force restart when no log path found in runconfig yaml updated where persistence restart arg added documentation and whitespace cleanup
1 parent 75bd0fc commit a454593

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

python/packages/pybind_nisar/workflows/insar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def run(cfg: dict, out_paths: dict, run_steps: dict):
6868
insar_runcfg = InsarRunConfig(args)
6969

7070
# determine what steps if any need to be rerun
71-
persist = Persistence(args.restart)
71+
persist = Persistence(insar_runcfg.args.restart)
7272

7373
# run InSAR workflow
7474
if persist.run:

python/packages/pybind_nisar/workflows/runconfig.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ def load_geocode_yaml_to_dict(self):
8686
self.cfg = self.cfg['runconfig']['groups']
8787
self.user = self.user['runconfig']['groups']
8888

89-
# update logging destination
89+
# attempt updating logging destination only if:
90+
# CLI arg for log is True AND valid path provided in yaml
91+
# otherwise indicate restart
9092
if self.args.log_file and 'logging' in self.cfg:
9193
log_path = self.cfg['logging']['path']
9294
helpers.check_log_dir_writable(log_path)
@@ -95,7 +97,10 @@ def load_geocode_yaml_to_dict(self):
9597
write_mode = self.cfg['logging']['write_mode']
9698
else:
9799
write_mode = 'a'
100+
journal.debug.journal.device = "journal.file"
98101
journal.debug.journal.device.log = open(log_path, write_mode)
102+
else:
103+
self.args.restart = True
99104

100105
# remove default frequency(s) if not chosen by user
101106
default_freqs = self.cfg['processing']['input_subset']['list_of_frequencies']
@@ -231,7 +236,7 @@ def prep_cubes_geocode_cfg(self):
231236

232237
# check for user provided EPSG and grab geocode group EPSG if not provided
233238

234-
if self.cfg['processing']['radar_grid_cubes']['outputEPSG'] is None:
239+
if self.cfg['processing']['radar_grid_cubes']['outputEPSG'] is None:
235240
cubes_epsg = geocode_dict['outputEPSG']
236241
else:
237242
cubes_epsg = self.cfg['processing']['radar_grid_cubes']['outputEPSG']
@@ -258,7 +263,7 @@ def prep_cubes_geocode_cfg(self):
258263
frequency_ref = 'A'
259264
frequency_group = None
260265
cubes_geogrid = geogrid.create(
261-
self.cfg, frequency_group = frequency_group,
266+
self.cfg, frequency_group = frequency_group,
262267
frequency = frequency_ref,
263268
geocode_dict = radar_grid_cubes_dict,
264269
default_spacing_x = default_cube_geogrid_spacing_x,

python/packages/pybind_nisar/workflows/yaml_argparse.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def __init__(self, resample_type = False):
4646
self.parser.add_argument('run_config_path', type=str, nargs='?',
4747
default=None, help='Path to run config file')
4848
self.parser.add_argument('--no-log-file', dest='log_file', action='store_false',
49-
default=True, help='Disable logging to file. Log to file on by default.')
49+
default=True, help='Disable logging to file. Log to file on/True by default. If off/False, log file in runconfig yaml will not be read nor altered, log messasges will be sent to stdout, and all submodules will run i.e. no persistence checking.')
5050
self.parser.add_argument('--restart', action='store_true', default=False,
51-
help='Restart the InSAR workflow from the beginning and ignore the previous run. False by default.')
51+
help='Restart the InSAR workflow from the beginning and, if applicable, ignore the persistence state of previous run. Off/False by default.')
5252
if resample_type:
5353
self.parser.add_argument('--resample-type', dest='resample_type', default='coarse',
5454
help='Type of offsets (coregistered slc) to use in resample_slc (crossmul).\n'
@@ -62,6 +62,10 @@ def parse(self):
6262
'''
6363
self.args = self.parser.parse_args()
6464
self.check_run_config_path()
65+
# Force restart if no log file provided
66+
# Otherwise persistence will attempt reading nonexistent file
67+
if not self.args.log_file:
68+
self.args.restart = True
6569
return self.args
6670

6771
def check_run_config_path(self):
@@ -76,13 +80,6 @@ def check_run_config_path(self):
7680
error_channel.log(err_str)
7781
raise FileNotFoundError(err_str)
7882

79-
if self.args.log_file:
80-
helpers.check_log_dir_writable(self.args.run_config_path)
81-
82-
# make a journal device that is attached to a file
83-
journal.debug.journal.device = "journal.file"
84-
journal.debug.journal.device.log = open(self.args.run_config_path + ".log", 'a')
85-
8683

8784
# only used for unit tests
8885
if __name__ == "__main__":

0 commit comments

Comments
 (0)