|
1 | 1 | import typing as ty |
2 | | -from copy import deepcopy, copy |
| 2 | +from copy import deepcopy |
3 | 3 | from enum import Enum |
4 | 4 | import attrs |
5 | 5 | from pydra.utils.typing import TypeParser, StateArray |
6 | 6 | from . import lazy |
7 | 7 | from pydra.engine.helpers import ( |
8 | | - ensure_list, |
9 | 8 | attrs_values, |
10 | 9 | is_lazy, |
11 | | - create_checksum, |
12 | 10 | ) |
13 | | -from pydra.utils.hash import hash_function |
14 | 11 | from pydra.engine import helpers_state as hlpst |
15 | | -from pydra.engine.state import State, StateIndex |
| 12 | +from pydra.engine.state import State |
16 | 13 |
|
17 | 14 | if ty.TYPE_CHECKING: |
18 | 15 | from .core import Workflow |
@@ -172,51 +169,6 @@ def combiner(self): |
172 | 169 | return () |
173 | 170 | return self._state.combiner |
174 | 171 |
|
175 | | - def _checksum_states(self, state_index: StateIndex = StateIndex()): |
176 | | - """ |
177 | | - Calculate a checksum for the specific state or all of the states of the task. |
178 | | - Replaces state-arrays in the inputs fields with a specific values for states. |
179 | | - Used to recreate names of the task directories, |
180 | | -
|
181 | | - Parameters |
182 | | - ---------- |
183 | | - state_index : |
184 | | - TODO |
185 | | -
|
186 | | - """ |
187 | | - # if is_workflow(self) and self._definition._graph_checksums is attr.NOTHING: |
188 | | - # self._definition._graph_checksums = { |
189 | | - # nd.name: nd.checksum for nd in self.graph_sorted |
190 | | - # } |
191 | | - from pydra.engine.specs import WorkflowDef |
192 | | - |
193 | | - if state_index: |
194 | | - inputs_copy = copy(self._definition) |
195 | | - for key, ind in self.state.inputs_ind[state_index].items(): |
196 | | - val = self._extract_input_el( |
197 | | - inputs=self._definition, inp_nm=key.split(".")[1], ind=ind |
198 | | - ) |
199 | | - setattr(inputs_copy, key.split(".")[1], val) |
200 | | - # setting files_hash again in case it was cleaned by setting specific element |
201 | | - # that might be important for outer splitter of input variable with big files |
202 | | - # the file can be changed with every single index even if there are only two files |
203 | | - input_hash = inputs_copy.hash |
204 | | - if isinstance(self._definition, WorkflowDef): |
205 | | - con_hash = hash_function(self._connections) |
206 | | - # TODO: hash list is not used |
207 | | - hash_list = [input_hash, con_hash] # noqa: F841 |
208 | | - checksum_ind = create_checksum( |
209 | | - self.__class__.__name__, self._checksum_wf(input_hash) |
210 | | - ) |
211 | | - else: |
212 | | - checksum_ind = create_checksum(self.__class__.__name__, input_hash) |
213 | | - return checksum_ind |
214 | | - else: |
215 | | - checksum_list = [] |
216 | | - for ind in range(len(self.state.inputs_ind)): |
217 | | - checksum_list.append(self._checksum_states(state_index=ind)) |
218 | | - return checksum_list |
219 | | - |
220 | 172 | def _check_if_outputs_have_been_used(self, msg): |
221 | 173 | used = [] |
222 | 174 | if self._lzout: |
@@ -287,24 +239,6 @@ def _get_upstream_states(self) -> dict[str, tuple["State", list[str]]]: |
287 | 239 | upstream_states[node.name][1].append(inpt_name) |
288 | 240 | return upstream_states |
289 | 241 |
|
290 | | - def _extract_input_el(self, inputs, inp_nm, ind): |
291 | | - """ |
292 | | - Extracting element of the inputs taking into account |
293 | | - container dimension of the specific element that can be set in self.state.cont_dim. |
294 | | - If input name is not in cont_dim, it is assumed that the input values has |
295 | | - a container dimension of 1, so only the most outer dim will be used for splitting. |
296 | | - If |
297 | | - """ |
298 | | - if f"{self.name}.{inp_nm}" in self.state.cont_dim: |
299 | | - return list( |
300 | | - hlpst.flatten( |
301 | | - ensure_list(getattr(inputs, inp_nm)), |
302 | | - max_depth=self.state.cont_dim[f"{self.name}.{inp_nm}"], |
303 | | - ) |
304 | | - )[ind] |
305 | | - else: |
306 | | - return getattr(inputs, inp_nm)[ind] |
307 | | - |
308 | 242 | # else: |
309 | 243 | # # todo it never gets here |
310 | 244 | # breakpoint() |
|
0 commit comments