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

Include analysis_type on inspection_result #501

Merged
merged 1 commit into from
Nov 8, 2023
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
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