isar 1.30.1__py3-none-any.whl → 1.30.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of isar might be problematic. Click here for more details.
- isar/config/settings.py +7 -26
- isar/modules.py +0 -7
- isar/robot/robot_start_mission.py +14 -2
- isar/robot/robot_status.py +5 -3
- isar/script.py +0 -1
- isar/state_machine/generic_states/idle.py +133 -0
- isar/state_machine/generic_states/ongoing_mission.py +294 -0
- isar/state_machine/generic_states/robot_unavailable.py +61 -0
- isar/state_machine/state_machine.py +9 -0
- isar/state_machine/states/await_next_mission.py +11 -83
- isar/state_machine/states/blocked_protective_stop.py +13 -39
- isar/state_machine/states/home.py +10 -78
- isar/state_machine/states/monitor.py +10 -242
- isar/state_machine/states/offline.py +11 -36
- isar/state_machine/states/paused.py +1 -1
- isar/state_machine/states/returning_home.py +14 -177
- isar/state_machine/states/robot_standing_still.py +11 -91
- isar/state_machine/transitions/mission.py +1 -1
- {isar-1.30.1.dist-info → isar-1.30.3.dist-info}/METADATA +18 -5
- {isar-1.30.1.dist-info → isar-1.30.3.dist-info}/RECORD +25 -24
- robot_interface/robot_interface.py +15 -7
- isar/config/settings.env +0 -23
- isar/storage/slimm_storage.py +0 -190
- {isar-1.30.1.dist-info → isar-1.30.3.dist-info}/WHEEL +0 -0
- {isar-1.30.1.dist-info → isar-1.30.3.dist-info}/entry_points.txt +0 -0
- {isar-1.30.1.dist-info → isar-1.30.3.dist-info}/licenses/LICENSE +0 -0
- {isar-1.30.1.dist-info → isar-1.30.3.dist-info}/top_level.txt +0 -0
isar/storage/slimm_storage.py
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import json
|
|
2
|
-
import logging
|
|
3
|
-
|
|
4
|
-
from azure.identity import DefaultAzureCredential
|
|
5
|
-
from dependency_injector.wiring import inject
|
|
6
|
-
from requests import HTTPError, RequestException
|
|
7
|
-
from requests_toolbelt import MultipartEncoder
|
|
8
|
-
|
|
9
|
-
from isar.config.settings import settings
|
|
10
|
-
from isar.services.auth.azure_credentials import AzureCredentials
|
|
11
|
-
from isar.services.service_connections.request_handler import RequestHandler
|
|
12
|
-
from isar.storage.storage_interface import StorageException, StorageInterface
|
|
13
|
-
from isar.storage.utilities import get_filename
|
|
14
|
-
from robot_interface.models.inspection.inspection import Inspection, ThermalVideo, Video
|
|
15
|
-
from robot_interface.models.mission.mission import Mission
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class SlimmStorage(StorageInterface):
|
|
19
|
-
@inject
|
|
20
|
-
def __init__(self, request_handler: RequestHandler) -> None:
|
|
21
|
-
self.request_handler: RequestHandler = request_handler
|
|
22
|
-
self.logger = logging.getLogger("uploader")
|
|
23
|
-
|
|
24
|
-
self.credentials: DefaultAzureCredential = (
|
|
25
|
-
AzureCredentials.get_azure_credentials()
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
client_id: str = settings.SLIMM_CLIENT_ID
|
|
29
|
-
scope: str = settings.SLIMM_APP_SCOPE
|
|
30
|
-
self.request_scope: str = f"{client_id}/{scope}"
|
|
31
|
-
|
|
32
|
-
self.url: str = settings.SLIMM_API_URL
|
|
33
|
-
|
|
34
|
-
def store(self, inspection: Inspection, mission: Mission) -> str:
|
|
35
|
-
filename: str = get_filename(
|
|
36
|
-
inspection=inspection,
|
|
37
|
-
)
|
|
38
|
-
filename = f"{filename}.{inspection.metadata.file_type}"
|
|
39
|
-
if type(inspection) in [Video, ThermalVideo]:
|
|
40
|
-
inspection_path = self._store_video(filename, inspection, mission)
|
|
41
|
-
else:
|
|
42
|
-
inspection_path = self._store_image(filename, inspection, mission)
|
|
43
|
-
return inspection_path
|
|
44
|
-
|
|
45
|
-
def _store_image(
|
|
46
|
-
self, filename: str, inspection: Inspection, mission: Mission
|
|
47
|
-
) -> str:
|
|
48
|
-
multiform_body: MultipartEncoder = self._construct_multiform_request_image(
|
|
49
|
-
filename=filename, inspection=inspection, mission=mission
|
|
50
|
-
)
|
|
51
|
-
request_url: str = f"{self.url}/UploadSingleImage"
|
|
52
|
-
inspection_path = self._ingest(
|
|
53
|
-
inspection=inspection,
|
|
54
|
-
multiform_body=multiform_body,
|
|
55
|
-
request_url=request_url,
|
|
56
|
-
)
|
|
57
|
-
return inspection_path
|
|
58
|
-
|
|
59
|
-
def _store_video(
|
|
60
|
-
self, filename: str, inspection: Inspection, mission: Mission
|
|
61
|
-
) -> str:
|
|
62
|
-
multiform_body: MultipartEncoder = self._construct_multiform_request_video(
|
|
63
|
-
filename=filename, inspection=inspection, mission=mission
|
|
64
|
-
)
|
|
65
|
-
request_url = f"{self.url}/UploadSingleVideo"
|
|
66
|
-
inspection_path = self._ingest(
|
|
67
|
-
inspection=inspection,
|
|
68
|
-
multiform_body=multiform_body,
|
|
69
|
-
request_url=request_url,
|
|
70
|
-
)
|
|
71
|
-
return inspection_path
|
|
72
|
-
|
|
73
|
-
def _ingest(
|
|
74
|
-
self,
|
|
75
|
-
inspection: Inspection,
|
|
76
|
-
multiform_body: MultipartEncoder,
|
|
77
|
-
request_url: str,
|
|
78
|
-
) -> str:
|
|
79
|
-
token: str = self.credentials.get_token(self.request_scope).token
|
|
80
|
-
try:
|
|
81
|
-
response = self.request_handler.post(
|
|
82
|
-
url=request_url,
|
|
83
|
-
data=multiform_body,
|
|
84
|
-
headers={
|
|
85
|
-
"Authorization": f"Bearer {token}",
|
|
86
|
-
"Content-Type": multiform_body.content_type,
|
|
87
|
-
},
|
|
88
|
-
)
|
|
89
|
-
guid = json.loads(response.text)["guid"]
|
|
90
|
-
self.logger.info("SLIMM upload GUID: %s", guid)
|
|
91
|
-
except (RequestException, HTTPError) as e:
|
|
92
|
-
self.logger.warning(
|
|
93
|
-
f"Failed to upload inspection: {inspection.id} to SLIMM due to a "
|
|
94
|
-
f"request exception"
|
|
95
|
-
)
|
|
96
|
-
raise StorageException from e
|
|
97
|
-
data = json.loads(response.content)
|
|
98
|
-
return data["guid"]
|
|
99
|
-
|
|
100
|
-
@staticmethod
|
|
101
|
-
def _construct_multiform_request_image(
|
|
102
|
-
filename: str, inspection: Inspection, mission: Mission
|
|
103
|
-
) -> MultipartEncoder:
|
|
104
|
-
array_of_orientation = (
|
|
105
|
-
inspection.metadata.robot_pose.orientation.to_quat_array().tolist()
|
|
106
|
-
)
|
|
107
|
-
multiform_body: MultipartEncoder = MultipartEncoder(
|
|
108
|
-
fields={
|
|
109
|
-
"PlantFacilitySAPCode": settings.PLANT_CODE,
|
|
110
|
-
"InstCode": settings.PLANT_SHORT_NAME,
|
|
111
|
-
"InternalClassification": settings.DATA_CLASSIFICATION,
|
|
112
|
-
"IsoCountryCode": "NO",
|
|
113
|
-
"Geodetic.CoordinateReferenceSystemCode": settings.COORDINATE_REFERENCE_SYSTEM, # noqa: E501
|
|
114
|
-
"Geodetic.VerticalCoordinateReferenceSystemCode": settings.VERTICAL_REFERENCE_SYSTEM, # noqa: E501
|
|
115
|
-
"Geodetic.OrientationReferenceSystem": settings.MEDIA_ORIENTATION_REFERENCE_SYSTEM, # noqa: E501
|
|
116
|
-
"SensorCarrier.SensorCarrierId": settings.ISAR_ID,
|
|
117
|
-
"SensorCarrier.ModelName": settings.ROBOT_TYPE,
|
|
118
|
-
"Mission.MissionId": mission.id,
|
|
119
|
-
"Mission.Client": "Equinor",
|
|
120
|
-
"ImageMetadata.Timestamp": inspection.metadata.start_time.isoformat(), # noqa: E501
|
|
121
|
-
"ImageMetadata.X": str(inspection.metadata.robot_pose.position.x),
|
|
122
|
-
"ImageMetadata.Y": str(inspection.metadata.robot_pose.position.y),
|
|
123
|
-
"ImageMetadata.Z": str(inspection.metadata.robot_pose.position.z),
|
|
124
|
-
"ImageMetadata.CameraOrientation1": str(array_of_orientation[0]),
|
|
125
|
-
"ImageMetadata.CameraOrientation2": str(array_of_orientation[1]),
|
|
126
|
-
"ImageMetadata.CameraOrientation3": str(array_of_orientation[2]),
|
|
127
|
-
"ImageMetadata.CameraOrientation4": str(array_of_orientation[3]),
|
|
128
|
-
"ImageMetadata.Description": (
|
|
129
|
-
inspection.metadata.inspection_description
|
|
130
|
-
if inspection.metadata.inspection_description
|
|
131
|
-
else "N/A"
|
|
132
|
-
),
|
|
133
|
-
"ImageMetadata.FunctionalLocation": (
|
|
134
|
-
inspection.metadata.tag_id # noqa: E501
|
|
135
|
-
if inspection.metadata.tag_id
|
|
136
|
-
else "N/A"
|
|
137
|
-
),
|
|
138
|
-
"Filename": filename,
|
|
139
|
-
"AttachedFile": (filename, inspection.data),
|
|
140
|
-
}
|
|
141
|
-
)
|
|
142
|
-
return multiform_body
|
|
143
|
-
|
|
144
|
-
@staticmethod
|
|
145
|
-
def _construct_multiform_request_video(
|
|
146
|
-
filename: str,
|
|
147
|
-
inspection: Inspection,
|
|
148
|
-
mission: Mission,
|
|
149
|
-
) -> MultipartEncoder:
|
|
150
|
-
array_of_orientation = (
|
|
151
|
-
inspection.metadata.robot_pose.orientation.to_quat_array().tolist()
|
|
152
|
-
)
|
|
153
|
-
multiform_body: MultipartEncoder = MultipartEncoder(
|
|
154
|
-
fields={
|
|
155
|
-
"PlantFacilitySAPCode": settings.PLANT_CODE,
|
|
156
|
-
"InstCode": settings.PLANT_SHORT_NAME,
|
|
157
|
-
"InternalClassification": settings.DATA_CLASSIFICATION,
|
|
158
|
-
"IsoCountryCode": "NO",
|
|
159
|
-
"Geodetic.CoordinateReferenceSystemCode": settings.COORDINATE_REFERENCE_SYSTEM, # noqa: E501
|
|
160
|
-
"Geodetic.VerticalCoordinateReferenceSystemCode": settings.VERTICAL_REFERENCE_SYSTEM, # noqa: E501
|
|
161
|
-
"Geodetic.OrientationReferenceSystem": settings.MEDIA_ORIENTATION_REFERENCE_SYSTEM, # noqa: E501
|
|
162
|
-
"SensorCarrier.SensorCarrierId": settings.ISAR_ID,
|
|
163
|
-
"SensorCarrier.ModelName": settings.ROBOT_TYPE,
|
|
164
|
-
"Mission.MissionId": mission.id,
|
|
165
|
-
"Mission.Client": "Equinor",
|
|
166
|
-
"VideoMetadata.Timestamp": inspection.metadata.start_time.isoformat(), # noqa: E501
|
|
167
|
-
# Converting to int because SLIMM expects an int, while we use floats in operations.
|
|
168
|
-
"VideoMetadata.Duration": str(int(inspection.metadata.duration)), # type: ignore
|
|
169
|
-
"VideoMetadata.X": str(inspection.metadata.robot_pose.position.x),
|
|
170
|
-
"VideoMetadata.Y": str(inspection.metadata.robot_pose.position.y),
|
|
171
|
-
"VideoMetadata.Z": str(inspection.metadata.robot_pose.position.z),
|
|
172
|
-
"VideoMetadata.CameraOrientation1": str(array_of_orientation[0]),
|
|
173
|
-
"VideoMetadata.CameraOrientation2": str(array_of_orientation[1]),
|
|
174
|
-
"VideoMetadata.CameraOrientation3": str(array_of_orientation[2]),
|
|
175
|
-
"VideoMetadata.CameraOrientation4": str(array_of_orientation[3]),
|
|
176
|
-
"VideoMetadata.Description": (
|
|
177
|
-
inspection.metadata.inspection_description
|
|
178
|
-
if inspection.metadata.inspection_description
|
|
179
|
-
else "N/A"
|
|
180
|
-
),
|
|
181
|
-
"VideoMetadata.FunctionalLocation": (
|
|
182
|
-
inspection.metadata.tag_id # noqa: E501
|
|
183
|
-
if inspection.metadata.tag_id
|
|
184
|
-
else "N/A"
|
|
185
|
-
),
|
|
186
|
-
"Filename": filename,
|
|
187
|
-
"AttachedFile": (filename, inspection.data),
|
|
188
|
-
}
|
|
189
|
-
)
|
|
190
|
-
return multiform_body
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|