Skip to content

Commit

Permalink
v2.11.1 (#1198)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent-laporte-pro authored Jan 11, 2023
2 parents a74f51a + cf587d0 commit 16a71c1
Show file tree
Hide file tree
Showing 41 changed files with 769 additions and 244 deletions.
2 changes: 1 addition & 1 deletion antarest/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.11.0"
__version__ = "2.11.1"

from pathlib import Path

Expand Down
6 changes: 6 additions & 0 deletions antarest/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class StorageConfig:
matrix_gc_dry_run: bool = False
auto_archive_threshold_days: int = 60
auto_archive_dry_run: bool = False
auto_archive_sleeping_time: int = 3600
auto_archive_max_parallel: int = 5

@staticmethod
def from_dict(data: JSON) -> "StorageConfig":
Expand All @@ -151,6 +153,10 @@ def from_dict(data: JSON) -> "StorageConfig":
"auto_archive_threshold_days", 60
),
auto_archive_dry_run=data.get("auto_archive_dry_run", False),
auto_archive_sleeping_time=data.get(
"auto_archive_sleeping_time", 3600
),
auto_archive_max_parallel=data.get("auto_archive_max_parallel", 5),
)


Expand Down
5 changes: 5 additions & 0 deletions antarest/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ def __init__(self, message: str) -> None:
super().__init__(HTTPStatus.NOT_FOUND, message)


class LayerNotFound(HTTPException):
def __init__(self) -> None:
super().__init__(HTTPStatus.NOT_FOUND)


class StudyOutputNotFoundError(Exception):
pass

Expand Down
8 changes: 6 additions & 2 deletions antarest/core/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,13 @@ def remove_carriage_return(value: str) -> str:

def new_redis_instance(config: RedisConfig) -> redis.Redis: # type: ignore
redis_client = redis.Redis(
host=config.host, port=config.port, password=config.password, db=0
host=config.host,
port=config.port,
password=config.password,
db=0,
retry_on_error=[redis.ConnectionError, redis.TimeoutError], # type: ignore
)
return redis_client
return redis_client # type: ignore


class StopWatch:
Expand Down
6 changes: 1 addition & 5 deletions antarest/launcher/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -655,11 +655,7 @@ def _download_fallback_output(
def export_task(notifier: TaskUpdateNotifier) -> TaskResult:
try:
#
shutil.make_archive(
base_name=os.path.splitext(export_path)[0],
format="zip",
root_dir=output_path,
)
zip_dir(output_path, export_path)
self.file_transfer_manager.set_ready(export_id)
return TaskResult(success=True, message="")
except Exception as e:
Expand Down
10 changes: 3 additions & 7 deletions antarest/matrixstore/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
ITaskService,
)
from antarest.core.utils.fastapi_sqlalchemy import db
from antarest.core.utils.utils import StopWatch, assert_this
from antarest.core.utils.utils import StopWatch, assert_this, zip_dir
from antarest.login.service import LoginService
from antarest.matrixstore.exceptions import MatrixDataSetNotFound
from antarest.matrixstore.model import (
Expand Down Expand Up @@ -376,17 +376,13 @@ def create_matrix_files(
if not mtx:
continue
write_tsv_matrix(mtx, tmpdir)
filename = shutil.make_archive(
base_name=os.path.splitext(export_path)[0],
format="zip",
root_dir=tmpdir,
)
zip_dir(Path(tmpdir), export_path)
stopwatch.log_elapsed(
lambda x: logger.info(
f"Matrix dataset exported (zipped mode) in {x}s"
)
)
return filename if filename else ""
return str(export_path)

def download_dataset(
self,
Expand Down
Loading

0 comments on commit 16a71c1

Please sign in to comment.