settings.py 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. import os
  17. from grpc._cython import cygrpc
  18. from fate_arch.computing import ComputingEngine
  19. from fate_arch.common import engine_utils
  20. from fate_arch.common.conf_utils import get_base_config, decrypt_database_config
  21. from fate_flow.utils.base_utils import get_fate_flow_directory
  22. from fate_flow.utils.log_utils import LoggerFactory, getLogger
  23. # Server
  24. API_VERSION = "v1"
  25. FATE_FLOW_SERVICE_NAME = "fateflow"
  26. SERVER_MODULE = "fate_flow_server.py"
  27. CASBIN_TABLE_NAME = "fate_casbin"
  28. TEMP_DIRECTORY = os.path.join(get_fate_flow_directory(), "temp")
  29. FATE_FLOW_CONF_PATH = os.path.join(get_fate_flow_directory(), "conf")
  30. FATE_FLOW_JOB_DEFAULT_CONFIG_PATH = os.path.join(FATE_FLOW_CONF_PATH, "job_default_config.yaml")
  31. FATE_FLOW_DEFAULT_COMPONENT_REGISTRY_PATH = os.path.join(FATE_FLOW_CONF_PATH, "component_registry.json")
  32. TEMPLATE_INFO_PATH = os.path.join(FATE_FLOW_CONF_PATH, "template_info.yaml")
  33. FATE_VERSION_DEPENDENCIES_PATH = os.path.join(get_fate_flow_directory(), "version_dependencies")
  34. CASBIN_MODEL_CONF = os.path.join(FATE_FLOW_CONF_PATH, "casbin_model.conf")
  35. INCOMPATIBLE_VERSION_CONF = os.path.join(FATE_FLOW_CONF_PATH, "incompatible_version.yaml")
  36. SUBPROCESS_STD_LOG_NAME = "std.log"
  37. GRPC_SERVER_MAX_WORKERS = None
  38. GRPC_OPTIONS = [
  39. (cygrpc.ChannelArgKey.max_send_message_length, -1),
  40. (cygrpc.ChannelArgKey.max_receive_message_length, -1),
  41. ]
  42. ERROR_REPORT = True
  43. ERROR_REPORT_WITH_PATH = False
  44. MAX_TIMESTAMP_INTERVAL = 60
  45. SESSION_VALID_PERIOD = 7 * 24 * 60 * 60 * 1000
  46. REQUEST_TRY_TIMES = 3
  47. REQUEST_WAIT_SEC = 2
  48. REQUEST_MAX_WAIT_SEC = 300
  49. USE_REGISTRY = get_base_config("use_registry")
  50. # distribution
  51. DEPENDENT_DISTRIBUTION = get_base_config("dependent_distribution", False)
  52. FATE_FLOW_UPDATE_CHECK = False
  53. HOST = get_base_config(FATE_FLOW_SERVICE_NAME, {}).get("host", "127.0.0.1")
  54. HTTP_PORT = get_base_config(FATE_FLOW_SERVICE_NAME, {}).get("http_port")
  55. GRPC_PORT = get_base_config(FATE_FLOW_SERVICE_NAME, {}).get("grpc_port")
  56. NGINX_HOST = get_base_config(FATE_FLOW_SERVICE_NAME, {}).get("nginx", {}).get("host") or HOST
  57. NGINX_HTTP_PORT = get_base_config(FATE_FLOW_SERVICE_NAME, {}).get("nginx", {}).get("http_port") or HTTP_PORT
  58. NGINX_GRPC_PORT = get_base_config(FATE_FLOW_SERVICE_NAME, {}).get("nginx", {}).get("grpc_port") or GRPC_PORT
  59. RANDOM_INSTANCE_ID = get_base_config(FATE_FLOW_SERVICE_NAME, {}).get("random_instance_id", False)
  60. PROXY = get_base_config(FATE_FLOW_SERVICE_NAME, {}).get("proxy")
  61. PROXY_PROTOCOL = get_base_config(FATE_FLOW_SERVICE_NAME, {}).get("protocol")
  62. ENGINES = engine_utils.get_engines()
  63. IS_STANDALONE = engine_utils.is_standalone()
  64. DATABASE = decrypt_database_config()
  65. ZOOKEEPER = get_base_config("zookeeper", {})
  66. # Registry
  67. ZOOKEEPER_REGISTRY = {
  68. # server
  69. 'flow-server': "/FATE-COMPONENTS/fate-flow",
  70. # model service
  71. 'fateflow': "/FATE-SERVICES/flow/online/transfer/providers",
  72. 'servings': "/FATE-SERVICES/serving/online/publishLoad/providers",
  73. }
  74. # Engine
  75. IGNORE_RESOURCE_COMPUTING_ENGINE = {
  76. ComputingEngine.LINKIS_SPARK
  77. }
  78. IGNORE_RESOURCE_ROLES = {"arbiter"}
  79. SUPPORT_IGNORE_RESOURCE_ENGINES = {
  80. ComputingEngine.EGGROLL, ComputingEngine.STANDALONE
  81. }
  82. # linkis spark config
  83. LINKIS_EXECUTE_ENTRANCE = "/api/rest_j/v1/entrance/execute"
  84. LINKIS_KILL_ENTRANCE = "/api/rest_j/v1/entrance/execID/kill"
  85. LINKIS_QUERT_STATUS = "/api/rest_j/v1/entrance/execID/status"
  86. LINKIS_SUBMIT_PARAMS = {
  87. "configuration": {
  88. "startup": {
  89. "spark.python.version": "/data/anaconda3/bin/python",
  90. "archives": "hdfs:///apps-data/fate/python.zip#python,hdfs:///apps-data/fate/fate_guest.zip#fate_guest",
  91. "spark.executorEnv.PYTHONPATH": "./fate_guest/python:$PYTHONPATH",
  92. "wds.linkis.rm.yarnqueue": "dws",
  93. "spark.pyspark.python": "python/bin/python"
  94. }
  95. }
  96. }
  97. LINKIS_RUNTYPE = "py"
  98. LINKIS_LABELS = {"tenant": "fate"}
  99. # Endpoint
  100. FATE_FLOW_MODEL_TRANSFER_ENDPOINT = "/v1/model/transfer"
  101. FATE_MANAGER_GET_NODE_INFO_ENDPOINT = "/fate-manager/api/site/secretinfo"
  102. FATE_MANAGER_NODE_CHECK_ENDPOINT = "/fate-manager/api/site/checksite"
  103. FATE_BOARD_DASHBOARD_ENDPOINT = "/index.html#/dashboard?job_id={}&role={}&party_id={}"
  104. # Logger
  105. LoggerFactory.set_directory(os.path.join(get_fate_flow_directory(), "logs", "fate_flow"))
  106. # {CRITICAL: 50, FATAL:50, ERROR:40, WARNING:30, WARN:30, INFO:20, DEBUG:10, NOTSET:0}
  107. LoggerFactory.LEVEL = 10
  108. stat_logger = getLogger("fate_flow_stat")
  109. detect_logger = getLogger("fate_flow_detect")
  110. access_logger = getLogger("fate_flow_access")
  111. database_logger = getLogger("fate_flow_database")
  112. # Switch
  113. # upload
  114. UPLOAD_DATA_FROM_CLIENT = True
  115. # authentication
  116. AUTHENTICATION_CONF = get_base_config("authentication", {})
  117. PARTY_ID = get_base_config("party_id", "")
  118. # client
  119. CLIENT_AUTHENTICATION = AUTHENTICATION_CONF.get("client", {}).get("switch", False)
  120. HTTP_APP_KEY = AUTHENTICATION_CONF.get("client", {}).get("http_app_key")
  121. HTTP_SECRET_KEY = AUTHENTICATION_CONF.get("client", {}).get("http_secret_key")
  122. # site
  123. SITE_AUTHENTICATION = AUTHENTICATION_CONF.get("site", {}).get("switch", False)
  124. # permission
  125. PERMISSION_CONF = get_base_config("permission", {})
  126. PERMISSION_SWITCH = PERMISSION_CONF.get("switch")
  127. COMPONENT_PERMISSION = PERMISSION_CONF.get("component")
  128. DATASET_PERMISSION = PERMISSION_CONF.get("dataset")
  129. HOOK_MODULE = get_base_config("hook_module")
  130. HOOK_SERVER_NAME = get_base_config("hook_server_name")
  131. ENABLE_MODEL_STORE = get_base_config('enable_model_store', False)