Pārlūkot izejas kodu

Merge branch 'dev-xym-update-dnn-version' of algorithm/recommend-emr-dataprocess into feature/20250104-zt-update

fengzhoutian 1 dienu atpakaļ
vecāks
revīzija
dfb0302f26
1 mainītis faili ar 22 papildinājumiem un 0 dzēšanām
  1. 22 0
      ad/update_online_dnn_version.py

+ 22 - 0
ad/update_online_dnn_version.py

@@ -57,6 +57,23 @@ class EASClient:
             print(error.data.get("Recommend"))
             UtilClient.assert_as_string(error.message)
 
+    @staticmethod
+    def get_online_model_detail():
+        client = EASClient.create_client()
+        runtime = util_models.RuntimeOptions()
+        headers = {}
+        try:
+            # 复制代码运行请自行打印 API 的返回值
+            res =  client.describe_service_with_options('cn-hangzhou', SERVICE_NAME, headers, runtime)
+            return res.body.to_map()
+        except Exception as error:
+            # 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
+            # 错误 message
+            print(error.message)
+            # 诊断地址
+            print(error.data.get("Recommend"))
+            UtilClient.assert_as_string(error.message)
+
 
 def exist_oss_directory_path(directory_path):
     if not directory_path.endswith('/'):
@@ -120,6 +137,11 @@ def update_online_dnn_version(model_name: str, dt: str):
         print(json.dumps(model_path_config))
         online_model_update_res = EASClient.update_online_model_path(json.dumps(model_path_config))
         if online_model_update_res.status_code == 200:
+            time.sleep(60)
+            status = EASClient.get_online_model_detail()['Status']
+            while status != 'Running':
+                time.sleep(60)
+                status = EASClient.get_online_model_detail()['Status']
             cid_update_res = update_trained_cids_pointer(model_name, dt)
             if cid_update_res.status_code == 200:
                 print('模型更新成功,cid配置更新成功')