Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(group): enforce lower case for item groups #2333

Open
wants to merge 26 commits into
base: dev
Choose a base branch
from

Conversation

sylvlecl
Copy link
Member

@sylvlecl sylvlecl commented Feb 6, 2025

Simpler version of #2283
which will affect only groups, not cluster names and identifiers.

Should be merged after #2332

Signed-off-by: Sylvain Leclerc <[email protected]>
Signed-off-by: Sylvain Leclerc <[email protected]>
Signed-off-by: Sylvain Leclerc <[email protected]>
Signed-off-by: Sylvain Leclerc <[email protected]>
Signed-off-by: Sylvain Leclerc <[email protected]>
Signed-off-by: Sylvain Leclerc <[email protected]>
Signed-off-by: Sylvain Leclerc <[email protected]>
Signed-off-by: Sylvain Leclerc <[email protected]>
Signed-off-by: Sylvain Leclerc <[email protected]>
@sylvlecl sylvlecl marked this pull request as ready for review February 6, 2025 13:35
Copy link
Contributor

@MartinBelthle MartinBelthle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed with Florian, we should do something in the run method in case the study is in version 8.6 or 8.7 and the user didn't specified a solver higher or equal to 8.8
Could be done in another PR but it would mean that this doesn't work on it's own

values = self.model_dump(mode="json", by_alias=False, exclude_none=True)
return create_st_storage_config(study_version=study_version, **values)

def _to_properties(version: StudyVersion, creation: STStorageCreation) -> STStoragePropertiesType:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why didn't you put this as a method of STStorageCreation ? Because you did a method for RenewableCreation and ThermalCreation so we should probably harmonize

if isinstance(name, int):
name = str(name)
if not isinstance(name, str):
ValueError(f"Invalid name '{name}'.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sonar Issue: We should add a raise here :)

from antarest.study.storage.rawstudy.model.filesystem.config.model import FileStudyTreeConfig
from antarest.study.storage.rawstudy.model.filesystem.context import ContextServer
from antarest.study.storage.rawstudy.model.filesystem.ini_file_node import IniFileNode

_VALUE_PARSERS = {any_section_option_matcher("group"): LOWER_CASE_PARSER}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Should we put these parsers / serializers in a util file instead of declarating them every time ?

@@ -117,7 +117,7 @@ def test_lifecycle(
fr_solar_pv_props = {
**DEFAULT_PROPERTIES,
"name": fr_solar_pv,
"group": "Solar PV",
"group": "solar pv",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we should keep the MAJ to ensure we can create a cluster with a group in the wrong format.
We also have to change the check after to see that we return the value lowered

def validate_model(cls, values: t.Dict[str, t.Any], info: ValidationInfo) -> t.Dict[str, t.Any]:
# Validate parameters
if isinstance(values["parameters"], dict):
parameters = copy.deepcopy(values["parameters"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we need to make a copy here

@@ -361,7 +361,7 @@ def test_lifecycle__nominal(
grand_maison = "Grand'Maison"
grand_maison_properties = {
"name": grand_maison,
"group": "PSP_closed",
"group": "psp_closed",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same. We could keep the old writing

@@ -116,15 +116,15 @@ def test_nominal_case_of_an_api_user(client: TestClient, admin_access_token: str
"parameters": {
"group": "Gas",
"marginal-cost": 98,
"unitCount": 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you change it because it doesn't work anymore ? If so, it could be an issue as it's kind of a breaking change (even though the scripts don't use this writing)


data = {"0": {"name": "BC_1", "group": "GRP_1"}}
node.save(data)
# Asserts the data is saved correctly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be nice to add the same test as above concerning the save of a new group specifically

"parameters": {"group": "Nuclear", "nominalcapacity": 2400, "unitcount": 2},
"prepro": prepro_id,
"modulation": modulation_id,
"modulation": "acc60faf9e0c47c77ec61c0d522382676102d8c1de1eb4aac1c5bb3a11682ff8",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change the prepro and modulation ids ? I think it was better before. Also this hash could be random no ?

"name": "id",
"base_filter": "add-all",
"filter_items": ["a"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants