Skip to content

Commit

Permalink
docs: add new configuration field.
Browse files Browse the repository at this point in the history
  • Loading branch information
maugde committed Oct 7, 2024
1 parent 49dcc65 commit 2ad217f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions antarest/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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,
),
)

Expand Down
4 changes: 2 additions & 2 deletions antarest/study/storage/auto_archive_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions docs/install/1-CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2ad217f

Please sign in to comment.