Skip to content

Commit

Permalink
fix: query experiments based on storage handler name not mutable id
Browse files Browse the repository at this point in the history
  • Loading branch information
ankeko committed Feb 8, 2024
1 parent fbb72d4 commit 1e94add
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions niceml/dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions niceml/dashboard/remotettrainutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ 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)
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(
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion niceml/experiments/experimentinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions niceml/experiments/experimentmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 1e94add

Please sign in to comment.