示例#1
0
    def fetch_protocol(
        self, protocol_id: Union[str, int], location: "BaseWorker", copy: bool = False
    ) -> "Plan":  # noqa: F821
        """Fetch a copy of a the protocol with the given `protocol_id` from the worker registry.
        This method is executed for local execution.
        Args:
            protocol_id: A string indicating the protocol id.
        Returns:
            A protocol if a protocol with the given `protocol_id` exists. Returns None otherwise.
        """
        message = PlanCommandMessage("fetch_protocol", (protocol_id, copy))
        protocol = self.send_msg(message, location=location)

        return protocol
示例#2
0
    def fetch_plan(
        self, plan_id: Union[str, int], location: "BaseWorker", copy: bool = False
    ) -> "Plan":  # noqa: F821
        """Fetchs a copy of a the plan with the given `plan_id` from the worker registry.

        This method is executed for local execution.

        Args:
            plan_id: A string indicating the plan id.

        Returns:
            A plan if a plan with the given `plan_id` exists. Returns None otherwise.
        """
        message = PlanCommandMessage("fetch_plan", (plan_id, copy))
        plan = self.send_msg(message, location=location)

        plan.procedure.update_worker_ids(location.id, self.id)

        return plan
示例#3
0
    def fetch_plan(self,
                   plan_id: Union[str, int],
                   location: "BaseWorker",
                   copy: bool = False) -> "Plan":  # noqa: F821
        """Fetchs a copy of a the plan with the given `plan_id` from the worker registry.

        This method is executed for local execution.

        Args:
            plan_id: A string indicating the plan id.

        Returns:
            A plan if a plan with the given `plan_id` exists. Returns None otherwise.
        """
        message = PlanCommandMessage("fetch_plan", (plan_id, copy))
        plan = self.send_msg(message, location=location)

        plan.replace_worker_ids(location.id, self.id)

        if plan.state_ids:
            state_ids = []
            for state_id in plan.state_ids:
                if copy:
                    state_ptr = PointerTensor(
                        location=location,
                        id_at_location=state_id,
                        owner=self,
                        garbage_collect_data=False,
                    )
                    state_elem = state_ptr.copy().get()
                else:
                    state_elem = self.request_obj(state_id, location)
                self.register_obj(state_elem)
                state_ids.append(state_elem.id)
            plan.replace_ids(plan.state_ids, state_ids)
            plan.state_ids = state_ids

        return plan