From bbc13ebe07d682020ec9bc3eace3da020275fde1 Mon Sep 17 00:00:00 2001 From: danleifeng <52735331+danleifeng@users.noreply.github.com> Date: Tue, 9 Jan 2024 14:17:15 +0800 Subject: [PATCH] [cherry-pick]fix fleetutil get_online_pass_interval bug3 (#60620) * fix fleetutil get_online_pass_interval bug3; test=develop * fix fleetutil get_online_pass_interval bug3; test=develop * fix fleetutil get_online_pass_interval bug3; test=develop --- .../incubate/distributed/fleet/fleet_util.py | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/python/paddle/incubate/distributed/fleet/fleet_util.py b/python/paddle/incubate/distributed/fleet/fleet_util.py index e0450948e6171..9af91e4f5b148 100644 --- a/python/paddle/incubate/distributed/fleet/fleet_util.py +++ b/python/paddle/incubate/distributed/fleet/fleet_util.py @@ -18,6 +18,7 @@ import logging import math import os +import re import sys import time @@ -1317,25 +1318,12 @@ def get_online_pass_interval( ... is_data_hourly_placed=False) """ - assert ( - "|" not in days - and ";" not in days - and "\\" not in days - and "/" not in days - and "(" not in days - and ")" not in days - and "&" not in days - ), r"days should not contain [|,;,\,/,(,),&]" + pattern = r'^\d+|{[0-9]+}|{[0-9]+\.\.[0-9]+}$' + if not re.fullmatch(pattern, str(days)): + raise Exception("days format is not right") days = os.popen("echo -n " + days).read().split(" ") - assert ( - "|" not in hours - and ";" not in hours - and "\\" not in hours - and "/" not in hours - and "(" not in hours - and ")" not in hours - and "&" not in hours - ), r"hours should not contain [|,;,\,/,(,),&]" + if not re.fullmatch(pattern, str(hours)): + raise Exception("hours format is not right") hours = os.popen("echo -n " + hours).read().split(" ") split_interval = int(split_interval) split_per_pass = int(split_per_pass)