|
7 | 7 |
|
8 | 8 |
|
9 | 9 | import enum
|
10 |
| -import copy |
11 | 10 |
|
12 | 11 | from pydantic import Field, field_validator
|
13 | 12 |
|
14 | 13 | from order.types import (
|
15 |
| - Union, List, Dict, NonEmptyStrictStr, PositiveStrictInt, Lazy, ClassVar, GeneratorType, Any, |
| 14 | + Union, List, Dict, NonEmptyStrictStr, PositiveStrictInt, Lazy, ClassVar, GeneratorType, |
16 | 15 | )
|
17 |
| -from order.util import has_attr, validated |
| 16 | +from order.util import validated |
18 | 17 | from order.models.base import Model
|
19 | 18 | from order.models.unique import UniqueObjectBase, UniqueObject, LazyUniqueObject, UniqueObjectIndex
|
20 |
| -# from order.models.mixins import CopyMixin |
21 | 19 |
|
22 | 20 |
|
23 | 21 | class DatasetIndex(UniqueObjectIndex):
|
@@ -83,19 +81,6 @@ def validate_gen_order(cls, gen_order: str) -> str:
|
83 | 81 | except KeyError:
|
84 | 82 | raise ValueError(f"unknown gen_order '{gen_order}'")
|
85 | 83 |
|
86 |
| - def __copy__(self) -> "DatasetVariation": |
87 |
| - inst = super().__copy__() |
88 |
| - |
89 |
| - # shallow copy of keys |
90 |
| - with self._unfreeze_field("keys"): |
91 |
| - inst.keys = copy.copy(inst.keys) |
92 |
| - |
93 |
| - # shallow copy of the lfns if not materialized yet |
94 |
| - if isinstance(inst.lazy_lfns, list): |
95 |
| - inst.lfns = copy.copy(inst.lfns) |
96 |
| - |
97 |
| - return inst |
98 |
| - |
99 | 84 |
|
100 | 85 | class Dataset(UniqueObject):
|
101 | 86 |
|
@@ -127,42 +112,6 @@ def campaign(self, campaign: "Campaign" | None) -> "Campaign":
|
127 | 112 |
|
128 | 113 | return campaign
|
129 | 114 |
|
130 |
| - def __copy__(self) -> "Dataset": |
131 |
| - copied = super().__copy__() |
132 |
| - |
133 |
| - # shallow copy the variations dict |
134 |
| - with copied._unfreeze_field("variations"): |
135 |
| - copied.variations = copy.copy(copied.variations) |
136 |
| - |
137 |
| - # drop the campaign reference |
138 |
| - copied.campaign = None |
139 |
| - |
140 |
| - # setup objects if not triggered by model_copy |
141 |
| - if not self._copy_triggered_by_model: |
142 |
| - copied._setup_objects() |
143 |
| - |
144 |
| - return copied |
145 |
| - |
146 |
| - def __deepcopy__(self, memo: dict[int, Any] | None = None) -> Dataset: |
147 |
| - copied = super().__deepcopy__(memo=memo) |
148 |
| - |
149 |
| - # setup objects if not triggered by model_copy |
150 |
| - if not self._copy_triggered_by_model: |
151 |
| - copied._setup_objects() |
152 |
| - |
153 |
| - return copied |
154 |
| - |
155 |
| - def model_copy(self, *args, **kwargs) -> "Dataset": |
156 |
| - copied = super().model_copy(*args, **kwargs) |
157 |
| - |
158 |
| - # since campaign is not a proper field, a duplicate of the copied instance is added to the |
159 |
| - # campaign's dataset index, so replace it |
160 |
| - if has_attr(getattr(copied, "campaign", None), "datasets"): |
161 |
| - copied.campaign._setup_datasets() |
162 |
| - copied.campaign.datasets.add(copied, overwrite=True) |
163 |
| - |
164 |
| - return copied |
165 |
| - |
166 | 115 | def __getitem__(self, name: str) -> DatasetVariation:
|
167 | 116 | return self.get_info(name)
|
168 | 117 |
|
|
0 commit comments