Commit 61126f5e authored by Yannick DAYER's avatar Yannick DAYER
Browse files

Load delayed_attribute when copying to non-delayed

parent 1636471a
Pipeline #50748 passed with stage
in 7 minutes and 47 seconds
......@@ -15,15 +15,20 @@ SAMPLE_DATA_ATTRS = ("data", "samples")
def _copy_attributes(sample, parent, kwargs):
"""Copies attributes from a dictionary to self."""
if parent is not None:
if getattr(parent, "_delayed_attributes", None) is not None:
if (
isinstance(sample, DelayedSample)
and getattr(parent, "_delayed_attributes", None) is not None
):
setattr(sample, "_delayed_attributes", parent._delayed_attributes)
for key in parent.__dict__:
if key.startswith("_") or key in SAMPLE_DATA_ATTRS:
continue
# Prevent the assignment of delayed attributes when copying
if getattr(
parent, "_delayed_attributes", None
) is not None and key in getattr(parent, "_delayed_attributes"):
# Prevent the assignment of delayed attributes when copying to DelayedSample
if (
isinstance(sample, DelayedSample)
and getattr(parent, "_delayed_attributes", None) is not None
and key in getattr(parent, "_delayed_attributes")
):
setattr(sample, key, None)
continue
setattr(sample, key, getattr(parent, key))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment