From d3d37c468d8776f7f975ae4bf9f7a43834b2b28e Mon Sep 17 00:00:00 2001 From: Brett Graham Date: Mon, 4 Dec 2023 09:22:43 -0500 Subject: [PATCH] remove extra asdf validation during DataModel.clone (#230) Co-authored-by: Howard Bushouse --- CHANGES.rst | 2 ++ src/stdatamodels/model_base.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index a708381d..9f4bfe49 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -22,6 +22,8 @@ Other - Add mrsptcorr ref_file to core.schema [#228] +- Avoid unnecessary validation during ``DataModel.clone`` [#230] + - Replace uses of ``utcnow`` (deprecated in python 3.12) [#231] - Updated JWST MIRI imager photom model to include time-dependent correction diff --git a/src/stdatamodels/model_base.py b/src/stdatamodels/model_base.py index 4effdba8..7215a177 100644 --- a/src/stdatamodels/model_base.py +++ b/src/stdatamodels/model_base.py @@ -406,7 +406,10 @@ def close(self): def clone(target, source, deepcopy=False, memo=None): if deepcopy: instance = copy.deepcopy(source._instance, memo=memo) - target._asdf = AsdfFile(instance) + target._asdf = AsdfFile() + # assign to private '_tree' to avoid validation caused + # by either using AsdfFile(instance) or target._asdf = tree + target._asdf._tree = instance target._instance = instance else: target._asdf = source._asdf