Пример #1
0
    def should_resume(self, data_container: DataContainer, context: ExecutionContext) -> bool:
        context = context.push(self)
        expanded_data_container = ExpandedDataContainer.create_from(data_container)

        if isinstance(self.wrapped, ResumableStepMixin) and \
                self.wrapped.should_resume(expanded_data_container, context):
            return True

        return False
Пример #2
0
    def _create_expanded_data_container(
            self, data_container: DataContainer) -> ExpandedDataContainer:
        """
        Create expanded data container.

        :param data_container: data container to expand
        :type data_container: DataContainer
        :return: expanded data container
        :rtype: ExpandedDataContainer
        """
        current_ids = self.hash(data_container)
        data_container.set_current_ids(current_ids)

        expanded_data_container = ExpandedDataContainer.create_from(
            data_container)

        return expanded_data_container
Пример #3
0
    def resume(self, data_container: DataContainer, context: ExecutionContext):
        context = context.push(self)
        if not isinstance(self.wrapped, ResumableStepMixin):
            raise Exception('cannot resume steps that don\' inherit from ResumableStepMixin')

        old_current_ids = data_container.current_ids

        data_container = self.wrapped.resume(data_container, context)

        expanded_data_container = ExpandedDataContainer(
            data_inputs=data_container.data_inputs,
            expected_outputs=data_container.expected_outputs,
            current_ids=data_container.current_ids,
            summary_id=data_container.summary_id,
            old_current_ids=old_current_ids
        )

        data_container = self._did_process(expanded_data_container, context)

        return data_container
Пример #4
0
 def _will_process(self, data_container, context):
     data_container, context = BaseStep._will_process(self, data_container, context)
     return ExpandedDataContainer.create_from(data_container), context