Skip to content

Commit

Permalink
Make resetting run boundaries more graceful / no-op in the case of mi…
Browse files Browse the repository at this point in the history
…ssing dataset bounds
  • Loading branch information
drake-nominal committed Nov 15, 2024
1 parent efc6632 commit 35830ab
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions nominal/core/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,17 @@ def reset_bounds(self) -> Self:
"""
datasets = self.list_datasets()

# Get the start and end bounds of all composing datasets
dataset_starts = [dataset.bounds.start for _, dataset in datasets if dataset.bounds]
dataset_ends = [dataset.bounds.end for _, dataset in datasets if dataset.bounds]

# If there are not yet any datasets with bounds in the run, there is nothing to reset
if not dataset_starts or not dataset_ends:
return self

return self.update(start=min(dataset_starts), end=max(dataset_ends))
# If there are no start or end bounds across all input datasets, don't update the
# respective bound of the Run by using None
new_start = min(dataset_starts) if dataset_starts else None
new_end = max(dataset_ends) if dataset_ends else None

# Update the run and return with updated metadata
return self.update(start=new_start, end=new_end)

@classmethod
def _from_conjure(cls, clients: _Clients, run: scout_run_api.Run) -> Self:
Expand Down

0 comments on commit 35830ab

Please sign in to comment.