Skip to content

Commit

Permalink
Include analysis_type on inspection_result
Browse files Browse the repository at this point in the history
message beeing published at every inspection upload
  • Loading branch information
tsundvoll committed Nov 8, 2023
1 parent 5dad445 commit ab500ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/isar/apis/models/start_mission_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class InspectionTypes(str, Enum):
class StartMissionInspectionDefinition(BaseModel):
type: InspectionTypes = Field(default=InspectionTypes.image)
inspection_target: InputPosition
analysis_type: Optional[str] = None
duration: Optional[float] = None
metadata: Optional[dict] = None
id: Optional[str] = None
Expand Down
15 changes: 9 additions & 6 deletions src/isar/storage/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

from isar.config.settings import settings
from isar.models.communication.queues import Queues
from robot_interface.models.mission.mission import Mission
from isar.storage.storage_interface import StorageException, StorageInterface
from robot_interface.models.inspection.inspection import Inspection
from robot_interface.models.mission.mission import Mission
from robot_interface.telemetry.mqtt_client import MqttClientInterface
from robot_interface.utilities.json_service import EnhancedJSONEncoder

Expand Down Expand Up @@ -131,26 +131,29 @@ def _upload(self, upload_item: UploaderQueueItem) -> str:

def _process_upload_queue(self) -> None:
ready_items: List[UploaderQueueItem] = [
x for x in self._internal_upload_queue if x.is_ready_for_upload()
item for item in self._internal_upload_queue if item.is_ready_for_upload()
]
for item in ready_items:
inspection_path = self._upload(item)
self._publish_inspection_path(
self._publish_inspection_result(
inspection=item.inspection, inspection_path=inspection_path
)

def _publish_inspection_path(
def _publish_inspection_result(
self, inspection: Inspection, inspection_path: str
) -> None:
"""Publishes the image url to the MQTT Broker"""
"""Publishes the reference of the inspection result to the MQTT Broker
along with the analysis type
"""
if not self.mqtt_publisher:
return
payload: str = json.dumps(
{
"isar_id": settings.ISAR_ID,
"robot_name": settings.ROBOT_NAME,
"step_id": inspection.id,
"inspection_id": inspection.id,
"inspection_path": inspection_path,
"analysis_type": inspection.metadata.analysis_type,
"timestamp": datetime.utcnow(),
},
cls=EnhancedJSONEncoder,
Expand Down

0 comments on commit ab500ab

Please sign in to comment.