Пример #1
0
    def practice_cancel(self, impulse: CancelSkillBuildJobImpulse,
                        config: Union[Callable[[CanceledSkillBuildJobImpulseReq], None], None] = None) -> Observable[
        CanceledSkillBuildJobImpulseRes]:
        if config is not None:
            practice_req: Callable[[PracticeReq], None] = lambda p: p.cancel(impulse, config)
            mutation_req: Callable[[MutationReq], None] = lambda m: m.practice(practice_req)
            mutation_res: Callable[[MutationRes], CanceledSkillBuildJobImpulseRes] = lambda ms: ms.practice.cancel
            obs = rx.from_callable(lambda: self.client.mutation(GaiaRequest.mutation(mutation_req)), self._scheduler)
            return mapM(obs, mutation_res)
        else:
            def job_cfg(b: SkillBuildJobReq):
                b.reference()
                b.name()
                b.tag()
                b.skill_ref()
                b.tenant_id()
                b.created()

            def r_cfg(x: CanceledSkillBuildJobImpulseReq):
                x.id()
                x.data(job_cfg)

            practice_req: Callable[[PracticeReq], None] = lambda p: p.cancel(impulse, r_cfg)
            mutation_req: Callable[[MutationReq], None] = lambda m: m.practice(practice_req)
            mutation_res: Callable[[MutationRes], CanceledSkillBuildJobImpulseRes] = lambda ms: ms.practice.cancel
            obs = rx.from_callable(lambda: self.client.mutation(GaiaRequest.mutation(mutation_req)), self._scheduler)
            return mapM(obs, mutation_res)
Пример #2
0
    def perceive(self, config: Callable[[PerceptionReq], None]) -> Observable[PerceptionRes]:
        mutation_req: Callable[[MutationReq], None] = lambda x: x.perceive(config)
        mutation_res: Callable[[MutationRes], PerceptionRes] = lambda x: x.perceive

        observable = rx.from_callable(lambda: self.client.mutation(GaiaRequest.mutation(mutation_req)),
                                      self._scheduler)
        return mapM(observable, mutation_res)
Пример #3
0
    def perceive_data(self, impulse: PerceiveDataImpulse) -> Observable[PerceivedImpulse]:
        perceive_data_req: Callable[[PerceptionReq], None] = lambda x: x.perceive_data(impulse, lambda e: e.id())
        mutation_req: Callable[[MutationReq], None] = lambda x: x.perceive(perceive_data_req)
        mutation_res: Callable[[MutationRes], PerceivedImpulse] = lambda x: x.perceive.perceive_data

        observable = rx.from_callable(lambda: self.client.mutation(GaiaRequest.mutation(mutation_req)),
                                      self._scheduler)
        return mapM(observable, mutation_res)
    def preserve(
        self, config: Callable[[PreservationReq],
                               None]) -> Observable[PreservationRes]:
        mutation_req: Callable[[MutationReq],
                               None] = lambda x: x.preserve(config)
        mutation_res: Callable[[MutationRes],
                               PreservationRes] = lambda x: x.preserve

        observable = rx.of(
            self.client.mutation(GaiaRequest.mutation(mutation_req)))
        return mapM(observable, mutation_res)
    def perceive_action(
            self,
            impulse: PerceiveActionImpulse) -> Observable[PerceivedImpulse]:
        perceive_action_req: Callable[
            [PerceptionReq],
            None] = lambda x: x.perceive_action(impulse, lambda e: e.id())
        mutation_req: Callable[
            [MutationReq], None] = lambda x: x.perceive(perceive_action_req)
        mutation_res: Callable[
            [MutationRes],
            PerceivedImpulse] = lambda x: x.perceive.perceive_action

        observable = rx.of(
            self.client.mutation(GaiaRequest.mutation(mutation_req)))
        return mapM(observable, mutation_res)