Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into fix/fix-endpoint-links…
Browse files Browse the repository at this point in the history
…-creation
  • Loading branch information
TheoPascoli committed Sep 25, 2024
2 parents 0c002d9 + 9c94118 commit 26d382e
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 36 deletions.
2 changes: 1 addition & 1 deletion antarest/study/business/area_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ClusterInfoDTO(PatchCluster):
name: str
enabled: bool = True
unitcount: int = 0
nominalcapacity: int = 0
nominalcapacity: float = 0
group: t.Optional[str] = None
min_stable_power: t.Optional[int] = None
min_up_time: t.Optional[int] = None
Expand Down
14 changes: 0 additions & 14 deletions antarest/study/business/xpansion_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
from antarest.study.business.all_optional_meta import all_optional_model
from antarest.study.business.enum_ignore_case import EnumIgnoreCase
from antarest.study.model import Study
from antarest.study.storage.rawstudy.model.filesystem.bucket_node import BucketNode
from antarest.study.storage.rawstudy.model.filesystem.factory import FileStudy
from antarest.study.storage.rawstudy.model.filesystem.folder_node import FolderNode
from antarest.study.storage.rawstudy.model.filesystem.root.user.expansion.expansion import Expansion
from antarest.study.storage.storage_service import StudyStorageService
from antarest.study.storage.utils import fix_study_root

Expand Down Expand Up @@ -715,17 +712,6 @@ def list_resources(self, study: Study, resource_type: XpansionResourceFileType)
except ChildNotFoundError:
return []

def list_root_files(self, study: Study) -> t.List[str]:
logger.info(f"Getting xpansion root resources file from study '{study.id}'")
file_study = self.study_storage_service.get_storage(study).get_raw(study)
registered_filenames = [registered_file.key for registered_file in Expansion.registered_files]
root_files = [
key
for key, node in t.cast(FolderNode, file_study.tree.get_node(["user", "expansion"])).build().items()
if key not in registered_filenames and not isinstance(node, BucketNode)
]
return root_files

@staticmethod
def _is_constraints_file_used(file_study: FileStudy, filename: str) -> bool: # type: ignore
with contextlib.suppress(KeyError):
Expand Down
2 changes: 1 addition & 1 deletion antarest/study/web/studies_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def get_studies(
exists: t.Optional[bool] = Query(None, description="Filter studies based on their existence on disk."),
workspace: str = Query("", description="Filter studies based on their workspace."),
folder: str = Query("", description="Filter studies based on their folder."),
sort_by: t.Optional[StudySortBy] = Query(
sort_by: StudySortBy = Query(
None,
description="Sort studies based on their name (case-insensitive) or creation date.",
alias="sortBy",
Expand Down
6 changes: 3 additions & 3 deletions antarest/study/web/study_data_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def create_study_data_routes(study_service: StudyService, config: Config) -> API
)
def get_areas(
uuid: str,
type: t.Optional[AreaType] = None,
type: AreaType = Query(None),
ui: bool = False,
current_user: JWTUser = Depends(auth.get_current_user),
) -> t.Union[t.List[AreaInfoDTO], t.Dict[str, t.Any]]:
Expand Down Expand Up @@ -1095,10 +1095,10 @@ def update_version(
def get_binding_constraint_list(
uuid: str,
enabled: t.Optional[bool] = Query(None, description="Filter results based on enabled status"),
operator: t.Optional[BindingConstraintOperator] = Query(None, description="Filter results based on operator"),
operator: BindingConstraintOperator = Query(None, description="Filter results based on operator"),
comments: str = Query("", description="Filter results based on comments (word match)"),
group: str = Query("", description="filter binding constraints based on group name (exact match)"),
time_step: t.Optional[BindingConstraintFrequency] = Query(
time_step: BindingConstraintFrequency = Query(
None,
description="Filter results based on time step",
alias="timeStep",
Expand Down
4 changes: 1 addition & 3 deletions antarest/study/web/xpansion_studies_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def get_resource_content(
)
def list_resources(
uuid: str,
resource_type: t.Optional[XpansionResourceFileType] = None,
resource_type: XpansionResourceFileType,
current_user: JWTUser = Depends(auth.get_current_user),
) -> t.Any:
logger.info(
Expand All @@ -304,8 +304,6 @@ def list_resources(
StudyPermissionType.READ,
RequestParameters(user=current_user),
)
if resource_type is None:
return study_service.xpansion_manager.list_root_files(study)
return study_service.xpansion_manager.list_resources(study, resource_type)

return bp
6 changes: 3 additions & 3 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def test_area_management(client: TestClient, admin_access_token: str) -> None:
"args": {
"area_id": "area 2",
"cluster_name": "cluster 2",
"parameters": {},
"parameters": {"nominalcapacity": 2.5},
},
}
],
Expand Down Expand Up @@ -566,7 +566,7 @@ def test_area_management(client: TestClient, admin_access_token: str) -> None:
"min-stable-power": None,
"min-up-time": None,
"name": "cluster 2",
"nominalcapacity": 0,
"nominalcapacity": 2.5,
"spinning": None,
"spread-cost": None,
"type": None,
Expand Down Expand Up @@ -1478,7 +1478,7 @@ def test_area_management(client: TestClient, admin_access_token: str) -> None:
"min-stable-power": None,
"min-up-time": None,
"name": "cluster 2",
"nominalcapacity": 0,
"nominalcapacity": 2.5,
"spinning": None,
"spread-cost": None,
"type": None,
Expand Down
11 changes: 0 additions & 11 deletions tests/storage/business/test_xpansion_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,17 +512,6 @@ def test_add_resources(tmp_path: Path) -> None:
xpansion_manager.delete_resource(study, XpansionResourceFileType.WEIGHTS, filename3)


@pytest.mark.unit_test
def test_list_root_resources(tmp_path: Path) -> None:
empty_study, study, xpansion_manager = set_up_xpansion_manager(tmp_path)

constraints_file_content = b"0"
constraints_file_name = "unknownfile.txt"

empty_study.tree.save({"user": {"expansion": {constraints_file_name: constraints_file_content}}})
assert [constraints_file_name] == xpansion_manager.list_root_files(study)


@pytest.mark.unit_test
def test_get_single_constraints(tmp_path: Path) -> None:
empty_study, study, xpansion_manager = set_up_xpansion_manager(tmp_path)
Expand Down

0 comments on commit 26d382e

Please sign in to comment.