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

Fix missing argument in mqtt.Client #515

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/isar/config/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ def configure_azure_handler(log_config: dict, keyvault: Keyvault) -> logging.Han
"application-insights-connection-string"
).value
except KeyvaultError:
message: str = f"CRITICAL ERROR: Missing connection string for Application Insights in key vault '{keyvault.name}'."
message: str = (
f"CRITICAL ERROR: Missing connection string for Application Insights in key vault '{keyvault.name}'."
)
print(f"\n{message} \n")
raise ConfigurationError(message)

Expand Down
2 changes: 1 addition & 1 deletion src/isar/services/service_connections/mqtt/mqtt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, mqtt_queue: Queue) -> None:

self.port: int = settings.MQTT_PORT

self.client: Client = Client()
self.client: Client = Client(mqtt.CallbackAPIVersion.VERSION1)

self.client.enable_logger(logger=self.logger)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,21 @@ def run(self) -> None:
robot_status=combined_status,
previous_robot_status=previous_robot_status,
current_isar_state=self.state_machine.current_state,
current_mission_id=self.state_machine.current_mission.id
if self.state_machine.current_mission
else None,
current_task_id=self.state_machine.current_task.id
if self.state_machine.current_task
else None,
current_step_id=self.state_machine.current_step.id
if self.state_machine.current_step
else None,
current_mission_id=(
self.state_machine.current_mission.id
if self.state_machine.current_mission
else None
),
current_task_id=(
self.state_machine.current_task.id
if self.state_machine.current_task
else None
),
current_step_id=(
self.state_machine.current_step.id
if self.state_machine.current_step
else None
),
timestamp=datetime.utcnow(),
)

Expand Down
18 changes: 9 additions & 9 deletions src/isar/state_machine/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ def publish_mission_status(self) -> None:
"mission_id": self.current_mission.id if self.current_mission else None,
"status": self.current_mission.status if self.current_mission else None,
"error_reason": error_message.error_reason if error_message else None,
"error_description": error_message.error_description
if error_message
else None,
"error_description": (
error_message.error_description if error_message else None
),
"timestamp": datetime.utcnow(),
},
cls=EnhancedJSONEncoder,
Expand Down Expand Up @@ -524,9 +524,9 @@ def publish_task_status(self, task: Task) -> None:
"task_id": task.id if task else None,
"status": task.status if task else None,
"error_reason": error_message.error_reason if error_message else None,
"error_description": error_message.error_description
if error_message
else None,
"error_description": (
error_message.error_description if error_message else None
),
"timestamp": datetime.utcnow(),
},
cls=EnhancedJSONEncoder,
Expand Down Expand Up @@ -558,9 +558,9 @@ def publish_step_status(self, step: Step) -> None:
"step_type": step.__class__.__name__ if step else None,
"status": step.status if step else None,
"error_reason": error_message.error_reason if error_message else None,
"error_description": error_message.error_description
if error_message
else None,
"error_description": (
error_message.error_description if error_message else None
),
"timestamp": datetime.utcnow(),
},
cls=EnhancedJSONEncoder,
Expand Down
6 changes: 3 additions & 3 deletions src/isar/state_machine/states/idle.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def stop(self) -> None:

def _run(self) -> None:
while True:
start_mission: Optional[
StartMissionMessage
] = self.state_machine.should_start_mission()
start_mission: Optional[StartMissionMessage] = (
self.state_machine.should_start_mission()
)
if start_mission:
self.state_machine.start_mission(
mission=start_mission.mission,
Expand Down
12 changes: 6 additions & 6 deletions src/isar/state_machine/states/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def _run(self) -> None:
)

try:
status: Union[
StepStatus, MissionStatus
] = self.step_status_thread.get_output()
status: Union[StepStatus, MissionStatus] = (
self.step_status_thread.get_output()
)
except ThreadedRequestNotFinishedError:
time.sleep(self.state_machine.sleep_time)
continue
Expand Down Expand Up @@ -145,9 +145,9 @@ def _queue_inspections_for_upload(
self, mission: Mission, current_step: InspectionStep
) -> None:
try:
inspections: Sequence[
Inspection
] = self.state_machine.robot.get_inspections(step=current_step)
inspections: Sequence[Inspection] = (
self.state_machine.robot.get_inspections(step=current_step)
)

except (RobotRetrieveInspectionException, RobotException) as e:
self._set_error_message(e)
Expand Down
40 changes: 22 additions & 18 deletions src/isar/storage/slimm_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,18 @@ def _construct_multiform_request_image(
"ImageMetadata.CameraOrientation2": str(array_of_orientation[1]),
"ImageMetadata.CameraOrientation3": str(array_of_orientation[2]),
"ImageMetadata.CameraOrientation4": str(array_of_orientation[3]),
"ImageMetadata.AnalysisMethods": inspection.metadata.additional[
"analysis_type"
]
if inspection.metadata.additional
and inspection.metadata.additional["analysis_type"]
else "N/A",
"ImageMetadata.AnalysisMethods": (
inspection.metadata.additional["analysis_type"]
if inspection.metadata.additional
and inspection.metadata.additional["analysis_type"]
else "N/A"
),
"ImageMetadata.Description": str(inspection.metadata.additional),
"ImageMetadata.FunctionalLocation": inspection.metadata.tag_id # noqa: E501
if inspection.metadata.tag_id
else "N/A",
"ImageMetadata.FunctionalLocation": (
inspection.metadata.tag_id # noqa: E501
if inspection.metadata.tag_id
else "N/A"
),
"Filename": filename,
"AttachedFile": (filename, inspection.data),
}
Expand Down Expand Up @@ -170,16 +172,18 @@ def _construct_multiform_request_video(
"VideoMetadata.CameraOrientation2": str(array_of_orientation[1]),
"VideoMetadata.CameraOrientation3": str(array_of_orientation[2]),
"VideoMetadata.CameraOrientation4": str(array_of_orientation[3]),
"VideoMetadata.AnalysisMethods": inspection.metadata.additional[
"analysis_type"
]
if inspection.metadata.additional
and inspection.metadata.additional["analysis_type"]
else "N/A",
"VideoMetadata.AnalysisMethods": (
inspection.metadata.additional["analysis_type"]
if inspection.metadata.additional
and inspection.metadata.additional["analysis_type"]
else "N/A"
),
"VideoMetadata.Description": str(inspection.metadata.additional),
"VideoMetadata.FunctionalLocation": inspection.metadata.tag_id # noqa: E501
if inspection.metadata.tag_id
else "N/A",
"VideoMetadata.FunctionalLocation": (
inspection.metadata.tag_id # noqa: E501
if inspection.metadata.tag_id
else "N/A"
),
"Filename": filename,
"AttachedFile": (filename, inspection.data),
}
Expand Down
8 changes: 5 additions & 3 deletions src/isar/storage/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ def construct_metadata_file(
"mission_date": datetime.utcnow().date(),
"isar_id": settings.ISAR_ID,
"robot_name": settings.ROBOT_NAME,
"analysis_type": inspection.metadata.additional["analysis_type"]
if inspection.metadata.additional
else "N/A",
"analysis_type": (
inspection.metadata.additional["analysis_type"]
if inspection.metadata.additional
else "N/A"
),
},
"data": [
{
Expand Down
Loading