Skip to content

Commit

Permalink
populate meta.ref_file
Browse files Browse the repository at this point in the history
  • Loading branch information
cshanahan1 committed Jul 30, 2022
1 parent 2ef49c9 commit 55653ee
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
0.7.2 (unreleased)
==================

general
-------

- Populate 'ref_file' section in meta after step is run. [#492]

assign_wcs
----------

Expand Down
22 changes: 22 additions & 0 deletions romancal/stpipe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
Roman Calibration Pipeline base class
"""
import logging
import os
import time

from stpipe import Step, Pipeline


import roman_datamodels as rdm
from roman_datamodels.datamodels import ImageModel
from ..lib.suffix import remove_suffix

if os.environ.get("CI") == "false":
from stpipe import crds_client


_LOG_FORMATTER = logging.Formatter(
"%(asctime)s.%(msecs)03dZ :: %(name)s :: %(levelname)s :: %(message)s",
Expand Down Expand Up @@ -49,10 +54,27 @@ def finalize_result(self, model, reference_files_used):
List of reference files used. The first element of each tuple
is the reftype code, the second element is the filename.
"""

if isinstance(model, ImageModel):
for log_record in self.log_records:
model.cal_logs.append(_LOG_FORMATTER.format(log_record))


if len(reference_files_used) > 0:
for ref_name, ref_file in reference_files_used:
if hasattr(model.meta.ref_file, ref_name):
setattr(model.meta.ref_file, ref_name, ref_file)
#getattr(model.meta.ref_file, ref_name).name = ref_file

# this will only run if 'parent' is none, which happens when an individual step is being run
# or if self is a RomanPipeline and not a RomanStep.

if os.environ.get("CI") == "false": # no CRDS connection, do not run
if (self.parent is None):
model.meta.ref_file.crds.sw_version = crds_client.get_svn_version()
model.meta.ref_file.crds.context_used = crds_client.get_context_used(model.crds_observatory)


def record_step_status(self, model, step_name, success=True):
"""
Record step completion status in the model's metadata.
Expand Down

0 comments on commit 55653ee

Please sign in to comment.