runtime_config.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #
  2. # Copyright 2019 The FATE Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. from fate_arch.common.versions import get_versions
  17. from fate_flow.entity.types import ProcessRole
  18. from fate_flow.entity import ComponentProvider
  19. from .reload_config_base import ReloadConfigBase
  20. class RuntimeConfig(ReloadConfigBase):
  21. DEBUG = None
  22. WORK_MODE = None
  23. COMPUTING_ENGINE = None
  24. FEDERATION_ENGINE = None
  25. FEDERATED_MODE = None
  26. JOB_QUEUE = None
  27. USE_LOCAL_DATABASE = False
  28. HTTP_PORT = None
  29. JOB_SERVER_HOST = None
  30. JOB_SERVER_VIP = None
  31. IS_SERVER = False
  32. PROCESS_ROLE = None
  33. ENV = dict()
  34. COMPONENT_PROVIDER: ComponentProvider = None
  35. SERVICE_DB = None
  36. LOAD_COMPONENT_REGISTRY = False
  37. LOAD_CONFIG_MANAGER = False
  38. @classmethod
  39. def init_config(cls, **kwargs):
  40. for k, v in kwargs.items():
  41. if hasattr(cls, k):
  42. setattr(cls, k, v)
  43. @classmethod
  44. def init_env(cls):
  45. cls.ENV.update(get_versions())
  46. @classmethod
  47. def load_component_registry(cls):
  48. cls.LOAD_COMPONENT_REGISTRY = True
  49. @classmethod
  50. def load_config_manager(cls):
  51. cls.LOAD_CONFIG_MANAGER = True
  52. @classmethod
  53. def get_env(cls, key):
  54. return cls.ENV.get(key, None)
  55. @classmethod
  56. def get_all_env(cls):
  57. return cls.ENV
  58. @classmethod
  59. def set_process_role(cls, process_role: ProcessRole):
  60. cls.PROCESS_ROLE = process_role
  61. @classmethod
  62. def set_component_provider(cls, component_provider: ComponentProvider):
  63. cls.COMPONENT_PROVIDER = component_provider
  64. @classmethod
  65. def set_service_db(cls, service_db):
  66. cls.SERVICE_DB = service_db