Skip to content

Commit

Permalink
Merge branch 'refs/heads/hotfix/v2.16.8' into dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	antarest/core/exceptions.py
#	antarest/study/business/areas/renewable_management.py
#	antarest/study/business/areas/st_storage_management.py
#	antarest/study/business/areas/thermal_management.py
#	antarest/study/business/thematic_trimming_field_infos.py
#	antarest/study/storage/variantstudy/model/model.py
#	antarest/study/web/study_data_blueprint.py
#	tests/integration/study_data_blueprint/test_renewable.py
#	tests/integration/study_data_blueprint/test_st_storage.py
#	tests/integration/study_data_blueprint/test_thermal.py
#	tests/storage/repository/filesystem/config/test_config_files.py
#	tests/study/business/areas/test_st_storage_management.py
#	webapp/src/components/App/Singlestudy/explore/Configuration/General/dialogs/ThematicTrimmingDialog/utils.ts
#	webapp/src/components/App/Singlestudy/explore/Modelization/BindingConstraints/AddDialog.tsx
  • Loading branch information
laurent-laporte-pro committed Apr 22, 2024
1 parent d2a78da commit 3624143
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 45 deletions.
4 changes: 2 additions & 2 deletions antarest/study/business/area_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

from antarest.core.exceptions import ConfigFileNotFound, DuplicateAreaName, LayerNotAllowedToBeDeleted, LayerNotFound
from antarest.core.model import JSON
from antarest.study.business.utils import AllOptionalMetaclass, camel_case_model, execute_or_add_commands
from antarest.study.business.all_optional_meta import AllOptionalMetaclass, camel_case_model
from antarest.study.business.utils import execute_or_add_commands
from antarest.study.model import Patch, PatchArea, PatchCluster, RawStudy, Study
from antarest.study.repository import StudyMetadataRepository
from antarest.study.storage.patch_service import PatchService
from antarest.study.storage.rawstudy.model.filesystem.config.area import (
AdequacyPathProperties,
AreaFolder,
AreaUI,
OptimizationProperties,
ThermalAreasProperties,
UIProperties,
Expand Down
4 changes: 2 additions & 2 deletions antarest/study/business/areas/st_storage_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def create_storage_output(
cluster_id: str,
config: t.Mapping[str, t.Any],
) -> "STStorageOutput":
obj = create_st_storage_config(study_version=study_version, **config, id=cluster_id)
obj = create_st_storage_config(study_version, **config, id=cluster_id)
kwargs = obj.dict(by_alias=False)
return STStorageOutput(**kwargs)

Expand Down Expand Up @@ -361,7 +361,7 @@ def get_all_storages_props(
storages_by_areas = collections.defaultdict(dict)
for area_id, cluster_obj in storages.items():
for cluster_id, cluster in cluster_obj.items():
storages_by_areas[area_id][cluster_id] = STStorageOutput.from_config(cluster_id, cluster)
storages_by_areas[area_id][cluster_id] = create_storage_output(int(study.version), cluster_id, cluster)

return storages_by_areas

Expand Down
8 changes: 3 additions & 5 deletions antarest/study/business/binding_constraint_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@

from antarest.core.exceptions import (
BindingConstraintNotFound,
ConfigFileNotFound,
ConstraintAlreadyExistError,
ConstraintIdNotFoundError,
DuplicateConstraintName,
IncoherenceBetweenMatricesLength,
InvalidConstraintName,
InvalidFieldForVersionError,
MatrixWidthMismatchError,
Expand Down Expand Up @@ -323,7 +321,7 @@ class ConstraintOutput870(ConstraintOutput830):

def _get_references_by_widths(
file_study: FileStudy, bcs: t.Sequence[ConstraintOutput]
) -> Mapping[int, Sequence[Tuple[str, str]]]:
) -> t.Mapping[int, t.Sequence[t.Tuple[str, str]]]:
"""
Iterates over each BC and its associated matrices.
For each matrix, it checks its width according to the expected matrix shapes.
Expand Down Expand Up @@ -363,15 +361,15 @@ def _get_references_by_widths(
return references_by_width


def _validate_binding_constraints(file_study: FileStudy, bcs: Sequence[ConstraintOutput]) -> bool:
def _validate_binding_constraints(file_study: FileStudy, bcs: t.Sequence[ConstraintOutput]) -> bool:
"""
Validates the binding constraints within a group.
"""
references_by_widths = _get_references_by_widths(file_study, bcs)

if len(references_by_widths) > 1:
most_common = collections.Counter(references_by_widths.keys()).most_common()
invalid_constraints: Dict[str, str] = {}
invalid_constraints: t.Dict[str, str] = {}

for width, _ in most_common[1:]:
references = references_by_widths[width]
Expand Down
3 changes: 2 additions & 1 deletion antarest/study/business/link_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

from antarest.core.exceptions import ConfigFileNotFound
from antarest.core.model import JSON
from antarest.study.business.utils import AllOptionalMetaclass, camel_case_model, execute_or_add_commands
from antarest.study.business.all_optional_meta import AllOptionalMetaclass, camel_case_model
from antarest.study.business.utils import execute_or_add_commands
from antarest.study.model import RawStudy
from antarest.study.storage.rawstudy.model.filesystem.config.links import LinkProperties
from antarest.study.storage.storage_service import StudyStorageService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import typing as t
from pathlib import Path

from pydantic import BaseModel
from pydantic import Field, root_validator
from pydantic import BaseModel, Field, root_validator

from antarest.core.utils.utils import DTO
from antarest.study.business.enum_ignore_case import EnumIgnoreCase

from .binding_constraint import BindingConstraintFrequency
from .field_validators import extract_filtering
from .renewable import RenewableConfigType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class STStorage880Config(STStorage880Properties, LowerCaseIdentifier):
STStorageConfigType = t.Union[STStorageConfig, STStorage880Config]


def get_st_storage_config_cls(study_version: t.Union[str, int]) -> t.Type[STStorageConfig]:
def get_st_storage_config_cls(study_version: t.Union[str, int]) -> t.Type[STStorageConfigType]:
"""
Retrieves the short-term storage configuration class based on the study version.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import typing as t

from antarest.study.storage.rawstudy.model.filesystem.config.binding_constraint import (
BindingConstraintFrequency,
)
from antarest.study.storage.rawstudy.model.filesystem.config.model import FileStudyTreeConfig, BindingConstraintDTO
from antarest.study.storage.rawstudy.model.filesystem.config.binding_constraint import BindingConstraintFrequency
from antarest.study.storage.rawstudy.model.filesystem.config.model import BindingConstraintDTO, FileStudyTreeConfig


def parse_bindings_coeffs_and_save_into_config(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class BindingConstraintProperties830(BindingConstraintPropertiesBase):
filter_year_by_year: str = Field("", alias="filter-year-by-year")
filter_synthesis: str = Field("", alias="filter-synthesis")

@validator("filter_synthesis", "filter_year_by_year", pre=True)
def _validate_filtering(cls, v: t.Any) -> str:
return validate_filtering(v)


class BindingConstraintProperties870(BindingConstraintProperties830):
group: str = DEFAULT_GROUP
Expand Down Expand Up @@ -130,10 +134,6 @@ def create_binding_constraint_config(study_version: t.Union[str, int], **kwargs:
cls = get_binding_constraint_config_cls(study_version)
return cls.from_dict(**kwargs)

@validator("filter_synthesis", "filter_year_by_year", pre=True)
def _validate_filtering(cls, v: t.Any) -> str:
return validate_filtering(v)


class OptionalProperties(BindingConstraintProperties870, metaclass=AllOptionalMetaclass, use_none=True):
pass
Expand All @@ -144,25 +144,6 @@ class OptionalProperties(BindingConstraintProperties870, metaclass=AllOptionalMe
# =================================================================================


BindingConstraintPropertiesType = t.Union[BindingConstraintProperties870, BindingConstraintProperties]


def get_binding_constraint_config_cls(study_version: t.Union[str, int]) -> t.Type[BindingConstraintPropertiesType]:
"""
Retrieves the short-term storage configuration class based on the study version.
Args:
study_version: The version of the study.
Returns:
The short-term storage configuration class.
"""
version = int(study_version)
if version >= 870:
return BindingConstraintProperties870
return BindingConstraintProperties


class BindingConstraintMatrices(BaseModel, extra=Extra.forbid, allow_population_by_field_name=True):
"""
Class used to store the matrices of a binding constraint.
Expand Down
3 changes: 1 addition & 2 deletions antarest/study/web/study_data_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
from antarest.study.business.adequacy_patch_management import AdequacyPatchFormFields
from antarest.study.business.advanced_parameters_management import AdvancedParamsFormFields
from antarest.study.business.allocation_management import AllocationFormFields, AllocationMatrix
from antarest.study.business.area_management import AreaCreationDTO, AreaInfoDTO, AreaType, LayerInfoDTO, \
UpdateAreaUi
from antarest.study.business.area_management import AreaCreationDTO, AreaInfoDTO, AreaType, LayerInfoDTO, UpdateAreaUi
from antarest.study.business.areas.hydro_management import InflowStructure, ManagementOptionsFormFields
from antarest.study.business.areas.properties_management import PropertiesFormFields
from antarest.study.business.areas.renewable_management import (
Expand Down
3 changes: 1 addition & 2 deletions webapp/src/components/common/TableMode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { SubmitHandlerPlus } from "./Form/types";
import TableForm from "./TableForm";
import UsePromiseCond from "./utils/UsePromiseCond";
import GridOffIcon from "@mui/icons-material/GridOff";
import { useTranslation } from "react-i18next";
import SimpleContent from "./page/SimpleContent";

export interface TableModeProps<T extends TableModeType = TableModeType> {
Expand Down Expand Up @@ -56,7 +55,7 @@ function TableMode<T extends TableModeType>(props: TableModeProps<T>) {
////////////////////////////////////////////////////////////////

const handleSubmit = (data: SubmitHandlerPlus<TableData>) => {
return setTableMode({ studyId, type, data: data.dirtyValues });
return setTableMode(studyId, type, data.dirtyValues);
};

////////////////////////////////////////////////////////////////
Expand Down
6 changes: 5 additions & 1 deletion webapp/src/services/api/studies/tableMode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { StudyMetadata } from "../../../../common/types";
import client from "../../client";
import { format } from "../../../../utils/stringUtils";
import { TABLE_MODE_API_URL } from "../../constants";
import type { TableData, TableModeColumnsForType, TableModeType } from "./type";
import type {
TableData,
TableModeColumnsForType,
TableModeType,
} from "./types";

export async function getTableMode<T extends TableModeType>(
studyId: StudyMetadata["id"],
Expand Down

0 comments on commit 3624143

Please sign in to comment.