How to use the pydra.engine.helpers.load_result function in pydra

To help you get started, we’ve selected a few pydra examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nipype / pydra / pydra / engine / core.py View on Github external
result = load_result(checksum, self.cache_locations)
                        if result is None:
                            return None
                        results.append(result)
                    if return_inputs is True or return_inputs == "val":
                        return list(zip(self.state.states_val, results))
                    elif return_inputs == "ind":
                        return list(zip(self.state.states_ind, results))
                    else:
                        return results
            else:  # state_index is not None
                if self.state.combiner:
                    return self._combined_output(return_inputs=return_inputs)[
                        state_index
                    ]
                result = load_result(
                    self.checksum_states(state_index), self.cache_locations
                )
                if return_inputs is True or return_inputs == "val":
                    return (self.state.states_val[state_index], result)
                elif return_inputs == "ind":
                    return (self.state.states_ind[state_index], result)
                else:
                    return result
        else:
            if state_index is not None:
                raise ValueError("Task does not have a state")
            checksum = self.checksum
            result = load_result(checksum, self.cache_locations)
            if return_inputs is True or return_inputs == "val":
                inputs_val = {
                    f"{self.name}.{inp}": getattr(self.inputs, inp)
github nipype / pydra / pydra / engine / core.py View on Github external
state_index
                    ]
                result = load_result(
                    self.checksum_states(state_index), self.cache_locations
                )
                if return_inputs is True or return_inputs == "val":
                    return (self.state.states_val[state_index], result)
                elif return_inputs == "ind":
                    return (self.state.states_ind[state_index], result)
                else:
                    return result
        else:
            if state_index is not None:
                raise ValueError("Task does not have a state")
            checksum = self.checksum
            result = load_result(checksum, self.cache_locations)
            if return_inputs is True or return_inputs == "val":
                inputs_val = {
                    f"{self.name}.{inp}": getattr(self.inputs, inp)
                    for inp in self.input_names
                }
                return (inputs_val, result)
            elif return_inputs == "ind":
                inputs_ind = {f"{self.name}.{inp}": None for inp in self.input_names}
                return (inputs_ind, result)
            else:
                return result
github nipype / pydra / pydra / engine / core.py View on Github external
def _combined_output(self, return_inputs=False):
        combined_results = []
        for (gr, ind_l) in self.state.final_combined_ind_mapping.items():
            combined_results_gr = []
            for ind in ind_l:
                result = load_result(self.checksum_states(ind), self.cache_locations)
                if result is None:
                    return None
                if return_inputs is True or return_inputs == "val":
                    result = (self.state.states_val[ind], result)
                elif return_inputs == "ind":
                    result = (self.state.states_ind[ind], result)
                combined_results_gr.append(result)
            combined_results.append(combined_results_gr)
        if len(combined_results) == 1 and self.state.splitter_rpn_final == []:
            # in case it's full combiner, removing the nested structure
            return combined_results[0]
        else:
            return combined_results
github nipype / pydra / pydra / engine / core.py View on Github external
result = load_result(checksum, self.cache_locations)
                        if result is None:
                            return None
                        results.append(result)
                    if return_inputs is True or return_inputs == "val":
                        return list(zip(self.state.states_val, results))
                    elif return_inputs == "ind":
                        return list(zip(self.state.states_ind, results))
                    else:
                        return results
            else:  # state_index is not None
                if self.state.combiner:
                    return self._combined_output(return_inputs=return_inputs)[
                        state_index
                    ]
                result = load_result(
                    self.checksum_states(state_index), self.cache_locations
                )
                if return_inputs is True or return_inputs == "val":
                    return (self.state.states_val[state_index], result)
                elif return_inputs == "ind":
                    return (self.state.states_ind[state_index], result)
                else:
                    return result
        else:
            if state_index is not None:
                raise ValueError("Task does not have a state")
            checksum = self.checksum
            result = load_result(checksum, self.cache_locations)
            if result and result.errored:
                self._errored = True
            if return_inputs is True or return_inputs == "val":
github nipype / pydra / pydra / engine / core.py View on Github external
Returns
        -------
        result :

        """
        # TODO: check if result is available in load_result and
        # return a future if not
        if self.state:
            if state_index is None:
                # if state_index=None, collecting all results
                if self.state.combiner:
                    return self._combined_output(return_inputs=return_inputs)
                else:
                    results = []
                    for checksum in self.checksum_states():
                        result = load_result(checksum, self.cache_locations)
                        if result is None:
                            return None
                        results.append(result)
                    if return_inputs is True or return_inputs == "val":
                        return list(zip(self.state.states_val, results))
                    elif return_inputs == "ind":
                        return list(zip(self.state.states_ind, results))
                    else:
                        return results
            else:  # state_index is not None
                if self.state.combiner:
                    return self._combined_output(return_inputs=return_inputs)[
                        state_index
                    ]
                result = load_result(
                    self.checksum_states(state_index), self.cache_locations
github nipype / pydra / pydra / engine / core.py View on Github external
result :

        """
        # TODO: check if result is available in load_result and
        # return a future if not
        if self.errored:
            return Result(output=None, runtime=None, errored=True)
        if self.state:
            if state_index is None:
                # if state_index=None, collecting all results
                if self.state.combiner:
                    return self._combined_output(return_inputs=return_inputs)
                else:
                    results = []
                    for checksum in self.checksum_states():
                        result = load_result(checksum, self.cache_locations)
                        if result is None:
                            return None
                        results.append(result)
                    if return_inputs is True or return_inputs == "val":
                        return list(zip(self.state.states_val, results))
                    elif return_inputs == "ind":
                        return list(zip(self.state.states_ind, results))
                    else:
                        return results
            else:  # state_index is not None
                if self.state.combiner:
                    return self._combined_output(return_inputs=return_inputs)[
                        state_index
                    ]
                result = load_result(
                    self.checksum_states(state_index), self.cache_locations