Skip to content

Commit daef19a

Browse files
committed
Refactor parameter registry cache key retrieval
- Updated the `_param_registry_cache_key` function to safely access the configuration directory, ensuring it checks for the existence of `_config_dir` before attempting to retrieve the modification time of the engine parameters catalog. - Improved error handling by encapsulating the file modification time retrieval in a conditional check, enhancing robustness against potential OSError exceptions.
1 parent 34488dc commit daef19a

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

backend/routes/models.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,14 @@ def _param_registry_cache_key(store, engine: str) -> str:
224224
) else None
225225
version = (active or {}).get("version") or ""
226226
catalog_mtime = 0.0
227-
try:
228-
catalog_mtime = os.path.getmtime(
229-
os.path.join(store._config_dir, "engine_params_catalog.yaml")
230-
)
231-
except OSError:
232-
pass
227+
config_dir = getattr(store, "_config_dir", None)
228+
if config_dir:
229+
try:
230+
catalog_mtime = os.path.getmtime(
231+
os.path.join(config_dir, "engine_params_catalog.yaml")
232+
)
233+
except OSError:
234+
pass
233235
return f"{engine}:{version}:{catalog_mtime}"
234236

235237

0 commit comments

Comments
 (0)