Skip to content

Commit

Permalink
fix: correcting errors told for #34
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdiwahada committed Dec 13, 2024
1 parent 45ccb1c commit 00db642
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/antares/exceptions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ def __init__(self, area_id: str, matrix_type: str, message: str) -> None:


class LinkUploadError(Exception):
def __init__(self, link_id: str, matrix_type: str, message: str) -> None:
self.message = f"Error uploading {matrix_type} matrix for link {link_id}: {message}"
def __init__(self, area_from_id: str, area_to_id: str, matrix_type: str, message: str) -> None:
self.message = f"Error uploading {matrix_type} matrix for link {area_from_id}/{area_to_id}: {message}"
super().__init__(self.message)


class LinkDownloadError(Exception):
def __init__(self, area_id: str, matrix_type: str, message: str):
self.message = f"Could not download {matrix_type} matrix for link {area_id}: {message}"
def __init__(self, area_from_id: str, area_to_id: str, matrix_type: str, message: str):
self.message = f"Could not download {matrix_type} matrix for link {area_from_id}/{area_to_id}: {message}"
super().__init__(self.message)


Expand Down
10 changes: 5 additions & 5 deletions src/antares/service/api_services/area_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,35 +363,35 @@ def create_load(self, area_id: str, series: pd.DataFrame) -> None:
raise MatrixUploadError(area_id, "load", f"Expected {expected_rows} rows and received {rows_number}.")
upload_series(self._base_url, self.study_id, self._wrapper, series, series_path)
except APIError as e:
raise MatrixUploadError(area_id, "load", e.message)
raise MatrixUploadError(area_id, "load", e.message) from e

def create_wind(self, area_id: str, series: pd.DataFrame) -> None:
try:
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)
raise MatrixUploadError(area_id, "wind", e.message) from e

def create_reserves(self, area_id: str, series: pd.DataFrame) -> None:
try:
series_path = f"input/reserves/{area_id}"
upload_series(self._base_url, self.study_id, self._wrapper, series, series_path)
except APIError as e:
raise MatrixUploadError(area_id, "reserves", e.message)
raise MatrixUploadError(area_id, "reserves", e.message) from e

def create_solar(self, area_id: str, series: pd.DataFrame) -> None:
try:
series_path = f"input/solar/series/solar_{area_id}"
upload_series(self._base_url, self.study_id, self._wrapper, series, series_path)
except APIError as e:
raise MatrixUploadError(area_id, "solar", e.message)
raise MatrixUploadError(area_id, "solar", e.message) from e

def create_misc_gen(self, area_id: str, series: pd.DataFrame) -> None:
try:
series_path = f"input/misc-gen/miscgen-{area_id}"
upload_series(self._base_url, self.study_id, self._wrapper, series, series_path)
except APIError as e:
raise MatrixUploadError(area_id, "misc-gen", e.message)
raise MatrixUploadError(area_id, "misc-gen", e.message) from e

def create_hydro(
self,
Expand Down
12 changes: 6 additions & 6 deletions src/antares/service/api_services/link_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def get_parameters(self, area_from: str, area_to: str) -> pd.DataFrame:
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
raise LinkDownloadError(area_from, area_to, "parameters", e.message) from e

return matrix

Expand All @@ -181,37 +181,37 @@ def create_parameters(self, series: pd.DataFrame, area_from: str, area_to: str)
series_path = f"input/links/{area_from}/{area_to}_parameters"
upload_series(self._base_url, self.study_id, self._wrapper, series, series_path)
except APIError as e:
raise LinkUploadError(f"{area_from}/{area_to}", "parameters", e.message) from e
raise LinkUploadError(area_from, area_to, "parameters", e.message) from e

def get_capacity_direct(self, area_from: str, area_to: str) -> pd.DataFrame:
try:
series_path = f"input/links/{area_from}/capacities/{area_to}_direct"
matrix = get_matrix(self._base_url, self.study_id, self._wrapper, series_path)
except APIError as e:
raise LinkDownloadError(f"{area_from}/{area_to}", "directcapacity", e.message) from e
raise LinkDownloadError(area_from, area_to, "directcapacity", e.message) from e
return matrix

def create_capacity_direct(self, series: pd.DataFrame, area_from: str, area_to: str) -> None:
try:
series_path = f"input/links/{area_from}/capacities/{area_to}_direct"
upload_series(self._base_url, self.study_id, self._wrapper, series, series_path)
except APIError as e:
raise LinkUploadError(f"{area_from}/{area_to}", "directcapacity", e.message) from e
raise LinkUploadError(area_from, area_to, "directcapacity", e.message) from e

def get_capacity_indirect(self, area_from: str, area_to: str) -> pd.DataFrame:
try:
series_path = f"input/links/{area_from}/capacities/{area_to}_indirect"
matrix = get_matrix(self._base_url, self.study_id, self._wrapper, series_path)
except APIError as e:
raise LinkDownloadError(f"{area_from}/{area_to}", "indirectcapacity", e.message) from e
raise LinkDownloadError(area_from, area_to, "indirectcapacity", e.message) from e
return matrix

def create_capacity_indirect(self, series: pd.DataFrame, area_from: str, area_to: str) -> None:
try:
series_path = f"input/links/{area_from}/capacities/{area_to}_indirect"
upload_series(self._base_url, self.study_id, self._wrapper, series, series_path)
except APIError as e:
raise LinkUploadError(f"{area_from}/{area_to}", "indirectcapacity", e.message) from e
raise LinkUploadError(area_from, area_to, "indirectcapacity", e.message) from e

def read_links(self) -> list[Link]:
raise NotImplementedError
Expand Down

0 comments on commit 00db642

Please sign in to comment.