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

feat(api): handle link matrices #34

Merged
merged 76 commits into from
Dec 13, 2024
Merged

feat(api): handle link matrices #34

merged 76 commits into from
Dec 13, 2024

Conversation

mehdiwahada
Copy link
Contributor

No description provided.

mehdiwahada and others added 30 commits November 26, 2024 14:53
src/antares/exceptions/exceptions.py Outdated Show resolved Hide resolved
src/antares/model/area.py Outdated Show resolved Hide resolved
def delete_area(self, area: Area) -> None:
self._area_service.delete_area(area)
self._areas.pop(area.id)
def delete_area(self, area_id: str) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Here I think we should still have an Area as an argument and then pass the id. It would be clearer for the user I believe


return link_ui

def read_links(self) -> list[Link]:
raise NotImplementedError
def get_parameters(self, area_from_id: str, area_to_id: str) -> pd.DataFrame:
Copy link
Contributor

Choose a reason for hiding this comment

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

We should choose between area_from_id and area_from between the 2 methods. I think we should type area_from_id as it's clearer

parameters_path = f"input/links/{area_from_id}/{area_to_id}_parameters"
matrix = get_matrix(self._base_url, self.study_id, self._wrapper, parameters_path)
except APIError as e:
raise LinkDownloadError(f"{area_from_id}/{area_to_id}", "parameters", e.message)
Copy link
Contributor

Choose a reason for hiding this comment

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

You should raise from e instead of giving the e.message. see other parts of the code

@abstractmethod
def create_parameters(self, series: pd.DataFrame, area_from: str, area_to: str) -> None:
"""
Args:
Copy link
Contributor

Choose a reason for hiding this comment

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

Either remove the args or fill them. I think you can remove them

tests/antares/services/api_services/test_link_api.py Outdated Show resolved Hide resolved
tests/integration/test_web_client.py Outdated Show resolved Hide resolved
tests/integration/test_web_client.py Outdated Show resolved Hide resolved
"""
Args:
area_to:
area_from:
Copy link
Contributor

Choose a reason for hiding this comment

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

Last comment about this unresolved

ui_response = AreaUiResponse.model_validate(json_ui)
area_ui = AreaUi.model_validate(ui_response.to_craft())

except APIError as e:
raise AreaUiUpdateError(area.id, e.message) from e
raise AreaUiUpdateError(area_id, e.message) from e

return area_ui

def delete_area(self, area: Area) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

The delete area should only get the area_id to be the same as the other methods. The delete inisde the sutdy.py gets an Area but calls the service with the id


return link_ui

def read_links(self) -> list[Link]:
raise NotImplementedError
def get_parameters(self, area_from: str, area_to_id: str) -> pd.DataFrame:
Copy link
Contributor

Choose a reason for hiding this comment

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

You forgot to rename area_to_id in area_to

parameters_path = f"input/links/{area_from}/{area_to_id}_parameters"
matrix = get_matrix(self._base_url, self.study_id, self._wrapper, parameters_path)
except APIError as e:
raise LinkDownloadError(f"{area_from}/{area_to_id}", "parameters", e.message) from e
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove the e.message as now you raise from e. Also remove it inside the exception class

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.

Last review :)

series_path = f"input/wind/series/wind_{area_id}"
upload_series(self._base_url, self.study_id, self._wrapper, series, series_path)
except APIError as e:
raise MatrixUploadError(area_id, "wind", e.message)
Copy link
Contributor

@MartinBelthle MartinBelthle Dec 13, 2024

Choose a reason for hiding this comment

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

you forgot to put back the from e at the end. This goes for the others methods inside this file

parameters_path = f"input/links/{area_from}/{area_to}_parameters"
matrix = get_matrix(self._base_url, self.study_id, self._wrapper, parameters_path)
except APIError as e:
raise LinkDownloadError(f"{area_from}/{area_to}", "parameters", e.message) from e
Copy link
Contributor

Choose a reason for hiding this comment

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

Last remark:
The exception class should expect area_form and to as parameter and do the area_from / area_to itself. This way a new user won't have to know how it's done to call the exception

@MartinBelthle MartinBelthle merged commit f04bf8b into main Dec 13, 2024
8 checks passed
@MartinBelthle MartinBelthle deleted the feat/add_link_methods branch December 13, 2024 13:51
mehdiwahada added a commit that referenced this pull request Dec 24, 2024
mehdiwahada added a commit that referenced this pull request Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants