Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/add-installer-submodule'…
Browse files Browse the repository at this point in the history
… into feature/add-installer-submodule
  • Loading branch information
maugde committed Aug 22, 2024
2 parents 87970fe + d59efea commit b74c443
Show file tree
Hide file tree
Showing 47 changed files with 332 additions and 942 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
python -m pip install --upgrade pip
pip install pydantic --no-binary pydantic
pip install -r requirements-dev.txt
pip install -r installer/requirements.txt
- name: 🐍 Install Windows dependencies
if: matrix.os == 'windows-latest'
Expand Down
7 changes: 2 additions & 5 deletions antarest/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,8 @@ def __str__(self) -> str:


class UnsupportedStudyVersion(HTTPException):
def __init__(self, version: str) -> None:
super().__init__(
HTTPStatus.BAD_REQUEST,
f"Study version {version} is not supported",
)
def __init__(self, message: str) -> None:
super().__init__(HTTPStatus.BAD_REQUEST, message)


class UnsupportedOperationOnArchivedStudy(HTTPException):
Expand Down
4 changes: 2 additions & 2 deletions antarest/study/business/adequacy_patch_management.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, Dict, List, Optional

from pydantic.types import StrictBool, confloat
from pydantic.types import StrictBool, confloat, conint

from antarest.study.business.enum_ignore_case import EnumIgnoreCase
from antarest.study.business.utils import GENERAL_DATA_PATH, FieldInfo, FormFieldsBaseModel, execute_or_add_commands
Expand Down Expand Up @@ -28,7 +28,7 @@ class AdequacyPatchFormFields(FormFieldsBaseModel):
check_csr_cost_function: Optional[StrictBool]
threshold_initiate_curtailment_sharing_rule: Optional[ThresholdType] # type: ignore
threshold_display_local_matching_rule_violations: Optional[ThresholdType] # type: ignore
threshold_csr_variable_bounds_relaxation: Optional[ThresholdType] # type: ignore
threshold_csr_variable_bounds_relaxation: Optional[conint(ge=0, strict=True)] # type: ignore


ADEQUACY_PATCH_PATH = f"{GENERAL_DATA_PATH}/adequacy patch"
Expand Down
22 changes: 9 additions & 13 deletions antarest/study/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
StudyVariantUpgradeError,
TaskAlreadyRunning,
UnsupportedOperationOnArchivedStudy,
UnsupportedStudyVersion,
)
from antarest.core.filetransfer.model import FileDownloadTaskDTO
from antarest.core.filetransfer.service import FileTransferManager
Expand Down Expand Up @@ -116,12 +115,7 @@
from antarest.study.storage.rawstudy.raw_study_service import RawStudyService
from antarest.study.storage.storage_service import StudyStorageService
from antarest.study.storage.study_download_utils import StudyDownloader, get_output_variables_information
from antarest.study.storage.study_upgrader import (
find_next_version,
get_current_version,
should_study_be_denormalized,
upgrade_study,
)
from antarest.study.storage.study_upgrader import StudyUpgrader, check_versions_coherence, find_next_version
from antarest.study.storage.utils import assert_permission, get_start_date, is_managed, remove_from_cache
from antarest.study.storage.variantstudy.business.utils import transform_command_to_dto
from antarest.study.storage.variantstudy.model.command.icommand import ICommand
Expand Down Expand Up @@ -192,13 +186,13 @@ def _upgrade_study(self) -> None:
self.storage_service.variant_study_service.clear_snapshot(study_to_upgrade)
else:
study_path = Path(study_to_upgrade.path)
current_version = get_current_version(study_path)
if is_managed(study_to_upgrade) and should_study_be_denormalized(current_version, target_version):
study_upgrader = StudyUpgrader(study_path, target_version)
if is_managed(study_to_upgrade) and study_upgrader.should_denormalize_study():
# We have to denormalize the study because the upgrade impacts study matrices
file_study = self.storage_service.get_storage(study_to_upgrade).get_raw(study_to_upgrade)
file_study.tree.denormalize()
is_study_denormalized = True
upgrade_study(study_path, target_version)
study_upgrader.upgrade()
remove_from_cache(self.cache_service, study_to_upgrade.id)
study_to_upgrade.version = target_version
self.repository.save(study_to_upgrade)
Expand Down Expand Up @@ -2426,13 +2420,15 @@ def upgrade_study(
# First check if the study is a variant study, if so throw an error
if isinstance(study, VariantStudy):
raise StudyVariantUpgradeError(True)
# If the study is a parent raw study, throw an error
# If the study is a parent raw study and has variants, throw an error
elif self.repository.has_children(study_id):
raise StudyVariantUpgradeError(False)

target_version = target_version or find_next_version(study.version)
# Checks versions coherence before launching the task
if not target_version:
raise UnsupportedStudyVersion(study.version)
target_version = find_next_version(study.version)
else:
check_versions_coherence(study.version, target_version)

task_name = f"Upgrade study {study.name} ({study.id}) to version {target_version}"
study_tasks = self.task_service.list_tasks(
Expand Down
Loading

0 comments on commit b74c443

Please sign in to comment.