load_experiments(
storage,
exp_info_list,
df_loader_factory,
image_loader_factory,
local_exp_cache=None,
)
Load the experiments from the cloud storage and
stores them in the experiment manager. Additionally, they are saved in the local cache
Source code in niceml/dashboard/remotettrainutils.py
| def load_experiments(
storage,
exp_info_list: List[ExperimentInfo],
df_loader_factory: DfLoaderFactory,
image_loader_factory: ImageLoaderFactory,
local_exp_cache: Optional[ExperimentCache] = None,
):
"""Load the experiments from the cloud storage and
stores them in the experiment manager. Additionally, they are saved in the local cache
"""
experiments: List[ExperimentData]
dir_info_list: List[str] = []
load_exp_info_list: List[ExperimentInfo] = []
# pylint: disable = unused-argument
@st.cache_data()
def _check_and_load_cache(
*args,
) -> List[ExperimentData]:
experiments_list = []
for cur_exp_info in exp_info_list:
if local_exp_cache is not None and not local_exp_cache.should_reload(
cur_exp_info
):
initialized_df_loader: DfLoader = df_loader_factory.create_df_loader(
storage, cur_exp_info.exp_filepath
)
initialized_image_loader: ImageLoader = (
image_loader_factory.create_image_loader(
storage, cur_exp_info.exp_filepath
)
)
exp_data = local_exp_cache.load_experiment(
cur_exp_info.short_id,
df_loader=initialized_df_loader,
image_loader=initialized_image_loader,
)
experiments_list.append(exp_data)
else:
dir_info_list.append(cur_exp_info.exp_filepath)
load_exp_info_list.append(cur_exp_info)
return experiments_list
exp_cache_count = local_exp_cache.get_exp_count_in_cache()
experiments = _check_and_load_cache(exp_info_list, exp_cache_count)
if len(load_exp_info_list) > 0:
load_exp_count = len(load_exp_info_list)
prog_bar = st.progress(0)
status_text = st.empty()
status_text.text(f"Cached 0/{load_exp_count} experiments")
for idx, dir_info in enumerate(dir_info_list):
df_loader = df_loader_factory.create_df_loader(storage, dir_info)
image_loader = image_loader_factory.create_image_loader(storage, dir_info)
experiment = try_remote_exp_data_factory(
dir_info, storage, df_loader=df_loader, image_loader=image_loader
)
if experiment is not None:
experiments.append(experiment)
if local_exp_cache is not None:
local_exp_cache.save_experiment(experiment)
prog_bar.progress(idx / load_exp_count)
status_text.text(f"Cached {idx}/{load_exp_count} experiments")
status_text.text(f"Cached {load_exp_count}/{load_exp_count} experiments")
prog_bar.progress(1.0)
st.success("Done")
return experiments
|