コード例 #1
0
 def __init__(self, action: str, allowed_actions: dict):
     assert action in allowed_actions, ("unsupported action of job", action)
     super().__init__(action, allowed_actions[action])
     suffix = action.replace('-', '_')
     self.define_arguments = getattr(self, "define_arguments_" + suffix,
                                     super().define_arguments)
     self.check_arguments = getattr(self, "check_arguments_" + suffix,
                                    super().check_arguments)
     self.do_action = getattr(self, "do_action_" + suffix, None)
     self.__job__ = Job()
     self.__clusters__ = ClusterList()
コード例 #2
0
ファイル: cli_factory.py プロジェクト: zjuter06060126/pai
    def __init__(self, action: str, allowed_actions: dict):
        assert action in allowed_actions, ("unsupported action of job", action)
        super().__init__(action, allowed_actions[action])
        suffix = action.replace('-', '_')
        for attr in ["define_arguments", "check_arguments", "do_action"]:
            if hasattr(self, f"{attr}_{suffix}"):
                setattr(self, attr, getattr(self, f"{attr}_{suffix}"))
            else:
                assert attr != "do_action", f"must specify a method named {attr}_{suffix} in {self.__class__.__name__}"

        self.__job__ = Job()
        self.__clusters__ = ClusterList()
        self.enable_svaing = dict(job=False, clusters=False)