From 9407129a376dbfcec2e08c237892cf5512045520 Mon Sep 17 00:00:00 2001 From: Maurane GLAUDE Date: Mon, 7 Oct 2024 15:28:50 +0200 Subject: [PATCH] docs: add new configuration field --- antarest/core/config.py | 6 +++--- antarest/study/storage/auto_archive_service.py | 4 ++-- docs/install/1-CONFIG.md | 6 ++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/antarest/core/config.py b/antarest/core/config.py index e7e39d71b7..2ef63515a5 100644 --- a/antarest/core/config.py +++ b/antarest/core/config.py @@ -155,7 +155,7 @@ class StorageConfig: auto_archive_dry_run: bool = False auto_archive_sleeping_time: int = 3600 auto_archive_max_parallel: int = 5 - variant_snapshot_lifespan_days: int = 1 + snapshot_lifespan: int = 1 @classmethod def from_dict(cls, data: JSON) -> "StorageConfig": @@ -185,9 +185,9 @@ def from_dict(cls, data: JSON) -> "StorageConfig": auto_archive_dry_run=data.get("auto_archive_dry_run", defaults.auto_archive_dry_run), auto_archive_sleeping_time=data.get("auto_archive_sleeping_time", defaults.auto_archive_sleeping_time), auto_archive_max_parallel=data.get("auto_archive_max_parallel", defaults.auto_archive_max_parallel), - variant_snapshot_lifespan_days=data.get( + snapshot_lifespan=data.get( "snapshot_variant_lifespan_days", - defaults.variant_snapshot_lifespan_days, + defaults.snapshot_lifespan, ), ) diff --git a/antarest/study/storage/auto_archive_service.py b/antarest/study/storage/auto_archive_service.py index 23e5914d8c..9e714306b8 100644 --- a/antarest/study/storage/auto_archive_service.py +++ b/antarest/study/storage/auto_archive_service.py @@ -85,8 +85,8 @@ def _try_archive_studies(self) -> None: ) def _try_clear_snapshot(self) -> None: - # convert days in hours - hours_of_lifespan = self.config.storage.variant_snapshot_lifespan_days * 24 + # get retention hours from number of days + hours_of_lifespan = self.config.storage.snapshot_lifespan * 24 self.study_service.storage_service.variant_study_service.clear_all_snapshots( datetime.timedelta(hours=hours_of_lifespan) diff --git a/docs/install/1-CONFIG.md b/docs/install/1-CONFIG.md index 9ad48dad03..554f1a9728 100644 --- a/docs/install/1-CONFIG.md +++ b/docs/install/1-CONFIG.md @@ -304,6 +304,12 @@ default: - **Default value:** 5 - **Description:** Max auto archival tasks in parallel. +## **snapshot_lifespan** + +- **Type:** Integer +- **Default value:** 1 +- **Description:** Snapshots of variant not updated or accessed for **snapshot_lifespan** days will be cleared. + ## **watcher_lock** - **Type:** Boolean