File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -251,6 +251,15 @@ def test_from_str(self) -> None:
251
251
metric_data = MetricData ("mean_loss_squared" , 0.0 ),
252
252
),
253
253
),
254
+ (
255
+ "foo/bar/epoch_1_train_step_2_eval_step_3_eval_loss=6.486097566010406e+18" ,
256
+ CheckpointPath (
257
+ "foo/bar/" ,
258
+ epoch = 1 ,
259
+ step = {Phase .TRAIN : 2 , Phase .EVALUATE : 3 },
260
+ metric_data = MetricData ("eval_loss" , 6.486097566010406e18 ),
261
+ ),
262
+ ),
254
263
]
255
264
for path , expected_ckpt in valid_paths :
256
265
parsed_ckpt = CheckpointPath .from_str (path )
Original file line number Diff line number Diff line change @@ -80,12 +80,14 @@ class CheckpointPath:
80
80
- phase-aware and metric-aware- <dirpath>/epoch_<epoch>_train_step_<train_step>_eval_step_<eval_step>_<metric_name>=<metric_value>
81
81
"""
82
82
83
+ _FLOAT_REGEX : str = r"-?\d+\.?\d*(?:e[\+\-]\d+)?"
84
+
83
85
PHASE_NAIVE_REGEX : Pattern = re .compile (
84
- r "^(.+)epoch_(\d+)_step_(\d+)(?:_(\w+)=(-?\d+\.?\d* ))?\/?$"
86
+ rf "^(.+)epoch_(\d+)_step_(\d+)(?:_(\w+)=({ _FLOAT_REGEX } ))?\/?$"
85
87
)
86
88
87
89
PHASE_AWARE_REGEX : Pattern = re .compile (
88
- r "^(.+)epoch_(\d+)(?:_train_step_(\d+))?(?:_eval_step_(\d+))?(?:_predict_step_(\d+))?(?:_(\w+)=(-?\d+\.?\d* ))?\/?$"
90
+ rf "^(.+)epoch_(\d+)(?:_train_step_(\d+))?(?:_eval_step_(\d+))?(?:_predict_step_(\d+))?(?:_(\w+)=({ _FLOAT_REGEX } ))?\/?$"
89
91
)
90
92
91
93
def __init__ (
You can’t perform that action at this time.
0 commit comments