Skip to content

Commit

Permalink
Fix currentSiteStage function
Browse files Browse the repository at this point in the history
Fix new error handling
  • Loading branch information
OleDrange committed Jun 13, 2023
1 parent fef64d4 commit 71d64f5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/isar_exr/api/energy_robotics_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,16 @@ def get_current_site_stage(self, site_id: str) -> str:

params: dict = {"siteId": site_id}

response_dict: dict[str, Any] = self.client.query(
dsl_gql(current_site_stage_query), params
)

return response_dict["currentSiteStage"]["id"]
try:
response_dict: dict[str, Any] = self.client.query(
dsl_gql(current_site_stage_query), params
)
except Exception as e:
message: str = "Could not get current site stage"
self.logger.error(message)
raise RobotAPIException(
error_description=message,
)
if response_dict["currentSiteStage"] is not None:
return response_dict["currentSiteStage"]["id"]
return None
3 changes: 3 additions & 0 deletions src/isar_exr/robotinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def __init__(self) -> None:
)

def initiate_mission(self, mission: Mission) -> None:
curent_stage_id = self.api.get_current_site_stage(settings.ROBOT_EXR_SITE_ID)
if curent_stage_id is not None:
self.api.discard_stage(stage_id=curent_stage_id)
stage_id: str = self.api.create_stage(site_id=settings.ROBOT_EXR_SITE_ID)
poi_ids: List[str] = []
for task in mission.tasks:
Expand Down

0 comments on commit 71d64f5

Please sign in to comment.