isar 1.30.1__py3-none-any.whl → 1.30.2__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 CHANGED
@@ -12,15 +12,6 @@ from robot_interface.telemetry.payloads import DocumentInfo
12
12
 
13
13
 
14
14
  class Settings(BaseSettings):
15
- def __init__(self) -> None:
16
- try:
17
- source = files("isar").joinpath("config").joinpath("settings.env")
18
- with as_file(source) as eml:
19
- env_file = eml
20
- except ModuleNotFoundError:
21
- env_file = None
22
- super().__init__(_env_file=env_file)
23
-
24
15
  # Determines which robot package ISAR will attempt to import
25
16
  # Name must match with an installed python package in the local environment
26
17
  ROBOT_PACKAGE: str = Field(default="isar_robot")
@@ -98,7 +89,6 @@ class Settings(BaseSettings):
98
89
  # Selecting a different storage module than local may require certain access rights
99
90
  STORAGE_LOCAL_ENABLED: bool = Field(default=True)
100
91
  STORAGE_BLOB_ENABLED: bool = Field(default=False)
101
- STORAGE_SLIMM_ENABLED: bool = Field(default=False)
102
92
 
103
93
  # Determines whether the MQTT publishing module should be enabled or not
104
94
  # The publishing module will attempt to connect to the MQTT broker configured in
@@ -153,21 +143,6 @@ class Settings(BaseSettings):
153
143
  # Name of blob container in Azure Blob Storage [slimm test]
154
144
  BLOB_CONTAINER: str = Field(default="test")
155
145
 
156
- # Client ID for SLIMM App Registration
157
- SLIMM_CLIENT_ID: str = Field(default="c630ca4d-d8d6-45ab-8cc6-68a363d0de9e")
158
-
159
- # Scope for access to SLIMM Ingestion API
160
- SLIMM_APP_SCOPE: str = Field(default=".default")
161
-
162
- # URL for SLIMM endpoint
163
- SLIMM_API_URL: str = Field(
164
- default="https://scinspectioningestapitest.azurewebsites.net/Ingest"
165
- )
166
-
167
- # Whether the results should be copied directly into the SLIMM datalake or only the
168
- # metadata
169
- COPY_FILES_TO_SLIMM_DATALAKE: bool = Field(default=False)
170
-
171
146
  # The configuration of this section is tightly coupled with the metadata that is
172
147
  # submitted with the results once they have been uploaded.
173
148
 
@@ -298,7 +273,12 @@ class Settings(BaseSettings):
298
273
  )
299
274
 
300
275
 
301
- load_dotenv()
276
+ env = os.environ.get("ISAR_ENV")
277
+
278
+ if env == "test":
279
+ load_dotenv(".env.test", override=True)
280
+ else:
281
+ load_dotenv()
302
282
  settings = Settings()
303
283
 
304
284
 
isar/modules.py CHANGED
@@ -14,13 +14,11 @@ from isar.mission_planner.sequential_task_selector import SequentialTaskSelector
14
14
  from isar.mission_planner.task_selector_interface import TaskSelectorInterface
15
15
  from isar.models.communication.queues.events import Events, SharedState
16
16
  from isar.robot.robot import Robot
17
- from isar.services.service_connections.request_handler import RequestHandler
18
17
  from isar.services.utilities.robot_utilities import RobotUtilities
19
18
  from isar.services.utilities.scheduling_utilities import SchedulingUtilities
20
19
  from isar.state_machine.state_machine import StateMachine
21
20
  from isar.storage.blob_storage import BlobStorage
22
21
  from isar.storage.local_storage import LocalStorage
23
- from isar.storage.slimm_storage import SlimmStorage
24
22
  from isar.storage.uploader import Uploader
25
23
  from robot_interface.telemetry.mqtt_client import MqttPublisher
26
24
 
@@ -77,11 +75,6 @@ class ApplicationContainer(containers.DeclarativeContainer):
77
75
  if settings.STORAGE_BLOB_ENABLED:
78
76
  blob_storage = providers.Singleton(BlobStorage, keyvault=keyvault)
79
77
  storage_handlers_temp.append(blob_storage)
80
- if settings.STORAGE_SLIMM_ENABLED:
81
- slimm_storage = providers.Singleton(
82
- SlimmStorage, request_handler=providers.Singleton(RequestHandler)
83
- )
84
- storage_handlers_temp.append(slimm_storage)
85
78
  storage_handlers = providers.List(*storage_handlers_temp)
86
79
 
87
80
  # Mqtt client
@@ -48,7 +48,7 @@ class RobotStartMissionThread(Thread):
48
48
  )
49
49
 
50
50
  if retries >= settings.INITIATE_FAILURE_COUNTER_LIMIT:
51
- error_description = (
51
+ self.logger.error(
52
52
  f"Mission will be cancelled after failing to initiate "
53
53
  f"{settings.INITIATE_FAILURE_COUNTER_LIMIT} times because: "
54
54
  f"{e.error_description}"
@@ -58,7 +58,7 @@ class RobotStartMissionThread(Thread):
58
58
  self.robot_service_events.mission_failed,
59
59
  ErrorMessage(
60
60
  error_reason=e.error_reason,
61
- error_description=error_description,
61
+ error_description=e.error_description,
62
62
  ),
63
63
  )
64
64
  break
isar/script.py CHANGED
@@ -68,7 +68,6 @@ def print_startup_info():
68
68
  print_setting("Mission planner", settings.MISSION_PLANNER)
69
69
  print_setting("Using local storage", settings.STORAGE_LOCAL_ENABLED)
70
70
  print_setting("Using blob storage", settings.STORAGE_BLOB_ENABLED)
71
- print_setting("Using SLIMM storage", settings.STORAGE_SLIMM_ENABLED)
72
71
  print_setting("Using async inspection uploading", settings.UPLOAD_INSPECTIONS_ASYNC)
73
72
  print_setting("Plant code", settings.PLANT_CODE)
74
73
  print_setting("Plant name", settings.PLANT_NAME)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: isar
3
- Version: 1.30.1
3
+ Version: 1.30.2
4
4
  Summary: Integration and Supervisory control of Autonomous Robots
5
5
  Author-email: Equinor ASA <fg_robots_dev@equinor.com>
6
6
  License: Eclipse Public License version 2.0
@@ -132,7 +132,6 @@ Requires-Dist: isort; extra == "dev"
132
132
  Requires-Dist: mypy; extra == "dev"
133
133
  Requires-Dist: pip-tools; extra == "dev"
134
134
  Requires-Dist: pre-commit; extra == "dev"
135
- Requires-Dist: pytest-dotenv; extra == "dev"
136
135
  Requires-Dist: pytest-mock; extra == "dev"
137
136
  Requires-Dist: pytest-xdist; extra == "dev"
138
137
  Requires-Dist: pytest; extra == "dev"
@@ -236,7 +235,7 @@ ISAR_DEFAULT_MAP = turtleworld
236
235
  To run ISAR:
237
236
 
238
237
  ```bash
239
- python main.py
238
+ isar-start
240
239
  ```
241
240
 
242
241
  Note, running the full system requires that an implementation of a robot has been installed. See
@@ -281,6 +280,20 @@ There are two methods of specifying configuration.
281
280
  By adding environment variables with the prefix `ISAR_` to the [settings.env](./src/isar/config/settings.env) file
282
281
  the configuration variables will be overwritten by the values in this file.
283
282
 
283
+ ### Setup for testing
284
+ To be able to execute the tests you need to set the `ISAR_ENV` environment variable beforehand. Depending on your operating system and the command line you are using you can use one of the following commands:
285
+
286
+ **Bash/Zsh**
287
+ ```bash
288
+ export ISAR_ENV=test
289
+ ```
290
+ **Windows Command prompt**
291
+ ```cmd
292
+ set ISAR_ENV=test
293
+ ```
294
+
295
+ Remember to set `ISAR_ENV` back to `None` when you want to run `isar-start` afterwards.
296
+
284
297
  ### Running tests
285
298
 
286
299
  After following the steps in [Development](#install), you can run the tests:
@@ -375,10 +388,10 @@ overriding the configuration through an environment variable. It accepts a json
375
388
  in the list to retrieve the corresponding handler. The current options are
376
389
 
377
390
  ```
378
- ISAR_STORAGE = '["local", "blob", "slimm"]'
391
+ ISAR_STORAGE = '["local", "blob"]'
379
392
  ```
380
393
 
381
- Note that the `blob` and `slimm` options require special configuration to authenticate to these endpoints.
394
+ Note that the `blob` option requires special configuration to authenticate to these endpoints.
382
395
 
383
396
  ### Implement your own storage module
384
397
 
@@ -1,6 +1,6 @@
1
1
  isar/__init__.py,sha256=cH8p8bVveu3FUL6kBhldcSlLaoHgD82Kd0-SwSNfGXw,87
2
- isar/modules.py,sha256=CO3Ikr3evmlNk7-EXfcdafATxaXVtSd-I1Dzr3uHpts,5095
3
- isar/script.py,sha256=VOI4nSEObDj53cSAFfzVBFDMwbu20uOsUZLZYyDZfBE,6083
2
+ isar/modules.py,sha256=73cB5KgYUURsNR2bps1aVUXNY7gv6HHQyZ3qwnFpbJA,4742
3
+ isar/script.py,sha256=mcZGMkIbUKkdLY5CwQOO16HSLlNJZRFaozAppmTMfTQ,6010
4
4
  isar/apis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  isar/apis/api.py,sha256=1-RmRH7NReCpOo_NSwP5hS2lDQm6_Dx2ZWe2460GhJY,13770
6
6
  isar/apis/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -15,8 +15,7 @@ isar/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  isar/config/configuration_error.py,sha256=rO6WOhafX6xvVib8WxV-eY483Z0PpN-9PxGsq5ATfKc,46
16
16
  isar/config/log.py,sha256=SzEWbzXU1DpN7YONIRT8k0zBOGm_qVkXlJuuZtb8STc,2300
17
17
  isar/config/logging.conf,sha256=mYO1xf27gAopEMHhGzY7-mwyfN16rwRLkPNMvy3zn2g,1127
18
- isar/config/settings.env,sha256=cLIlcXTM8x0N-6XjXmC0Qclx5dfDC6myqa25tvVwmRw,500
19
- isar/config/settings.py,sha256=IM1T8rIo7DaOvLRlrgtftgdJ0cGohn52ByP-ZRD3AB8,13115
18
+ isar/config/settings.py,sha256=IYnL8aMOIlEIKzVMtJVFM1LlNlNdmW-VxiEEvvnhcqk,12324
20
19
  isar/config/certs/ca-cert.pem,sha256=qoNljfad_qcMxhXJIUMLd7nT-Qwf_d4dYSdoOFEOE8I,2179
21
20
  isar/config/keyvault/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
21
  isar/config/keyvault/keyvault_error.py,sha256=zvPCsZLjboxsxthYkxpRERCTFxYV8R5WmACewAUQLwk,41
@@ -51,7 +50,7 @@ isar/models/communication/queues/queue_utils.py,sha256=wg6bIR3NS35Ek9hnGR5eN8z6i
51
50
  isar/models/communication/queues/status_queue.py,sha256=on8kvlNsG6MJjEVsyqtBswIpmOdOggQiKr7F5x0T3jw,514
52
51
  isar/models/mission_metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
53
52
  isar/robot/robot.py,sha256=h-Z_1xCACekHvaj-vPJAhdzixSlcW4zMpe9__ui0zv8,5490
54
- isar/robot/robot_start_mission.py,sha256=QcNtGwM8ukf6iL3830AwAnBszmVDSgYe2J_xaFYLP0g,2860
53
+ isar/robot/robot_start_mission.py,sha256=jTTTAA_S3fIdzN57BsfVm_kgDzZZNMCn9UY5MkEncu8,2859
55
54
  isar/robot/robot_status.py,sha256=j5fGq5FzpEscmqUL6i8jRWCZEJ56b2g_DUpAgWpE1YI,1935
56
55
  isar/robot/robot_stop_mission.py,sha256=jUyfemvbyigxrlIp9aKPn-PvarhagJEgajQPS_LgJ7g,2442
57
56
  isar/robot/robot_task_status.py,sha256=71SYPnoqaFbTe1bELLTvAUigAJ-McpomC2sjYQNQs_A,3290
@@ -99,11 +98,10 @@ isar/state_machine/transitions/functions/utils.py,sha256=Wa72Ocq4QT1E6qkpEJZQ3h5
99
98
  isar/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
100
99
  isar/storage/blob_storage.py,sha256=Qci6bO508nlTHKPuPtVU5QcvGA4T7mv8cFrKWRcfw4g,3226
101
100
  isar/storage/local_storage.py,sha256=Bnmoi5gyN8r-oRh0aHrOdGqaH3JqRScFKMRXYojW5kY,1855
102
- isar/storage/slimm_storage.py,sha256=DwrryuiddMf5eRmjt3Di0f1GuoTG2faQTfRh378GHu0,8796
103
101
  isar/storage/storage_interface.py,sha256=DYDry4I7aZpDHJhsBF6s8zrgokFAc7fdKJKfA8AvL7o,828
104
102
  isar/storage/uploader.py,sha256=HAC3ssuPQCQ1xH4aTQfHIaq-ZoEzKwONWmsAOpNXOzw,9523
105
103
  isar/storage/utilities.py,sha256=oLH0Rp7UtrQQdilfITnmXO1Z0ExdeDhBImYHid55vBA,3449
106
- isar-1.30.1.dist-info/licenses/LICENSE,sha256=3fc2-ebLwHWwzfQbulGNRdcNob3SBQeCfEVUDYxsuqw,14058
104
+ isar-1.30.2.dist-info/licenses/LICENSE,sha256=3fc2-ebLwHWwzfQbulGNRdcNob3SBQeCfEVUDYxsuqw,14058
107
105
  robot_interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
108
106
  robot_interface/robot_interface.py,sha256=9I6c_7Qi8lOwb8M96p12iX2KwrRhcAXz1Ug_tnBEKcU,7821
109
107
  robot_interface/test_robot_interface.py,sha256=FV1urn7SbsMyWBIcTKjsBwAG4IsXeZ6pLHE0mA9EGGs,692
@@ -127,8 +125,8 @@ robot_interface/telemetry/payloads.py,sha256=78EVedDyRhYIquwXWdwjhA3RntMboCcuPWE
127
125
  robot_interface/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
128
126
  robot_interface/utilities/json_service.py,sha256=qkzVkb60Gi_pto-b5n1vNzCrQze2yqgIJqSLNLYj1Fg,1034
129
127
  robot_interface/utilities/uuid_string_factory.py,sha256=_NQIbBQ56w0qqO0MUDP6aPpHbxW7ATRhK8HnQiBSLkc,76
130
- isar-1.30.1.dist-info/METADATA,sha256=xUgD7-Nd_NsYwXuICFQcwldiAqSfrw8cMwJ3-hLQpb4,30709
131
- isar-1.30.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
132
- isar-1.30.1.dist-info/entry_points.txt,sha256=TFam7uNNw7J0iiDYzsH2gfG0u1eV1wh3JTw_HkhgKLk,49
133
- isar-1.30.1.dist-info/top_level.txt,sha256=UwIML2RtuQKCyJJkatcSnyp6-ldDjboB9k9JgKipO-U,21
134
- isar-1.30.1.dist-info/RECORD,,
128
+ isar-1.30.2.dist-info/METADATA,sha256=olWUSdkBtmv0INgMAqJYIS3IB7VzBdCMQ96SH3Z8lZ4,31063
129
+ isar-1.30.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
130
+ isar-1.30.2.dist-info/entry_points.txt,sha256=TFam7uNNw7J0iiDYzsH2gfG0u1eV1wh3JTw_HkhgKLk,49
131
+ isar-1.30.2.dist-info/top_level.txt,sha256=UwIML2RtuQKCyJJkatcSnyp6-ldDjboB9k9JgKipO-U,21
132
+ isar-1.30.2.dist-info/RECORD,,
isar/config/settings.env DELETED
@@ -1,23 +0,0 @@
1
- ISAR_ROBOT_PACKAGE = isar_robot
2
-
3
- ISAR_STORAGE_LOCAL_ENABLED = true
4
- ISAR_STORAGE_BLOB_ENABLED = false
5
- ISAR_STORAGE_SLIMM_ENABLED = false
6
-
7
- ISAR_LOG_HANDLER_LOCAL_ENABLED = true
8
- ISAR_LOG_HANDLER_APPLICATION_INSIGHTS_ENABLED = false
9
-
10
- ISAR_MQTT_ENABLED = true
11
- ISAR_MQTT_SSL_ENABLED = true
12
-
13
- ISAR_AUTHENTICATION_ENABLED = true
14
-
15
- ISAR_PLANT_SHORT_NAME = HUA
16
-
17
- ISAR_API_HOST_VIEWED_EXTERNALLY = 0.0.0.0
18
-
19
- ISAR_MQTT_USERNAME = isar
20
- ISAR_MQTT_HOST = localhost
21
- ISAR_MQTT_PORT = 1883
22
-
23
- ISAR_KEYVAULT_NAME = IsarDevKv
@@ -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