Skip to content

Commit

Permalink
feat(api): fix typing and reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
salemsd committed Dec 16, 2024
1 parent c2a7aef commit 9d4bcf3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/antares/exceptions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,13 @@ def __init__(self, job_id: str, time_out: int) -> None:
self.message = f"Job {job_id} exceeded timeout of {time_out} seconds"
super().__init__(self.message)


class TaskTimeOutError(Exception):
def __init__(self, task_id: str, time_out: int) -> None:
self.message = f"Task {task_id} exceeded timeout of {time_out} seconds"
super().__init__(self.message)


class AntaresSimulationUnzipError(Exception):
def __init__(self, study_id: str, message: str) -> None:
self.message = f"Could not unzip simulation for study {study_id}: " + message
Expand Down
7 changes: 4 additions & 3 deletions src/antares/service/api_services/run_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
AntaresSimulationUnzipError,
APIError,
SimulationFailedError,
SimulationTimeOutError, TaskTimeOutError,
SimulationTimeOutError,
TaskTimeOutError,
)
from antares.model.simulation import AntaresSimulationParameters, Job, JobStatus
from antares.service.base_services import BaseRunService
Expand Down Expand Up @@ -77,7 +78,7 @@ def wait_job_completion(self, job: Job, time_out: int) -> None:

return None

def _update_job(self, job):
def _update_job(self, job: Job) -> None:
updated_job = self._get_job_from_id(job.job_id)
job.status = updated_job.status
job.output_id = updated_job.output_id
Expand Down Expand Up @@ -116,4 +117,4 @@ def _wait_task_completion(self, task_id: str, repeat_interval: int, time_out: in
time.sleep(repeat_interval)

if not task_result["success"]:
raise SimulationFailedError(self.study_id)
raise SimulationFailedError(self.study_id)
3 changes: 1 addition & 2 deletions tests/integration/test_web_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
from antares.model.settings.advanced_parameters import AdvancedParameters, UnitCommitmentMode
from antares.model.settings.general import GeneralParameters, Mode
from antares.model.settings.study_settings import PlaylistParameters, StudySettings
from antares.model.simulation import AntaresSimulationParameters, JobStatus, Job
from antares.model.st_storage import STStorageGroup, STStorageMatrixName, STStorageProperties
from antares.model.study import create_study_api, create_variant_api, read_study_api
from antares.model.thermal import ThermalClusterGroup, ThermalClusterProperties
Expand Down Expand Up @@ -510,4 +509,4 @@ def test_creation_lifecycle(self, antares_web: AntaresWebDesktop):
# assert job.status == JobStatus.SUCCESS
#
# assert job.output_id is not None
# assert job.unzip_output is True
# assert job.unzip_output is True

0 comments on commit 9d4bcf3

Please sign in to comment.