示例#1
0
 def get(self, request, *args, **kwargs):
     CliConfig.init_file(self.HEALTH_FILE)
     config = self.get_config()
     if config and config.should_check():
         config.version = pkg.VERSION
         key = conf.get(ORGANIZATION_KEY) or get_dummy_key()
         compatibility = get_compatibility(
             key=key,
             service=PolyaxonServices.PLATFORM,
             version=config.version,
             is_cli=False,
         )
         config.compatibility = compatibility.to_dict() if compatibility else None
         config.last_check = now()
         config.write(self.HEALTH_FILE)
     return Response(status=status.HTTP_200_OK)
示例#2
0
def patch_settings(
    set_auth: bool = True,
    set_client: bool = True,
    set_cli: bool = True,
    set_agent: bool = True,
    set_proxies: bool = True,
):
    settings.AUTH_CONFIG = None
    if set_auth:
        settings.AUTH_CONFIG = AccessTokenConfig()

    settings.CLIENT_CONFIG = None
    if set_client:
        settings.CLIENT_CONFIG = ClientConfig(host="1.2.3.4")

    settings.CLI_CONFIG = None
    if set_cli:
        settings.CLI_CONFIG = CliConfig()

    settings.AGENT_CONFIG = None
    if set_agent:
        settings.AGENT_CONFIG = AgentConfig()

    settings.PROXIES_CONFIG = None
    if set_proxies:
        settings.PROXIES_CONFIG = ProxiesConfig()

    settings.CLIENT_CONFIG.tracking_timeout = 0
示例#3
0
 def test_cli_config(self):
     config_dict = {
         "current_version": "0.0.1",
         "installation": {
             "key": "uuid",
             "version": "1.1.4-rc11",
             "dist": "foo"
         },
         "compatibility": {
             "cli": {
                 "min": "0.0.4",
                 "latest": "1.1.4"
             }
         },
         "log_handler": None,
     }
     config = CliConfig.from_dict(config_dict)
     config_to_dict = config.to_dict()
     config_to_dict.pop("last_check")
     assert config_to_dict == config_dict
     assert config.INTERVAL == 30 * 60
示例#4
0
 def get_config(self):
     try:
         return CliConfig.read(self.HEALTH_FILE, config_type=".json")
     except:  # noqa
         return
示例#5
0
文件: health.py 项目: zhaohb/polyaxon
 def get_config(self):
     try:
         return CliConfig.read(self.FILE, config_type=".json")
     except:
         return
示例#6
0
文件: health.py 项目: zhaohb/polyaxon
 def write_config(self, config: CliConfig):
     with open(self.FILE, "w") as config_file:
         config_file.write(config.to_dict(dump=True))
示例#7
0
文件: health.py 项目: zhaohb/polyaxon
 def init_config(self):
     if not os.path.exists(self.FILE):
         self.write_config(CliConfig())