浏览代码

Revert "修改用正则替换日期"

This reverts commit 2cfa8971251ed115323072be9e1d2f8446220b13.
xueyiming 1 天之前
父节点
当前提交
94163a1051
共有 1 个文件被更改,包括 11 次插入5 次删除
  1. 11 5
      ad/pai_flow_operator.py

+ 11 - 5
ad/pai_flow_operator.py

@@ -17,7 +17,6 @@ from alibabacloud_paiflow20210202.client import Client as PAIFlow20210202Client
 from datetime import datetime, timedelta
 from odps import ODPS
 from ad_monitor_util import _monitor
-import re
 
 target_names = {
     '样本shuffle',
@@ -154,10 +153,17 @@ def get_train_data_list(date_begin):
 def update_data_date_range(old_str, date_begin='20250320'):
     date_list = get_train_data_list(date_begin)
     train_list = ["'" + item + "'" for item in date_list]
-    result = f"in ({','.join(train_list)})"
-    pattern = r"in\s*\(\s*'[^']+'\s*(?:,\s*'[^']+'\s*)*\)"
-    new_value = re.sub(pattern, result, old_str, flags=re.IGNORECASE)
-    return new_value
+    result = ','.join(train_list)
+    start_index = old_str.find('where dt in (')
+    if start_index != -1:
+        equal_sign_index = start_index + len('where dt in (')
+        # 找到下一个双引号的位置
+        next_quote_index = old_str.find(')', equal_sign_index)
+        if next_quote_index != -1:
+            # 进行替换
+            new_value = old_str[:equal_sign_index] + result + old_str[next_quote_index:]
+            return new_value
+    return None
 
 
 def compare_timestamp_with_today_start(time_str):