Skip to content

Commit

Permalink
Study creation with settings, also updated playlist parameters to val…
Browse files Browse the repository at this point in the history
…idate on assignment.
  • Loading branch information
Sigurd-Borge committed Dec 10, 2024
1 parent a460e66 commit e8f9538
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/antares/model/settings/playlist_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class PlaylistParameters(BaseModel):
playlist (list[PlaylistData]): A list of years (in **PlaylistData** format) in the playlist
"""

class Config:
validate_assignment = True

playlist: list[PlaylistData] = Field(default=[], exclude=True)

_playlist_dict_error_msg = "Not a valid playlist dictionary."
Expand Down
15 changes: 15 additions & 0 deletions tests/integration/test_local_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
from antares.model.commons import FilterOption
from antares.model.link import Link, LinkProperties, LinkUi
from antares.model.renewable import RenewableClusterGroup, RenewableClusterProperties
from antares.model.settings.general import GeneralParametersLocal, Mode
from antares.model.settings.playlist_parameters import PlaylistParameters
from antares.model.settings.study_settings import StudySettingsLocal
from antares.model.st_storage import STStorageGroup, STStorageProperties
from antares.model.study import Study
from antares.model.thermal import ThermalCluster, ThermalClusterGroup, ThermalClusterProperties
Expand Down Expand Up @@ -262,3 +265,15 @@ def test_local_study(self, tmp_path, other_area):
constraint_2.id: constraint_2,
constraint_3.id: constraint_3,
}

# test study creation with settings
settings = StudySettingsLocal()
settings.general_parameters = GeneralParametersLocal(mode="Adequacy")
settings.general_parameters.year_by_year = False
settings.playlist_parameters = PlaylistParameters()
settings.playlist_parameters.playlist = [{"status": False, "weight": 1}]
new_study = create_study_local("second_study", "880", tmp_path, settings)
settings = new_study.get_settings()
assert settings.general_parameters.mode == Mode.ADEQUACY.value
assert not settings.general_parameters.year_by_year
assert settings.playlist_parameters.model_dump() == {1: {"status": False, "weight": 1}}

0 comments on commit e8f9538

Please sign in to comment.