Skip to content

Remove DataModel.history #560

@braingram

Description

@braingram

It only has a few uses in wfs_combine (see spacetelescope/jwst#9744):

        new_model.history.append(f"Flip dithers = {self.flip_dithers}")
        new_model.history.append(f"WFS_COMBINE refine offset = {self.do_refine}")
        new_model.history.append(
            f"WFS_COMBINE X offset applied {str(self.off_x)} pixels "
            f"actual offset {str(round(self.flt_off_x, 2))} pixels"
        )
        new_model.history.append(
            f"WFS_COMBINE Y offset applied {str(self.off_y)} pixels "
            f"actual offset {str(round(self.flt_off_y, 2))} pixels"
        )

All of these may be more useful as log messages since the log messages are also recorded to FITS or ASDF file when an datamodel is saved and even better the log messages are shown to the terminal (the history appends are not).

"under the hood" DataModel.history modifies AsdfFile.tree["history"].

>> m.history.append("foo")
>> m._asdf.tree["history"]
{'entries': [{'description': 'foo',
   'time': datetime.datetime(2025, 8, 13, 14, 47, 58, tzinfo=datetime.timezone.utc)}]}

and there is already stable API in asdf for modifying the history via AsdfFile.add_history_entry:

>> m._asdf.add_history_entry("foo")  # where m is a new model 
{'entries': [{'description': 'foo',
   'time': datetime.datetime(2025, 8, 13, 14, 49, 21, tzinfo=datetime.timezone.utc)}]}

I propose that we:

  • update wfs_combine to use log messages
  • wrap AsdfFile.add_history_entry
  • deprecate DataModel.history (and mention that after removal Datamodel.history.entries will return the history entries via the standard ASDF-to-attribute mapping of all other metadata)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions