Skip to content

Commit

Permalink
Move determination of model_spec to _setup_proc_and_logger, print cha…
Browse files Browse the repository at this point in the history
…ndra_models version in log, improve outputs in the command-line printout
  • Loading branch information
jzuhone committed Jul 17, 2023
1 parent 22bc901 commit 10bd3d6
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions acis_thermal_check/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,7 @@ def run(self, args, override_limits=None):

# First, do some initial setup and log important information.

if args.model_spec is None:
model_spec = get_xija_model_spec(self.name)[0]
else:
model_spec = args.model_spec

if not isinstance(model_spec, dict):
with open(model_spec) as f:
model_spec = json.load(f)

proc = self._setup_proc_and_logger(args, model_spec)
proc, model_spec = self._setup_proc_and_logger(args)

# Record the selected state builder in the class attributes
# If there is no "state_builder" command line argument assume
Expand Down Expand Up @@ -1404,7 +1395,7 @@ def write_index_rst(self, outdir, context):
with open(outfile, "w") as fout:
fout.write(template.render(**context))

def _setup_proc_and_logger(self, args, model_spec):
def _setup_proc_and_logger(self, args):
"""
This method does some initial setup and logs important
information.
Expand All @@ -1418,6 +1409,17 @@ def _setup_proc_and_logger(self, args, model_spec):
The path to the thermal model specification.
"""

Check failure on line 1410 in acis_thermal_check/main.py

View workflow job for this annotation

GitHub Actions / build

Ruff (D202)

acis_thermal_check/main.py:1399:9: D202 No blank lines allowed after function docstring (found 1)

if args.model_spec is None:
model_spec, cm_version = get_xija_model_spec(self.name)
ms_out = f"chandra_models v{cm_version}"
else:
model_spec = args.model_spec
cm_version = None
if not isinstance(model_spec, dict):
ms_out = str(Path(model_spec).resolve())
with open(model_spec) as f:
model_spec = json.load(f)

if not args.outdir.exists():
args.outdir.mkdir(parents=True)

Expand All @@ -1439,8 +1441,13 @@ def _setup_proc_and_logger(self, args, model_spec):
"# %s_check run at %s by %s"
% (self.name, proc["run_time"], proc["run_user"]),

Check failure on line 1442 in acis_thermal_check/main.py

View workflow job for this annotation

GitHub Actions / build

Ruff (UP031)

acis_thermal_check/main.py:1441:13: UP031 Use format specifiers instead of percent format
)
mylog.info("# acis_thermal_check version = %s" % version)
mylog.info("Command line options:\n%s\n" % pformat(args.__dict__))
mylog.info("# acis_thermal_check version = %s", version)
if cm_version is not None:
mylog.info("# chandra_models version = %s", cm_version)
args_out = args.__dict__.copy()
args_out["outdir"] = str(args.outdir.resolve())
args_out["model_spec"] = ms_out
mylog.info("Command line options:\n%s\n", pformat(args_out))

if args.backstop_file is None:
self.bsdir = None
Expand All @@ -1450,7 +1457,7 @@ def _setup_proc_and_logger(self, args, model_spec):
self.bsdir = bf
else:
self.bsdir = PurePath(bf).parent
return proc
return proc, model_spec

def _determine_times(self, run_start, is_weekly_load):
"""
Expand Down

0 comments on commit 10bd3d6

Please sign in to comment.