Skip to content

Commit

Permalink
style: rename variable 'snapshot_lifespan' to 'snapshot_retention_days'
Browse files Browse the repository at this point in the history
  • Loading branch information
maugde committed Oct 7, 2024
1 parent 9407129 commit 277216e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 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
snapshot_lifespan: int = 1
snapshot_retention_days: 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),
snapshot_lifespan=data.get(
snapshot_retention_days=data.get(
"snapshot_variant_lifespan_days",
defaults.snapshot_lifespan,
defaults.snapshot_retention_days,
),
)

Expand Down
5 changes: 1 addition & 4 deletions antarest/study/storage/auto_archive_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,8 @@ def _try_archive_studies(self) -> None:
)

def _try_clear_snapshot(self) -> None:
# 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)
datetime.timedelta(days=self.config.storage.snapshot_retention_days)
)

def _loop(self) -> None:
Expand Down
4 changes: 2 additions & 2 deletions docs/install/1-CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,11 @@ default:
- **Default value:** 5
- **Description:** Max auto archival tasks in parallel.

## **snapshot_lifespan**
## **snapshot_retention_days**

- **Type:** Integer
- **Default value:** 1
- **Description:** Snapshots of variant not updated or accessed for **snapshot_lifespan** days will be cleared.
- **Description:** Snapshots of variant not updated or accessed for **snapshot_retention_days** days will be cleared.

## **watcher_lock**

Expand Down

0 comments on commit 277216e

Please sign in to comment.