[run_selector] better handling of no snapshot
This commit is contained in:
+8
-5
@@ -96,9 +96,6 @@ class RunSelector:
|
|||||||
self.namelist = {}
|
self.namelist = {}
|
||||||
self.runs = self.get_runs(in_runs, filter_name, filter_nml, sort_run_by)
|
self.runs = self.get_runs(in_runs, filter_name, filter_nml, sort_run_by)
|
||||||
|
|
||||||
if len(self.runs) == 0:
|
|
||||||
raise ValueError("No runs found")
|
|
||||||
|
|
||||||
self.info = {}
|
self.info = {}
|
||||||
for run in self.runs:
|
for run in self.runs:
|
||||||
self.info[run] = {}
|
self.info[run] = {}
|
||||||
@@ -119,11 +116,17 @@ class RunSelector:
|
|||||||
time,
|
time,
|
||||||
)
|
)
|
||||||
|
|
||||||
for i, run in enumerate(self.runs):
|
i = 0
|
||||||
|
for run in self.runs.copy():
|
||||||
if len(self.nums[run]) == 0:
|
if len(self.nums[run]) == 0:
|
||||||
print(f"[WARNING] No snapshot found for run {run}")
|
print(f"[WARNING] No snapshot found for run {run}")
|
||||||
del self.runs[i]
|
del self.runs[i]
|
||||||
del self.nums[run]
|
del self.nums[run]
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
if len(self.runs) == 0:
|
||||||
|
raise ValueError("No runs found")
|
||||||
|
|
||||||
def select(
|
def select(
|
||||||
self,
|
self,
|
||||||
@@ -328,7 +331,7 @@ class RunSelector:
|
|||||||
if time_max is not None:
|
if time_max is not None:
|
||||||
nums = list(filter(lambda n: self.info[run][n]["time"] <= time_max, nums))
|
nums = list(filter(lambda n: self.info[run][n]["time"] <= time_max, nums))
|
||||||
|
|
||||||
if time is not None:
|
if time is not None and len(nums) > 0:
|
||||||
filtered_nums = []
|
filtered_nums = []
|
||||||
if not isinstance(time, list):
|
if not isinstance(time, list):
|
||||||
time = [time]
|
time = [time]
|
||||||
|
|||||||
Reference in New Issue
Block a user