Skip to content

Commit

Permalink
mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
killian-scalian committed Dec 18, 2024
1 parent d9d644c commit 3eeb0ad
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 188 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ scipy==1.10.1
antlr4-python3-runtime==4.13.1
PyYAML~=6.0.1
pydantic~=2.6.1
antares>=0.1.1
antares>=0.3.25
7 changes: 4 additions & 3 deletions src/andromede/input_converter/src/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# This file is part of the Antares project.
from pathlib import Path
from antares.model.study import Study
from antares.model.study import Study # type: ignore
from typing import Optional
from pydantic import BaseModel
from andromede.study.parsing import InputComponents
Expand All @@ -30,9 +30,10 @@ def __init__(self, study_path: Optional[Path]):
self.study_path = resolve_path(study_path) if study_path else None
self.study: Study = None

def convert_study_to_input_components(self) -> BaseModel:
def convert_study_to_input_components(self) -> InputComponents:
areas = self.study.read_areas()
return convert_area_to_components(areas)
area_components = convert_area_to_components(areas)
return InputComponents(nodes=area_components)

def validate_with_pydantic(
self, data: dict, model_class: type[BaseModel]
Expand Down
164 changes: 0 additions & 164 deletions src/andromede/input_converter/src/main.py

This file was deleted.

30 changes: 13 additions & 17 deletions src/andromede/input_converter/src/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pathlib import Path
from antares.model.area import Area
from antares.model.area import Area # type: ignore
from andromede.study.parsing import (
InputComponent,
InputComponents,
Expand All @@ -17,15 +17,11 @@ def resolve_path(path_str: Path) -> Path:
return absolute_path


def convert_area_to_components(areas: list[Area]) -> BaseModel:
return InputComponents(
nodes=[InputComponent(id=area.id, model="area") for area in areas],
components=[],
connections=[],
)
def convert_area_to_components(areas: list[Area]) -> list[InputComponent]:
return [InputComponent(id=area.id, model="area") for area in areas]


def convert_renewable_to_components(area: Area) -> list:
def convert_renewable_to_components(area: Area) -> list[InputComponent]:
renewables = area.read_renewables()
return [
InputComponent(
Expand All @@ -44,7 +40,7 @@ def convert_renewable_to_components(area: Area) -> list:
),
InputComponentParameter(
name=renewable.id,
type="timeserie",
type="timeseries",
timeseries=str(renewable.get_timeseries()),
),
],
Expand All @@ -53,33 +49,33 @@ def convert_renewable_to_components(area: Area) -> list:
]


def convert_hydro_to_components(area: Area) -> list:
def convert_hydro_to_components(area: Area) -> list[InputComponent]:
raise NotImplementedError


def convert_st_storages_to_components(area: Area) -> list:
def convert_st_storages_to_components(area: Area) -> list[InputComponent]:
raise NotImplementedError


def convert_thermals_to_components(area: Area) -> list:
def convert_thermals_to_components(area: Area) -> list[InputComponent]:
raise NotImplementedError


def convert_load_matrix_to_components(area: Area) -> list:
def convert_load_matrix_to_components(area: Area) -> list[InputComponent]:
raise NotImplementedError


def convert_misc_gen_to_components(area: Area) -> list:
def convert_misc_gen_to_components(area: Area) -> list[InputComponent]:
raise NotImplementedError


def convert_reserves_matrix_to_components(area: Area) -> list:
def convert_reserves_matrix_to_components(area: Area) -> list[InputComponent]:
raise NotImplementedError


def convert_wind_matrix_to_components(area: Area) -> list:
def convert_wind_matrix_to_components(area: Area) -> list[InputComponent]:
raise NotImplementedError


def convert_solar_matrix_to_components(area: Area) -> list:
def convert_solar_matrix_to_components(area: Area) -> list[InputComponent]:
raise NotImplementedError
9 changes: 6 additions & 3 deletions tests/input_converter/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
# This file is part of the Antares project.


from andromede.input_converter.src.utils import convert_area_to_components
from andromede.input_converter.src.utils import convert_area_to_components
from andromede.input_converter.src.converter import StudyConverter
from andromede.study.parsing import InputComponent, InputComponents


class TestConverter:
def test_convert_area_to_input_components(self, local_study_w_areas):
areas = local_study_w_areas.read_areas()
area_components = convert_area_to_components(areas)
converter = StudyConverter(study_path=None)
converter.study = local_study_w_areas
area_components = converter.convert_study_to_input_components()
expected_area_components = InputComponents(
nodes=[
InputComponent(id="it", model="area", parameters=None),
Expand All @@ -27,4 +29,5 @@ def test_convert_area_to_input_components(self, local_study_w_areas):
components=[],
connections=[],
)

assert area_components == expected_area_components

0 comments on commit 3eeb0ad

Please sign in to comment.