diff --git a/antarest/study/business/thematic_trimming_field_infos.py b/antarest/study/business/thematic_trimming_field_infos.py new file mode 100644 index 0000000000..30d95a9393 --- /dev/null +++ b/antarest/study/business/thematic_trimming_field_infos.py @@ -0,0 +1,229 @@ +""" +List of fields of the Thematic Trimming panel +""" + +import typing as t + +from antarest.study.business.utils import AllOptionalMetaclass, FormFieldsBaseModel + + +class ThematicTrimmingFormFields(FormFieldsBaseModel, metaclass=AllOptionalMetaclass, use_none=True): + """ + This class manages the configuration of result filtering in a simulation. + + This table allows the user to enable or disable specific variables before running a simulation. + """ + + ov_cost: bool + op_cost: bool + mrg_price: bool + co2_emis: bool + dtg_by_plant: bool + balance: bool + row_bal: bool + psp: bool + misc_ndg: bool + load: bool + h_ror: bool + wind: bool + solar: bool + nuclear: bool + lignite: bool + coal: bool + gas: bool + oil: bool + mix_fuel: bool + misc_dtg: bool + h_stor: bool + h_pump: bool + h_lev: bool + h_infl: bool + h_ovfl: bool + h_val: bool + h_cost: bool + unsp_enrg: bool + spil_enrg: bool + lold: bool + lolp: bool + avl_dtg: bool + dtg_mrg: bool + max_mrg: bool + np_cost: bool + np_cost_by_plant: bool + nodu: bool + nodu_by_plant: bool + flow_lin: bool + ucap_lin: bool + loop_flow: bool + flow_quad: bool + cong_fee_alg: bool + cong_fee_abs: bool + marg_cost: bool + cong_prob_plus: bool + cong_prob_minus: bool + hurdle_cost: bool + # since v8.1 + res_generation_by_plant: bool + misc_dtg_2: bool + misc_dtg_3: bool + misc_dtg_4: bool + wind_offshore: bool + wind_onshore: bool + solar_concrt: bool + solar_pv: bool + solar_rooft: bool + renw_1: bool + renw_2: bool + renw_3: bool + renw_4: bool + # since v8.3 + dens: bool + profit_by_plant: bool + # topic: Short-Term Storages + # since v8.6 + sts_inj_by_plant: bool + sts_withdrawal_by_plant: bool + sts_lvl_by_plant: bool + sts_cashflow_by_cluster: bool + # topic: Short-Term Storages - Group + psp_open_injection: bool + psp_open_withdrawal: bool + psp_open_level: bool + psp_closed_injection: bool + psp_closed_withdrawal: bool + psp_closed_level: bool + pondage_injection: bool + pondage_withdrawal: bool + pondage_level: bool + battery_injection: bool + battery_withdrawal: bool + battery_level: bool + other1_injection: bool + other1_withdrawal: bool + other1_level: bool + other2_injection: bool + other2_withdrawal: bool + other2_level: bool + other3_injection: bool + other3_withdrawal: bool + other3_level: bool + other4_injection: bool + other4_withdrawal: bool + other4_level: bool + other5_injection: bool + other5_withdrawal: bool + other5_level: bool + + +_GENERAL = "General" +_SHORT_TERM_STORAGES = "Short-Term Storages" +_SHORT_TERM_STORAGES_GROUP = "Short-Term Storages - Group" + +FIELDS_INFO: t.Mapping[str, t.Mapping[str, t.Any]] = { + # fmt: off + "ov_cost": {"topic": _GENERAL, "path": "OV. COST", "default_value": True}, + "op_cost": {"topic": _GENERAL, "path": "OP. COST", "default_value": True}, + "mrg_price": {"topic": _GENERAL, "path": "MRG. PRICE", "default_value": True}, + "co2_emis": {"topic": _GENERAL, "path": "CO2 EMIS.", "default_value": True}, + "dtg_by_plant": {"topic": _GENERAL, "path": "DTG by plant", "default_value": True}, + "balance": {"topic": _GENERAL, "path": "BALANCE", "default_value": True}, + "row_bal": {"topic": _GENERAL, "path": "ROW BAL.", "default_value": True}, + "psp": {"topic": _GENERAL, "path": "PSP", "default_value": True}, + "misc_ndg": {"topic": _GENERAL, "path": "MISC. NDG", "default_value": True}, + "load": {"topic": _GENERAL, "path": "LOAD", "default_value": True}, + "h_ror": {"topic": _GENERAL, "path": "H. ROR", "default_value": True}, + "wind": {"topic": _GENERAL, "path": "WIND", "default_value": True}, + "solar": {"topic": _GENERAL, "path": "SOLAR", "default_value": True}, + "nuclear": {"topic": _GENERAL, "path": "NUCLEAR", "default_value": True}, + "lignite": {"topic": _GENERAL, "path": "LIGNITE", "default_value": True}, + "coal": {"topic": _GENERAL, "path": "COAL", "default_value": True}, + "gas": {"topic": _GENERAL, "path": "GAS", "default_value": True}, + "oil": {"topic": _GENERAL, "path": "OIL", "default_value": True}, + "mix_fuel": {"topic": _GENERAL, "path": "MIX. FUEL", "default_value": True}, + "misc_dtg": {"topic": _GENERAL, "path": "MISC. DTG", "default_value": True}, + "h_stor": {"topic": _GENERAL, "path": "H. STOR", "default_value": True}, + "h_pump": {"topic": _GENERAL, "path": "H. PUMP", "default_value": True}, + "h_lev": {"topic": _GENERAL, "path": "H. LEV", "default_value": True}, + "h_infl": {"topic": _GENERAL, "path": "H. INFL", "default_value": True}, + "h_ovfl": {"topic": _GENERAL, "path": "H. OVFL", "default_value": True}, + "h_val": {"topic": _GENERAL, "path": "H. VAL", "default_value": True}, + "h_cost": {"topic": _GENERAL, "path": "H. COST", "default_value": True}, + "unsp_enrg": {"topic": _GENERAL, "path": "UNSP. ENRG", "default_value": True}, + "spil_enrg": {"topic": _GENERAL, "path": "SPIL. ENRG", "default_value": True}, + "lold": {"topic": _GENERAL, "path": "LOLD", "default_value": True}, + "lolp": {"topic": _GENERAL, "path": "LOLP", "default_value": True}, + "avl_dtg": {"topic": _GENERAL, "path": "AVL DTG", "default_value": True}, + "dtg_mrg": {"topic": _GENERAL, "path": "DTG MRG", "default_value": True}, + "max_mrg": {"topic": _GENERAL, "path": "MAX MRG", "default_value": True}, + "np_cost": {"topic": _GENERAL, "path": "NP COST", "default_value": True}, + "np_cost_by_plant": {"topic": _GENERAL, "path": "NP Cost by plant", "default_value": True}, + "nodu": {"topic": _GENERAL, "path": "NODU", "default_value": True}, + "nodu_by_plant": {"topic": _GENERAL, "path": "NODU by plant", "default_value": True}, + "flow_lin": {"topic": _GENERAL, "path": "FLOW LIN.", "default_value": True}, + "ucap_lin": {"topic": _GENERAL, "path": "UCAP LIN.", "default_value": True}, + "loop_flow": {"topic": _GENERAL, "path": "LOOP FLOW", "default_value": True}, + "flow_quad": {"topic": _GENERAL, "path": "FLOW QUAD.", "default_value": True}, + "cong_fee_alg": {"topic": _GENERAL, "path": "CONG. FEE (ALG.)", "default_value": True}, + "cong_fee_abs": {"topic": _GENERAL, "path": "CONG. FEE (ABS.)", "default_value": True}, + "marg_cost": {"topic": _GENERAL, "path": "MARG. COST", "default_value": True}, + "cong_prob_plus": {"topic": _GENERAL, "path": "CONG. PROB +", "default_value": True}, + "cong_prob_minus": {"topic": _GENERAL, "path": "CONG. PROB -", "default_value": True}, + "hurdle_cost": {"topic": _GENERAL, "path": "HURDLE COST", "default_value": True}, + # since v8.1 + "res_generation_by_plant": {"topic": _GENERAL, "path": "RES generation by plant", "default_value": True, "start_version": 810}, + "misc_dtg_2": {"topic": _GENERAL, "path": "MISC. DTG 2", "default_value": True, "start_version": 810}, + "misc_dtg_3": {"topic": _GENERAL, "path": "MISC. DTG 3", "default_value": True, "start_version": 810}, + "misc_dtg_4": {"topic": _GENERAL, "path": "MISC. DTG 4", "default_value": True, "start_version": 810}, + "wind_offshore": {"topic": _GENERAL, "path": "WIND OFFSHORE", "default_value": True, "start_version": 810}, + "wind_onshore": {"topic": _GENERAL, "path": "WIND ONSHORE", "default_value": True, "start_version": 810}, + "solar_concrt": {"topic": _GENERAL, "path": "SOLAR CONCRT.", "default_value": True, "start_version": 810}, + "solar_pv": {"topic": _GENERAL, "path": "SOLAR PV", "default_value": True, "start_version": 810}, + "solar_rooft": {"topic": _GENERAL, "path": "SOLAR ROOFT", "default_value": True, "start_version": 810}, + "renw_1": {"topic": _GENERAL, "path": "RENW. 1", "default_value": True, "start_version": 810}, + "renw_2": {"topic": _GENERAL, "path": "RENW. 2", "default_value": True, "start_version": 810}, + "renw_3": {"topic": _GENERAL, "path": "RENW. 3", "default_value": True, "start_version": 810}, + "renw_4": {"topic": _GENERAL, "path": "RENW. 4", "default_value": True, "start_version": 810}, + # since v8.3 + "dens": {"topic": _GENERAL, "path": "DENS", "default_value": True, "start_version": 830}, + "profit_by_plant": {"topic": _GENERAL, "path": "Profit by plant", "default_value": True, "start_version": 830}, + # topic: "Short-Term Storages" + # since v8.6 + "sts_inj_by_plant": {"topic": _SHORT_TERM_STORAGES, "path": "STS inj by plant", "default_value": True, "start_version": 860}, + "sts_withdrawal_by_plant": {"topic": _SHORT_TERM_STORAGES, "path": "STS withdrawal by plant", "default_value": True, "start_version": 860}, + "sts_lvl_by_plant": {"topic": _SHORT_TERM_STORAGES, "path": "STS lvl by plant", "default_value": True, "start_version": 860}, + "sts_cashflow_by_cluster": {"topic": _SHORT_TERM_STORAGES, "path": "STS Cashflow By Cluster", "default_value": True, "start_version": 860}, + # topic: "Short-Term Storages - Group" + "psp_open_injection": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "PSP_open_injection", "default_value": True, "start_version": 860}, + "psp_open_withdrawal": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "PSP_open_withdrawal", "default_value": True, "start_version": 860}, + "psp_open_level": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "PSP_open_level", "default_value": True, "start_version": 860}, + "psp_closed_injection": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "PSP_closed_injection", "default_value": True, "start_version": 860}, + "psp_closed_withdrawal": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "PSP_closed_withdrawal", "default_value": True, "start_version": 860}, + "psp_closed_level": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "PSP_closed_level", "default_value": True, "start_version": 860}, + "pondage_injection": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Pondage_injection", "default_value": True, "start_version": 860}, + "pondage_withdrawal": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Pondage_withdrawal", "default_value": True, "start_version": 860}, + "pondage_level": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Pondage_level", "default_value": True, "start_version": 860}, + "battery_injection": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Battery_injection", "default_value": True, "start_version": 860}, + "battery_withdrawal": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Battery_withdrawal", "default_value": True, "start_version": 860}, + "battery_level": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Battery_level", "default_value": True, "start_version": 860}, + "other1_injection": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other1_injection", "default_value": True, "start_version": 860}, + "other1_withdrawal": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other1_withdrawal", "default_value": True, "start_version": 860}, + "other1_level": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other1_level", "default_value": True, "start_version": 860}, + "other2_injection": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other2_injection", "default_value": True, "start_version": 860}, + "other2_withdrawal": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other2_withdrawal", "default_value": True, "start_version": 860}, + "other2_level": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other2_level", "default_value": True, "start_version": 860}, + "other3_injection": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other3_injection", "default_value": True, "start_version": 860}, + "other3_withdrawal": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other3_withdrawal", "default_value": True, "start_version": 860}, + "other3_level": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other3_level", "default_value": True, "start_version": 860}, + "other4_injection": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other4_injection", "default_value": True, "start_version": 860}, + "other4_withdrawal": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other4_withdrawal", "default_value": True, "start_version": 860}, + "other4_level": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other4_level", "default_value": True, "start_version": 860}, + "other5_injection": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other5_injection", "default_value": True, "start_version": 860}, + "other5_withdrawal": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other5_withdrawal", "default_value": True, "start_version": 860}, + "other5_level": {"topic": _SHORT_TERM_STORAGES_GROUP, "path": "Other5_level", "default_value": True, "start_version": 860}, + # fmt: on +} + + +def get_fields_info(study_version: t.Union[str, int]) -> t.Mapping[str, t.Mapping[str, t.Any]]: + study_version = int(study_version) + return {key: info for key, info in FIELDS_INFO.items() if (info.get("start_version") or 0) <= study_version} diff --git a/antarest/study/business/thematic_trimming_management.py b/antarest/study/business/thematic_trimming_management.py index 1ebfeebe04..d4af9f960e 100644 --- a/antarest/study/business/thematic_trimming_management.py +++ b/antarest/study/business/thematic_trimming_management.py @@ -1,162 +1,12 @@ import typing as t -from antarest.study.business.utils import ( - GENERAL_DATA_PATH, - AllOptionalMetaclass, - FieldInfo, - FormFieldsBaseModel, - execute_or_add_commands, -) +from antarest.study.business.thematic_trimming_field_infos import ThematicTrimmingFormFields, get_fields_info +from antarest.study.business.utils import GENERAL_DATA_PATH, execute_or_add_commands from antarest.study.model import Study from antarest.study.storage.storage_service import StudyStorageService from antarest.study.storage.variantstudy.model.command.update_config import UpdateConfig -class ThematicTrimmingFormFields(FormFieldsBaseModel, metaclass=AllOptionalMetaclass, use_none=True): - """ - This class manages the configuration of result filtering in a simulation. - - This table allows the user to enable or disable specific variables before running a simulation. - """ - - ov_cost: bool - op_cost: bool - mrg_price: bool - co2_emis: bool - dtg_by_plant: bool - balance: bool - row_bal: bool - psp: bool - misc_ndg: bool - load: bool - h_ror: bool - wind: bool - solar: bool - nuclear: bool - lignite: bool - coal: bool - gas: bool - oil: bool - mix_fuel: bool - misc_dtg: bool - h_stor: bool - h_pump: bool - h_lev: bool - h_infl: bool - h_ovfl: bool - h_val: bool - h_cost: bool - unsp_enrg: bool - spil_enrg: bool - lold: bool - lolp: bool - avl_dtg: bool - dtg_mrg: bool - max_mrg: bool - np_cost: bool - np_cost_by_plant: bool - nodu: bool - nodu_by_plant: bool - flow_lin: bool - ucap_lin: bool - loop_flow: bool - flow_quad: bool - cong_fee_alg: bool - cong_fee_abs: bool - marg_cost: bool - cong_prob_plus: bool - cong_prob_minus: bool - hurdle_cost: bool - # For study versions >= 810 - res_generation_by_plant: bool - misc_dtg_2: bool - misc_dtg_3: bool - misc_dtg_4: bool - wind_offshore: bool - wind_onshore: bool - solar_concrt: bool - solar_pv: bool - solar_rooft: bool - renw_1: bool - renw_2: bool - renw_3: bool - renw_4: bool - # For study versions >= 830 - dens: bool - profit_by_plant: bool - - -FIELDS_INFO: t.Dict[str, FieldInfo] = { - "ov_cost": {"path": "OV. COST", "default_value": True}, - "op_cost": {"path": "OP. COST", "default_value": True}, - "mrg_price": {"path": "MRG. PRICE", "default_value": True}, - "co2_emis": {"path": "CO2 EMIS.", "default_value": True}, - "dtg_by_plant": {"path": "DTG by plant", "default_value": True}, - "balance": {"path": "BALANCE", "default_value": True}, - "row_bal": {"path": "ROW BAL.", "default_value": True}, - "psp": {"path": "PSP", "default_value": True}, - "misc_ndg": {"path": "MISC. NDG", "default_value": True}, - "load": {"path": "LOAD", "default_value": True}, - "h_ror": {"path": "H. ROR", "default_value": True}, - "wind": {"path": "WIND", "default_value": True}, - "solar": {"path": "SOLAR", "default_value": True}, - "nuclear": {"path": "NUCLEAR", "default_value": True}, - "lignite": {"path": "LIGNITE", "default_value": True}, - "coal": {"path": "COAL", "default_value": True}, - "gas": {"path": "GAS", "default_value": True}, - "oil": {"path": "OIL", "default_value": True}, - "mix_fuel": {"path": "MIX. FUEL", "default_value": True}, - "misc_dtg": {"path": "MISC. DTG", "default_value": True}, - "h_stor": {"path": "H. STOR", "default_value": True}, - "h_pump": {"path": "H. PUMP", "default_value": True}, - "h_lev": {"path": "H. LEV", "default_value": True}, - "h_infl": {"path": "H. INFL", "default_value": True}, - "h_ovfl": {"path": "H. OVFL", "default_value": True}, - "h_val": {"path": "H. VAL", "default_value": True}, - "h_cost": {"path": "H. COST", "default_value": True}, - "unsp_enrg": {"path": "UNSP. ENRG", "default_value": True}, - "spil_enrg": {"path": "SPIL. ENRG", "default_value": True}, - "lold": {"path": "LOLD", "default_value": True}, - "lolp": {"path": "LOLP", "default_value": True}, - "avl_dtg": {"path": "AVL DTG", "default_value": True}, - "dtg_mrg": {"path": "DTG MRG", "default_value": True}, - "max_mrg": {"path": "MAX MRG", "default_value": True}, - "np_cost": {"path": "NP COST", "default_value": True}, - "np_cost_by_plant": {"path": "NP Cost by plant", "default_value": True}, - "nodu": {"path": "NODU", "default_value": True}, - "nodu_by_plant": {"path": "NODU by plant", "default_value": True}, - "flow_lin": {"path": "FLOW LIN.", "default_value": True}, - "ucap_lin": {"path": "UCAP LIN.", "default_value": True}, - "loop_flow": {"path": "LOOP FLOW", "default_value": True}, - "flow_quad": {"path": "FLOW QUAD.", "default_value": True}, - "cong_fee_alg": {"path": "CONG. FEE (ALG.)", "default_value": True}, - "cong_fee_abs": {"path": "CONG. FEE (ABS.)", "default_value": True}, - "marg_cost": {"path": "MARG. COST", "default_value": True}, - "cong_prob_plus": {"path": "CONG. PROB +", "default_value": True}, - "cong_prob_minus": {"path": "CONG. PROB -", "default_value": True}, - "hurdle_cost": {"path": "HURDLE COST", "default_value": True}, - "res_generation_by_plant": {"path": "RES generation by plant", "default_value": True, "start_version": 810}, - "misc_dtg_2": {"path": "MISC. DTG 2", "default_value": True, "start_version": 810}, - "misc_dtg_3": {"path": "MISC. DTG 3", "default_value": True, "start_version": 810}, - "misc_dtg_4": {"path": "MISC. DTG 4", "default_value": True, "start_version": 810}, - "wind_offshore": {"path": "WIND OFFSHORE", "default_value": True, "start_version": 810}, - "wind_onshore": {"path": "WIND ONSHORE", "default_value": True, "start_version": 810}, - "solar_concrt": {"path": "SOLAR CONCRT.", "default_value": True, "start_version": 810}, - "solar_pv": {"path": "SOLAR PV", "default_value": True, "start_version": 810}, - "solar_rooft": {"path": "SOLAR ROOFT", "default_value": True, "start_version": 810}, - "renw_1": {"path": "RENW. 1", "default_value": True, "start_version": 810}, - "renw_2": {"path": "RENW. 2", "default_value": True, "start_version": 810}, - "renw_3": {"path": "RENW. 3", "default_value": True, "start_version": 810}, - "renw_4": {"path": "RENW. 4", "default_value": True, "start_version": 810}, - "dens": {"path": "DENS", "default_value": True, "start_version": 830}, - "profit_by_plant": {"path": "Profit by plant", "default_value": True, "start_version": 830}, -} - - -def get_fields_info(study_version: int) -> t.Mapping[str, FieldInfo]: - return {key: info for key, info in FIELDS_INFO.items() if (info.get("start_version") or -1) <= study_version} - - class ThematicTrimmingManager: def __init__(self, storage_service: StudyStorageService) -> None: self.storage_service = storage_service @@ -172,7 +22,7 @@ def get_field_values(self, study: Study) -> ThematicTrimmingFormFields: include_vars = trimming_config.get("select_var +") or [] selected_vars_reset = trimming_config.get("selected_vars_reset", True) - def get_value(field_info: FieldInfo) -> t.Any: + def get_value(field_info: t.Mapping[str, t.Any]) -> t.Any: if selected_vars_reset is None: return field_info["default_value"] var_name = field_info["path"] diff --git a/antarest/study/web/study_data_blueprint.py b/antarest/study/web/study_data_blueprint.py index 475514c687..6d7dff831e 100644 --- a/antarest/study/web/study_data_blueprint.py +++ b/antarest/study/web/study_data_blueprint.py @@ -60,7 +60,7 @@ ColumnsModelTypes, TableTemplateType, ) -from antarest.study.business.thematic_trimming_management import ThematicTrimmingFormFields +from antarest.study.business.thematic_trimming_field_infos import ThematicTrimmingFormFields from antarest.study.business.timeseries_config_management import TSFormFields from antarest.study.model import PatchArea, PatchCluster from antarest.study.service import StudyService diff --git a/tests/integration/studies_blueprint/test_comments.py b/tests/integration/studies_blueprint/test_comments.py index b282ed8781..378be0aed5 100644 --- a/tests/integration/studies_blueprint/test_comments.py +++ b/tests/integration/studies_blueprint/test_comments.py @@ -88,7 +88,7 @@ def test_variant_study( res = client.post( f"/v1/studies/{base_study_id}/variants", headers={"Authorization": f"Bearer {user_access_token}"}, - params={"name": f"Variant XYZ"}, + params={"name": "Variant XYZ"}, ) assert res.status_code == 200, res.json() # should be CREATED variant_id = res.json() diff --git a/tests/integration/studies_blueprint/test_synthesis.py b/tests/integration/studies_blueprint/test_synthesis.py index 059fba2aa7..1f10fa2989 100644 --- a/tests/integration/studies_blueprint/test_synthesis.py +++ b/tests/integration/studies_blueprint/test_synthesis.py @@ -84,7 +84,7 @@ def test_variant_study( res = client.post( f"/v1/studies/{base_study_id}/variants", headers={"Authorization": f"Bearer {user_access_token}"}, - params={"name": f"Variant XYZ"}, + params={"name": "Variant XYZ"}, ) assert res.status_code == 200, res.json() # should be CREATED variant_id = res.json() diff --git a/tests/integration/test_integration.py b/tests/integration/test_integration.py index 6f0a72fde5..619c0de92b 100644 --- a/tests/integration/test_integration.py +++ b/tests/integration/test_integration.py @@ -882,74 +882,103 @@ def test_area_management(client: TestClient, admin_access_token: str, study_id: # Thematic trimming form - res_thematic_trimming_config = client.get( - f"/v1/studies/{study_id}/config/thematictrimming/form", headers=admin_headers - ) - res_thematic_trimming_config_json = res_thematic_trimming_config.json() - assert res_thematic_trimming_config_json == { - "ovCost": True, - "opCost": True, - "mrgPrice": True, - "co2Emis": True, - "dtgByPlant": True, + res = client.get(f"/v1/studies/{study_id}/config/thematictrimming/form", headers=admin_headers) + obj = res.json() + assert obj == { + "avlDtg": True, "balance": True, - "rowBal": True, - "psp": True, - "miscNdg": True, - "load": True, - "hRor": True, - "wind": True, - "solar": True, - "nuclear": True, - "lignite": True, + "batteryInjection": True, + "batteryLevel": True, + "batteryWithdrawal": True, + "co2Emis": True, "coal": True, + "congFeeAbs": True, + "congFeeAlg": True, + "congProbMinus": True, + "congProbPlus": True, + "dens": True, + "dtgByPlant": True, + "dtgMrg": True, + "flowLin": True, + "flowQuad": True, "gas": True, - "oil": True, - "mixFuel": True, - "miscDtg": True, - "hStor": True, - "hPump": True, - "hLev": True, + "hCost": True, "hInfl": True, + "hLev": True, "hOvfl": True, + "hPump": True, + "hRor": True, + "hStor": True, "hVal": True, - "hCost": True, - "unspEnrg": True, - "spilEnrg": True, + "hurdleCost": True, + "lignite": True, + "load": True, "lold": True, "lolp": True, - "avlDtg": True, - "dtgMrg": True, - "maxMrg": True, - "npCost": True, - "npCostByPlant": True, - "nodu": True, - "noduByPlant": True, - "flowLin": True, - "ucapLin": True, "loopFlow": True, - "flowQuad": True, - "congFeeAlg": True, - "congFeeAbs": True, "margCost": True, - "congProbPlus": True, - "congProbMinus": True, - "hurdleCost": True, - "resGenerationByPlant": True, + "maxMrg": True, + "miscDtg": True, "miscDtg2": True, "miscDtg3": True, "miscDtg4": True, - "windOffshore": True, - "windOnshore": True, - "solarConcrt": True, - "solarPv": True, - "solarRooft": True, + "miscNdg": True, + "mixFuel": True, + "mrgPrice": True, + "nodu": True, + "noduByPlant": True, + "npCost": True, + "npCostByPlant": True, + "nuclear": True, + "oil": True, + "opCost": True, + "other1Injection": True, + "other1Level": True, + "other1Withdrawal": True, + "other2Injection": True, + "other2Level": True, + "other2Withdrawal": True, + "other3Injection": True, + "other3Level": True, + "other3Withdrawal": True, + "other4Injection": True, + "other4Level": True, + "other4Withdrawal": True, + "other5Injection": True, + "other5Level": True, + "other5Withdrawal": True, + "ovCost": True, + "pondageInjection": True, + "pondageLevel": True, + "pondageWithdrawal": True, + "profitByPlant": True, + "psp": True, + "pspClosedInjection": True, + "pspClosedLevel": True, + "pspClosedWithdrawal": True, + "pspOpenInjection": True, + "pspOpenLevel": True, + "pspOpenWithdrawal": True, "renw1": True, "renw2": True, "renw3": True, "renw4": True, - "dens": True, - "profitByPlant": True, + "resGenerationByPlant": True, + "rowBal": True, + "solar": True, + "solarConcrt": True, + "solarPv": True, + "solarRooft": True, + "spilEnrg": True, + "stsCashflowByCluster": True, + "stsInjByPlant": True, + "stsLvlByPlant": True, + "stsWithdrawalByPlant": True, + "ucapLin": True, + "unspEnrg": True, + "wind": True, + "windOffshore": True, + "windOnshore": True, } client.put( @@ -1021,74 +1050,103 @@ def test_area_management(client: TestClient, admin_access_token: str, study_id: "profitByPlant": True, }, ) - res_thematic_trimming_config = client.get( - f"/v1/studies/{study_id}/config/thematictrimming/form", headers=admin_headers - ) - res_thematic_trimming_config_json = res_thematic_trimming_config.json() - assert res_thematic_trimming_config_json == { - "ovCost": False, - "opCost": True, - "mrgPrice": True, - "co2Emis": True, - "dtgByPlant": True, + res = client.get(f"/v1/studies/{study_id}/config/thematictrimming/form", headers=admin_headers) + obj = res.json() + assert obj == { + "avlDtg": True, "balance": True, - "rowBal": True, - "psp": True, - "miscNdg": True, - "load": True, - "hRor": True, - "wind": True, - "solar": True, - "nuclear": True, - "lignite": True, + "batteryInjection": True, + "batteryLevel": True, + "batteryWithdrawal": True, + "co2Emis": True, "coal": True, + "congFeeAbs": True, + "congFeeAlg": True, + "congProbMinus": True, + "congProbPlus": True, + "dens": True, + "dtgByPlant": True, + "dtgMrg": True, + "flowLin": True, + "flowQuad": True, "gas": True, - "oil": True, - "mixFuel": True, - "miscDtg": True, - "hStor": True, - "hPump": True, - "hLev": True, + "hCost": True, "hInfl": True, + "hLev": True, "hOvfl": True, - "hVal": False, - "hCost": True, - "unspEnrg": True, - "spilEnrg": True, + "hPump": True, + "hRor": True, + "hStor": True, + "hVal": True, + "hurdleCost": True, + "lignite": True, + "load": True, "lold": True, "lolp": True, - "avlDtg": True, - "dtgMrg": True, - "maxMrg": True, - "npCost": True, - "npCostByPlant": True, - "nodu": True, - "noduByPlant": True, - "flowLin": True, - "ucapLin": True, "loopFlow": True, - "flowQuad": True, - "congFeeAlg": True, - "congFeeAbs": True, "margCost": True, - "congProbPlus": True, - "congProbMinus": True, - "hurdleCost": True, - "resGenerationByPlant": True, + "maxMrg": True, + "miscDtg": True, "miscDtg2": True, "miscDtg3": True, "miscDtg4": True, - "windOffshore": True, - "windOnshore": True, - "solarConcrt": True, - "solarPv": True, - "solarRooft": True, + "miscNdg": True, + "mixFuel": True, + "mrgPrice": True, + "nodu": True, + "noduByPlant": True, + "npCost": True, + "npCostByPlant": True, + "nuclear": True, + "oil": True, + "opCost": True, + "other1Injection": True, + "other1Level": True, + "other1Withdrawal": True, + "other2Injection": True, + "other2Level": True, + "other2Withdrawal": True, + "other3Injection": True, + "other3Level": True, + "other3Withdrawal": True, + "other4Injection": True, + "other4Level": True, + "other4Withdrawal": True, + "other5Injection": True, + "other5Level": True, + "other5Withdrawal": True, + "ovCost": True, + "pondageInjection": True, + "pondageLevel": True, + "pondageWithdrawal": True, + "profitByPlant": True, + "psp": True, + "pspClosedInjection": True, + "pspClosedLevel": True, + "pspClosedWithdrawal": True, + "pspOpenInjection": True, + "pspOpenLevel": True, + "pspOpenWithdrawal": True, "renw1": True, - "renw2": False, + "renw2": True, "renw3": True, "renw4": True, - "dens": True, - "profitByPlant": True, + "resGenerationByPlant": True, + "rowBal": True, + "solar": True, + "solarConcrt": True, + "solarPv": True, + "solarRooft": True, + "spilEnrg": True, + "stsCashflowByCluster": True, + "stsInjByPlant": True, + "stsLvlByPlant": True, + "stsWithdrawalByPlant": True, + "ucapLin": True, + "unspEnrg": True, + "wind": True, + "windOffshore": True, + "windOnshore": True, } # Properties form diff --git a/tests/integration/test_integration_watcher.py b/tests/integration/test_integration_watcher.py index 0ac0e3afd0..e151a3ade3 100644 --- a/tests/integration/test_integration_watcher.py +++ b/tests/integration/test_integration_watcher.py @@ -8,11 +8,5 @@ def test_integration_xpansion(app: FastAPI, tmp_path: str): admin_credentials = res.json() headers = {"Authorization": f'Bearer {admin_credentials["access_token"]}'} - client.post( - f"/v1/watcher/_scan", - headers=headers, - ) - client.post( - f"/v1/watcher/_scan?path=/tmp", - headers=headers, - ) + client.post("/v1/watcher/_scan", headers=headers) + client.post("/v1/watcher/_scan?path=/tmp", headers=headers) diff --git a/tests/launcher/test_web.py b/tests/launcher/test_web.py index 99799abbde..e0800cf019 100644 --- a/tests/launcher/test_web.py +++ b/tests/launcher/test_web.py @@ -100,7 +100,7 @@ def test_jobs() -> None: assert res.status_code == 200 assert [JobResultDTO.parse_obj(j) for j in res.json()] == [result.to_dto()] - res = client.get(f"/v1/launcher/jobs") + res = client.get("/v1/launcher/jobs") assert res.status_code == 200 assert [JobResultDTO.parse_obj(j) for j in res.json()] == [result.to_dto()] service.get_jobs.assert_has_calls( diff --git a/tests/login/test_model.py b/tests/login/test_model.py index 2dee1d994e..e1ef0bc928 100644 --- a/tests/login/test_model.py +++ b/tests/login/test_model.py @@ -1,7 +1,4 @@ -import contextlib - from sqlalchemy.engine.base import Engine # type: ignore -from sqlalchemy.exc import IntegrityError # type: ignore from sqlalchemy.orm import sessionmaker # type: ignore from antarest.login.model import ( diff --git a/tests/login/test_repository.py b/tests/login/test_repository.py index 60bdbc0dbf..5ab7406dc4 100644 --- a/tests/login/test_repository.py +++ b/tests/login/test_repository.py @@ -1,5 +1,5 @@ import pytest -from sqlalchemy.orm import Session, scoped_session, sessionmaker # type: ignore +from sqlalchemy.orm import Session # type: ignore from antarest.login.model import Bot, Group, Password, Role, RoleType, User, UserLdap from antarest.login.repository import BotRepository, GroupRepository, RoleRepository, UserLdapRepository, UserRepository diff --git a/tests/storage/business/test_config_manager.py b/tests/storage/business/test_config_manager.py index 2e20aae081..f4d344a27d 100644 --- a/tests/storage/business/test_config_manager.py +++ b/tests/storage/business/test_config_manager.py @@ -1,8 +1,8 @@ from pathlib import Path from unittest.mock import Mock +from antarest.study.business.thematic_trimming_field_infos import FIELDS_INFO from antarest.study.business.thematic_trimming_management import ( - FIELDS_INFO, ThematicTrimmingFormFields, ThematicTrimmingManager, get_fields_info, @@ -112,4 +112,4 @@ def test_thematic_trimming_config() -> None: ) ) - assert len(FIELDS_INFO) == 63 + assert len(FIELDS_INFO) == 94 diff --git a/tests/storage/business/test_variant_study_service.py b/tests/storage/business/test_variant_study_service.py index 8c6ac3602c..7c6e00f99c 100644 --- a/tests/storage/business/test_variant_study_service.py +++ b/tests/storage/business/test_variant_study_service.py @@ -92,7 +92,7 @@ def task_status(*args): yield t study_service.task_service.status_task.side_effect = task_status() - with pytest.raises(VariantGenerationError, match=f"Error while generating study2.py"): + with pytest.raises(VariantGenerationError, match="Error while generating study2.py"): study_service.get(metadata=metadata, url=sub_route, depth=2) study_service.task_service.await_task.assert_called() diff --git a/tests/storage/repository/filesystem/test_lazy_node.py b/tests/storage/repository/filesystem/test_lazy_node.py index e0e8e91e5a..f899d32fa3 100644 --- a/tests/storage/repository/filesystem/test_lazy_node.py +++ b/tests/storage/repository/filesystem/test_lazy_node.py @@ -112,7 +112,7 @@ def test_save_uri(tmp_path: Path): context = ContextServer(matrix=Mock(), resolver=resolver) node = MockLazyNode(context=context, config=config) - uri = f"matrix://id" + uri = "matrix://id" node.save(uri) assert (file.parent / f"{file.name}.link").read_text() == uri assert not file.exists() diff --git a/tests/study/storage/variantstudy/test_snapshot_generator.py b/tests/study/storage/variantstudy/test_snapshot_generator.py index 5e90b6ee06..2365049432 100644 --- a/tests/study/storage/variantstudy/test_snapshot_generator.py +++ b/tests/study/storage/variantstudy/test_snapshot_generator.py @@ -10,7 +10,6 @@ import numpy as np import pytest -from sqlalchemy import event # type: ignore from antarest.core.exceptions import VariantGenerationError from antarest.core.interfaces.cache import CacheConstants diff --git a/tests/study/storage/variantstudy/test_variant_study_service.py b/tests/study/storage/variantstudy/test_variant_study_service.py index 25317a9589..9dce83e735 100644 --- a/tests/study/storage/variantstudy/test_variant_study_service.py +++ b/tests/study/storage/variantstudy/test_variant_study_service.py @@ -5,7 +5,6 @@ import numpy as np import pytest -from sqlalchemy import create_engine # type: ignore from antarest.core.model import PublicMode from antarest.core.requests import RequestParameters diff --git a/tests/variantstudy/model/command/test_create_cluster.py b/tests/variantstudy/model/command/test_create_cluster.py index 4fdeb3c488..6554bbe6c2 100644 --- a/tests/variantstudy/model/command/test_create_cluster.py +++ b/tests/variantstudy/model/command/test_create_cluster.py @@ -247,17 +247,17 @@ def test_create_diff(command_context: CommandContext): assert base.create_diff(other_match) == [ ReplaceMatrix( - target=f"input/thermal/prepro/foo/foo/data", + target="input/thermal/prepro/foo/foo/data", matrix=prepro_b, command_context=command_context, ), ReplaceMatrix( - target=f"input/thermal/prepro/foo/foo/modulation", + target="input/thermal/prepro/foo/foo/modulation", matrix=modulation_b, command_context=command_context, ), UpdateConfig( - target=f"input/thermal/clusters/foo/list/foo", + target="input/thermal/clusters/foo/list/foo", data={"nominalcapacity": "2400"}, command_context=command_context, ), diff --git a/tests/variantstudy/model/command/test_create_link.py b/tests/variantstudy/model/command/test_create_link.py index 413e97038d..b2e8715ae3 100644 --- a/tests/variantstudy/model/command/test_create_link.py +++ b/tests/variantstudy/model/command/test_create_link.py @@ -254,12 +254,12 @@ def test_create_diff(command_context: CommandContext): assert base.create_diff(other_match) == [ UpdateConfig( - target=f"input/links/bar/properties/foo", + target="input/links/bar/properties/foo", data=CreateLink.generate_link_properties({"hurdles-cost": "true"}), command_context=command_context, ), ReplaceMatrix( - target=f"@links_series/bar/foo", + target="@links_series/bar/foo", matrix=series_b, command_context=command_context, ), diff --git a/tests/variantstudy/model/command/test_create_renewables_cluster.py b/tests/variantstudy/model/command/test_create_renewables_cluster.py index fc6ac91afe..ecec2fd882 100644 --- a/tests/variantstudy/model/command/test_create_renewables_cluster.py +++ b/tests/variantstudy/model/command/test_create_renewables_cluster.py @@ -190,7 +190,7 @@ def test_create_diff(command_context: CommandContext): ) assert base.create_diff(other_match) == [ UpdateConfig( - target=f"input/renewables/clusters/foo/list/foo", + target="input/renewables/clusters/foo/list/foo", data={"a": "b"}, command_context=command_context, ), diff --git a/webapp/src/common/types.ts b/webapp/src/common/types.ts index 509ac4c4ff..7e62f614e4 100644 --- a/webapp/src/common/types.ts +++ b/webapp/src/common/types.ts @@ -414,6 +414,7 @@ export interface Area { filters_synthesis: string[]; filters_year: string[]; } + export interface Set { name?: string; inverted_set: boolean; @@ -447,6 +448,7 @@ export interface FileStudyTreeConfigDTO { archive_input_series: string[]; enr_modelling: string; } + export interface LinkElement { id: string; label: string; @@ -643,68 +645,3 @@ export interface TaskView { type: TaskType; status: string; } - -export interface ThematicTrimmingConfigDTO { - "OV. COST": boolean; - "OP. COST": boolean; - "MRG. PRICE": boolean; - "CO2 EMIS.": boolean; - "DTG by plant": boolean; - BALANCE: boolean; - "ROW BAL.": boolean; - PSP: boolean; - "MISC. NDG": boolean; - LOAD: boolean; - "H. ROR": boolean; - WIND: boolean; - SOLAR: boolean; - NUCLEAR: boolean; - LIGNITE: boolean; - COAL: boolean; - GAS: boolean; - OIL: boolean; - "MIX. FUEL": boolean; - "MISC. DTG": boolean; - "H. STOR": boolean; - "H. PUMP": boolean; - "H. LEV": boolean; - "H. INFL": boolean; - "H. OVFL": boolean; - "H. VAL": boolean; - "H. COST": boolean; - "UNSP. ENRG": boolean; - "SPIL. ENRG": boolean; - LOLD: boolean; - LOLP: boolean; - "AVL DTG": boolean; - "DTG MRG": boolean; - "MAX MRG": boolean; - "NP COST": boolean; - "NP Cost by plant": boolean; - NODU: boolean; - "NODU by plant": boolean; - "FLOW LIN.": boolean; - "UCAP LIN.": boolean; - "LOOP FLOW": boolean; - "FLOW QUAD.": boolean; - "CONG. FEE (ALG.)": boolean; - "CONG. FEE (ABS.)": boolean; - "MARG. COST": boolean; - "CONG. PROB +": boolean; - "CONG. PROB -": boolean; - "HURDLE COST": boolean; - // Study version >= 810 - "RES generation by plant"?: boolean; - "MISC. DTG 2"?: boolean; - "MISC. DTG 3"?: boolean; - "MISC. DTG 4"?: boolean; - "WIND OFFSHORE"?: boolean; - "WIND ONSHORE"?: boolean; - "SOLAR CONCRT."?: boolean; - "SOLAR PV"?: boolean; - "SOLAR ROOFT"?: boolean; - "RENW. 1"?: boolean; - "RENW. 2"?: boolean; - "RENW. 3"?: boolean; - "RENW. 4"?: boolean; -} diff --git a/webapp/src/components/App/Singlestudy/explore/Configuration/General/dialogs/ThematicTrimmingDialog/utils.ts b/webapp/src/components/App/Singlestudy/explore/Configuration/General/dialogs/ThematicTrimmingDialog/utils.ts index b16491ff6c..89569ba05c 100644 --- a/webapp/src/components/App/Singlestudy/explore/Configuration/General/dialogs/ThematicTrimmingDialog/utils.ts +++ b/webapp/src/components/App/Singlestudy/explore/Configuration/General/dialogs/ThematicTrimmingDialog/utils.ts @@ -51,7 +51,7 @@ export interface ThematicTrimmingFormFields { congProbPlus: boolean; congProbMinus: boolean; hurdleCost: boolean; - // For study versions >= 810 + // Study version >= 810 resGenerationByPlant?: boolean; miscDtg2?: boolean; miscDtg3?: boolean; @@ -65,9 +65,41 @@ export interface ThematicTrimmingFormFields { renw2?: boolean; renw3?: boolean; renw4?: boolean; - // For study versions >= 830 + // Study version >= 830 dens?: boolean; profitByPlant?: boolean; + // Study version >= 860 + stsInjByPlant?: boolean; + stsWithdrawalByPlant?: boolean; + stsLvlByPlant?: boolean; + stsCashflowByCluster?: boolean; + pspOpenInjection?: boolean; + pspOpenWithdrawal?: boolean; + pspOpenLevel?: boolean; + pspClosedInjection?: boolean; + pspClosedWithdrawal?: boolean; + pspClosedLevel?: boolean; + pondageInjection?: boolean; + pondageWithdrawal?: boolean; + pondageLevel?: boolean; + batteryInjection?: boolean; + batteryWithdrawal?: boolean; + batteryLevel?: boolean; + other1Injection?: boolean; + other1Withdrawal?: boolean; + other1Level?: boolean; + other2Injection?: boolean; + other2Withdrawal?: boolean; + other2Level?: boolean; + other3Injection?: boolean; + other3Withdrawal?: boolean; + other3Level?: boolean; + other4Injection?: boolean; + other4Withdrawal?: boolean; + other4Level?: boolean; + other5Injection?: boolean; + other5Withdrawal?: boolean; + other5Level?: boolean; } const keysMap: Record = { @@ -136,6 +168,38 @@ const keysMap: Record = { // Study version >= 830 dens: "DENS", profitByPlant: "Profit by plant", + // Study version >= 860 + stsInjByPlant: "STS inj by plant", + stsWithdrawalByPlant: "STS withdrawal by plant", + stsLvlByPlant: "STS lvl by plant", + stsCashflowByCluster: "STS Cashflow By Cluster", + pspOpenInjection: "PSP_open_injection", + pspOpenWithdrawal: "PSP_open_withdrawal", + pspOpenLevel: "PSP_open_level", + pspClosedInjection: "PSP_closed_injection", + pspClosedWithdrawal: "PSP_closed_withdrawal", + pspClosedLevel: "PSP_closed_level", + pondageInjection: "Pondage_injection", + pondageWithdrawal: "Pondage_withdrawal", + pondageLevel: "Pondage_level", + batteryInjection: "Battery_injection", + batteryWithdrawal: "Battery_withdrawal", + batteryLevel: "Battery_level", + other1Injection: "Other1_injection", + other1Withdrawal: "Other1_withdrawal", + other1Level: "Other1_level", + other2Injection: "Other2_injection", + other2Withdrawal: "Other2_withdrawal", + other2Level: "Other2_level", + other3Injection: "Other3_injection", + other3Withdrawal: "Other3_withdrawal", + other3Level: "Other3_level", + other4Injection: "Other4_injection", + other4Withdrawal: "Other4_withdrawal", + other4Level: "Other4_level", + other5Injection: "Other5_injection", + other5Withdrawal: "Other5_withdrawal", + other5Level: "Other5_level", }; // Allow to support all study versions by using directly the server config