Skip to content

Commit

Permalink
v2.11.0 (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
pl-buiquang authored Dec 6, 2022
2 parents 61e4b23 + 09e3ae7 commit a74f51a
Show file tree
Hide file tree
Showing 131 changed files with 3,927 additions and 1,896 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#FROM python:3.8-slim-buster
FROM brunneis/python:3.8.3-ubuntu-20.04
FROM python:3.8-slim-bullseye

# RUN apt update && apt install -y procps gdb

ENV ANTAREST_CONF /resources/application.yaml

Expand Down
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.10.1"
__version__ = "2.11.0"

from pathlib import Path

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

@staticmethod
def from_dict(data: JSON) -> "StorageConfig":
Expand All @@ -149,6 +150,7 @@ def from_dict(data: JSON) -> "StorageConfig":
auto_archive_threshold_days=data.get(
"auto_archive_threshold_days", 60
),
auto_archive_dry_run=data.get("auto_archive_dry_run", False),
)


Expand Down
7 changes: 7 additions & 0 deletions antarest/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ def __init__(self, uuid: str) -> None:
)


class TaskAlreadyRunning(HTTPException):
def __init__(self) -> None:
super(TaskAlreadyRunning, self).__init__(
HTTPStatus.EXPECTATION_FAILED, "Task is already running"
)


class StudyDeletionNotAllowed(HTTPException):
def __init__(self, uuid: str, message: Optional[str] = None) -> None:
msg = f"Study {uuid} (not managed) is not allowed to be deleted"
Expand Down
1 change: 1 addition & 0 deletions antarest/core/tasks/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TaskType(str, Enum):
UNARCHIVE = "UNARCHIVE"
SCAN = "SCAN"
WORKER_TASK = "WORKER_TASK"
UPGRADE_STUDY = "UPGRADE_STUDY"


class TaskStatus(Enum):
Expand Down
2 changes: 1 addition & 1 deletion antarest/core/tasks/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def _run_task(
logger.error(f"Exception when running task {task_id}", exc_info=e)
with db():
self._update_task_status(
task_id, TaskStatus.FAILED, False, str(e)
task_id, TaskStatus.FAILED, False, repr(e)
)
self.event_bus.push(
Event(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def _clean_up_study(self, launch_id: str) -> None:
self.local_workspace / STUDIES_OUTPUT_DIR_NAME
).iterdir():
if finished_zip.is_file() and re.match(
f"finished_{launch_id}_\\d+", finished_zip.name
f"finished_(XPANSION_)?{launch_id}_\\d+", finished_zip.name
):
self._delete_workspace_file(finished_zip)

Expand Down
11 changes: 10 additions & 1 deletion antarest/matrixstore/matrix_garbage_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
from antarest.matrixstore.uri_resolver_service import UriResolverService
from antarest.study.model import DEFAULT_WORKSPACE_NAME
from antarest.study.service import StudyService
from antarest.study.storage.variantstudy.business.matrix_constants_generator import (
GeneratorMatrixConstants,
)
from antarest.study.storage.variantstudy.model.command.icommand import ICommand
from antarest.study.storage.variantstudy.model.dbmodel import CommandBlock
from antarest.study.storage.variantstudy.model.model import CommandDTO
Expand Down Expand Up @@ -44,6 +47,9 @@ def __init__(
matrix_service.repo_dataset
)
self.sleeping_time = config.storage.matrix_gc_sleeping_time
self.matrix_constants = (
study_service.storage_service.variant_study_service.command_factory.command_context.generator_matrix_constants
)
self.dry_run = config.storage.matrix_gc_dry_run

def _get_saved_matrices(self) -> Set[str]:
Expand Down Expand Up @@ -108,7 +114,10 @@ def _get_used_matrices(self) -> Set[str]:
variant_studies_matrices = self._get_variant_studies_matrices()
datasets_matrices = self._get_datasets_matrices()
return (
raw_studies_matrices | variant_studies_matrices | datasets_matrices
raw_studies_matrices
| variant_studies_matrices
| datasets_matrices
| set(self.matrix_constants.hashes.values())
)

def _delete_unused_saved_matrices(self, unused_matrices: Set[str]) -> None:
Expand Down
7 changes: 7 additions & 0 deletions antarest/singleton_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
create_matrix_gc,
create_archive_worker,
create_core_services,
create_simulator_worker,
)

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -64,6 +65,12 @@ def _init(
worker = create_archive_worker(config, "test", event_bus=event_bus)
services[Module.ARCHIVE_WORKER] = worker

if Module.SIMULATOR_WORKER in services_list:
worker = create_simulator_worker(
config, matrix_service=matrix_service, event_bus=event_bus
)
services[Module.SIMULATOR_WORKER] = worker

if Module.AUTO_ARCHIVER in services_list:
auto_archive_service = AutoArchiveService(study_service, config)
services[Module.AUTO_ARCHIVER] = auto_archive_service
Expand Down
20 changes: 19 additions & 1 deletion antarest/study/business/optimization_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ class LinkType(str, Enum):
AC = "ac"


class LegacyTransmissionCapacities(str, Enum):
INFINITE = "infinite"


class TransmissionCapacities(str, Enum):
LOCAL_VALUES = "local-values"
NULL_FOR_ALL_LINKS = "null-for-all-links"
INFINITE_FOR_ALL_LINKS = "infinite-for-all-links"
NULL_FOR_PHYSICAL_LINKS = "null-for-physical-links"
INFINITE_FOR_PHYSICAL_LINKS = "infinite-for-physical-links"


class UnfeasibleProblemBehavior(str, Enum):
WARNING_DRY = "warning-dry"
WARNING_VERBOSE = "warning-verbose"
Expand All @@ -36,7 +48,12 @@ class SimplexOptimizationRange(str, Enum):
class OptimizationFormFields(FormFieldsBaseModel):
binding_constraints: Optional[StrictBool]
hurdle_costs: Optional[StrictBool]
transmission_capacities: Optional[Union[StrictBool, Literal["infinite"]]]
transmission_capacities: Optional[
Union[
StrictBool,
Union[LegacyTransmissionCapacities, TransmissionCapacities],
]
]
link_type: Optional[LinkType]
thermal_clusters_min_stable_power: Optional[StrictBool]
thermal_clusters_min_ud_time: Optional[StrictBool]
Expand Down Expand Up @@ -117,6 +134,7 @@ class OptimizationFormFields(FormFieldsBaseModel):
"path": f"{OPTIMIZATION_PATH}/include-split-exported-mps",
"default_value": False,
"start_version": 830,
"end_version": 840,
},
"enable_adequacy_patch": {
"path": f"{ADEQUACY_PATCH_PATH}/include-adq-patch",
Expand Down
3 changes: 2 additions & 1 deletion antarest/study/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
"810": "empty_study_810.zip",
"820": "empty_study_820.zip",
"830": "empty_study_830.zip",
"840": "empty_study_840.zip",
}

NEW_DEFAULT_STUDY_VERSION: str = "830"
NEW_DEFAULT_STUDY_VERSION: str = "840"


class StudyContentStatus(enum.Enum):
Expand Down
Loading

0 comments on commit a74f51a

Please sign in to comment.