From 5be004b125d898a63e702c01020a8747df80cf7b Mon Sep 17 00:00:00 2001 From: Anke Koke Date: Mon, 5 Feb 2024 14:35:41 +0100 Subject: [PATCH] fix: query experiments based on storage handler name not mutable id --- niceml/dashboard/dashboard.py | 4 ++-- niceml/dashboard/remotettrainutils.py | 8 +++++--- niceml/experiments/experimentinfo.py | 2 +- niceml/experiments/experimentmanager.py | 8 ++++---- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/niceml/dashboard/dashboard.py b/niceml/dashboard/dashboard.py index 8737fd0d..a2cef52f 100644 --- a/niceml/dashboard/dashboard.py +++ b/niceml/dashboard/dashboard.py @@ -37,8 +37,8 @@ def run_dashboard(conf_instances): exp_cache = conf_instances.get("exp_cache", None) st.sidebar.title("Filter Experiments") - exp_manager = exp_manager_factory(id(storage)) - exp_list: List[ExperimentInfo] = query_experiments(storage) + exp_manager = exp_manager_factory(handler_name) + exp_list: List[ExperimentInfo] = query_experiments(storage, handler_name) exps_to_load = select_to_load_exps(exp_list, exp_manager) experiments = load_experiments( storage, diff --git a/niceml/dashboard/remotettrainutils.py b/niceml/dashboard/remotettrainutils.py index f53ef78f..09779bcf 100644 --- a/niceml/dashboard/remotettrainutils.py +++ b/niceml/dashboard/remotettrainutils.py @@ -22,7 +22,9 @@ def exp_manager_factory(*args): # pylint: disable=unused-argument return ExperimentManager([]) -def query_experiments(storage: StorageInterface) -> List[ExperimentInfo]: +def query_experiments( + storage: StorageInterface, storage_identifier: str +) -> List[ExperimentInfo]: """Query the experiments from the cloud storage""" @st.cache_data(ttl=3600) @@ -30,7 +32,7 @@ def _local_query_exps(*args): # pylint: disable=unused-argument exp_info_list: List[ExperimentInfo] = storage.list_experiments() return exp_info_list - return _local_query_exps(id(storage)) + return _local_query_exps(storage_identifier) def select_to_load_exps( @@ -40,7 +42,7 @@ def select_to_load_exps( That means which are not in the experiment manager""" experiments_to_load = [] for exp_info in exp_info_list: - if exp_manager.is_exp_modified(exp_info.short_id, exp_info.last_modified): + if exp_manager.is_exp_modified(exp_info): experiments_to_load.append(exp_info) return experiments_to_load diff --git a/niceml/experiments/experimentinfo.py b/niceml/experiments/experimentinfo.py index de85314d..a7c1bf1b 100644 --- a/niceml/experiments/experimentinfo.py +++ b/niceml/experiments/experimentinfo.py @@ -51,7 +51,7 @@ def as_save_dict(self) -> dict: LAST_MODIFIED_KEY: self.last_modified, } - def is_modified(self, other) -> bool: + def is_modified(self, other: "ExperimentInfo") -> bool: """Checks if the other experiment info is modified""" return self.last_modified != other.last_modified diff --git a/niceml/experiments/experimentmanager.py b/niceml/experiments/experimentmanager.py index 85686834..2e99f381 100644 --- a/niceml/experiments/experimentmanager.py +++ b/niceml/experiments/experimentmanager.py @@ -100,12 +100,12 @@ def get_metrics(self, experiments: Optional[List[str]] = None) -> List[str]: return sorted(list(metric_set)) - def is_exp_modified(self, exp_id: str, new_time_str: str) -> bool: + def is_exp_modified(self, exp_info: ExperimentInfo) -> bool: """Checks if the experiment has been modified""" - if exp_id not in self.exp_dict: + if exp_info.short_id not in self.exp_dict: return True - exp = self.get_exp_by_id(exp_id) - return exp.exp_info.is_modified(new_time_str) + exp = self.get_exp_by_id(exp_info.short_id) + return exp.exp_info.is_modified(exp_info) def get_datasets(self) -> List[str]: """Returns a list of all datasets used in the experiments"""