isar 1.32.1__py3-none-any.whl → 1.32.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 CHANGED
@@ -89,6 +89,9 @@ class Settings(BaseSettings):
89
89
  # Determines how long delay time should be allowed before returning home
90
90
  RETURN_HOME_DELAY: int = Field(default=10)
91
91
 
92
+ # Sets how many times the robot should try to return home if a return home fails
93
+ RETURN_HOME_RETRY_LIMIT: int = Field(default=5)
94
+
92
95
  # Determines which mission planner module is used by ISAR
93
96
  MISSION_PLANNER: str = Field(default="local")
94
97
 
@@ -20,6 +20,7 @@ if TYPE_CHECKING:
20
20
  class ReturningHome(EventHandlerBase):
21
21
 
22
22
  def __init__(self, state_machine: "StateMachine"):
23
+ self.failed_return_home_attemps: int = 0
23
24
  events = state_machine.events
24
25
 
25
26
  def _handle_task_completed(status: TaskStatus):
@@ -28,7 +29,9 @@ class ReturningHome(EventHandlerBase):
28
29
  error_reason=ErrorReason.RobotActionException,
29
30
  error_description="Return home failed.",
30
31
  )
32
+ self.failed_return_home_attemps += 1
31
33
  return state_machine.return_home_failed # type: ignore
34
+
32
35
  return state_machine.returned_home # type: ignore
33
36
 
34
37
  def _start_mission_event_handler(
@@ -5,8 +5,9 @@ if TYPE_CHECKING:
5
5
 
6
6
  from typing import TYPE_CHECKING
7
7
 
8
+ from isar.config.settings import settings
8
9
  from robot_interface.models.mission.mission import Mission
9
- from robot_interface.models.mission.status import MissionStatus, TaskStatus
10
+ from robot_interface.models.mission.status import MissionStatus, RobotStatus, TaskStatus
10
11
  from robot_interface.models.mission.task import ReturnToHome
11
12
 
12
13
  if TYPE_CHECKING:
@@ -23,6 +24,21 @@ def start_return_home_mission(state_machine: "StateMachine") -> bool:
23
24
  return True
24
25
 
25
26
 
27
+ def should_retry_return_home(state_machine: "StateMachine") -> bool:
28
+ if state_machine.shared_state.robot_status.check() != RobotStatus.Available:
29
+ return False
30
+
31
+ return (
32
+ state_machine.returning_home_state.failed_return_home_attemps
33
+ < settings.RETURN_HOME_RETRY_LIMIT
34
+ )
35
+
36
+
37
+ def reset_return_home_failure_counter(state_machine: "StateMachine") -> bool:
38
+ state_machine.returning_home_state.failed_return_home_attemps = 0
39
+ return True
40
+
41
+
26
42
  def set_return_home_status(state_machine: "StateMachine") -> bool:
27
43
  state_machine.log_mission_overview(mission=state_machine.current_mission)
28
44
  state_machine.current_mission.status = MissionStatus.InProgress
@@ -5,8 +5,10 @@ from isar.state_machine.transitions.functions.fail_mission import (
5
5
  report_failed_return_home_and_intervention_needed,
6
6
  )
7
7
  from isar.state_machine.transitions.functions.return_home import (
8
+ reset_return_home_failure_counter,
8
9
  return_home_finished,
9
10
  set_return_home_status,
11
+ should_retry_return_home,
10
12
  start_return_home_mission,
11
13
  )
12
14
  from isar.state_machine.transitions.functions.start_mission import (
@@ -34,6 +36,7 @@ def get_return_home_transitions(state_machine: "StateMachine") -> List[dict]:
34
36
  def_transition(state_machine, start_return_home_mission),
35
37
  def_transition(state_machine, set_return_home_status),
36
38
  def_transition(state_machine, initialize_robot),
39
+ def_transition(state_machine, initialize_robot),
37
40
  ],
38
41
  "before": def_transition(state_machine, trigger_start_mission_event),
39
42
  },
@@ -59,7 +62,25 @@ def get_return_home_transitions(state_machine: "StateMachine") -> List[dict]:
59
62
  "trigger": "returned_home",
60
63
  "source": state_machine.returning_home_state,
61
64
  "dest": state_machine.home_state,
62
- "before": def_transition(state_machine, return_home_finished),
65
+ "before": [
66
+ def_transition(state_machine, reset_return_home_failure_counter),
67
+ def_transition(state_machine, return_home_finished),
68
+ ],
69
+ },
70
+ {
71
+ "trigger": "return_home_failed",
72
+ "source": state_machine.returning_home_state,
73
+ "dest": state_machine.returning_home_state,
74
+ "conditions": [
75
+ def_transition(state_machine, should_retry_return_home),
76
+ ],
77
+ "before": [
78
+ def_transition(state_machine, report_failed_mission_and_finalize),
79
+ def_transition(state_machine, start_return_home_mission),
80
+ def_transition(state_machine, set_return_home_status),
81
+ def_transition(state_machine, initialize_robot),
82
+ def_transition(state_machine, trigger_start_mission_event),
83
+ ],
63
84
  },
64
85
  {
65
86
  "trigger": "return_home_failed",
@@ -69,6 +90,7 @@ def get_return_home_transitions(state_machine: "StateMachine") -> List[dict]:
69
90
  def_transition(
70
91
  state_machine, report_failed_return_home_and_intervention_needed
71
92
  ),
93
+ def_transition(state_machine, reset_return_home_failure_counter),
72
94
  def_transition(state_machine, report_failed_mission_and_finalize),
73
95
  ],
74
96
  },
@@ -3,34 +3,49 @@ from pathlib import Path
3
3
  from typing import Union
4
4
 
5
5
  from azure.core.exceptions import ResourceExistsError
6
- from azure.storage.blob import BlobClient, BlobServiceClient, ContainerClient
6
+ from azure.storage.blob import BlobServiceClient
7
7
 
8
8
  from isar.config.keyvault.keyvault_service import Keyvault
9
9
  from isar.config.settings import settings
10
10
  from isar.storage.storage_interface import StorageException, StorageInterface
11
11
  from isar.storage.utilities import construct_metadata_file, construct_paths
12
- from robot_interface.models.inspection.inspection import Inspection
12
+ from robot_interface.models.inspection.inspection import InspectionBlob
13
13
  from robot_interface.models.mission.mission import Mission
14
14
 
15
15
 
16
16
  class BlobStorage(StorageInterface):
17
- def __init__(
18
- self, keyvault: Keyvault, container_name: str = settings.BLOB_CONTAINER
19
- ) -> None:
20
- self.keyvault = keyvault
21
- self.storage_connection_string = self.keyvault.get_secret(
17
+ def __init__(self, keyvault: Keyvault) -> None:
18
+ self.logger = logging.getLogger("uploader")
19
+
20
+ storage_connection_string = keyvault.get_secret(
22
21
  "AZURE-STORAGE-CONNECTION-STRING"
23
22
  ).value
24
- self.container_name = container_name
25
23
 
26
- self.blob_service_client = self._get_blob_service_client()
27
- self.container_client = self._get_container_client(
28
- blob_service_client=self.blob_service_client
24
+ if storage_connection_string is None:
25
+ raise RuntimeError("AZURE-STORAGE-CONNECTION-STRING from keyvault is None")
26
+
27
+ try:
28
+ blob_service_client = BlobServiceClient.from_connection_string(
29
+ storage_connection_string
30
+ )
31
+ except Exception as e:
32
+ self.logger.error("Unable to retrieve blob service client. Error: %s", e)
33
+ raise e
34
+
35
+ self.container_client = blob_service_client.get_container_client(
36
+ settings.BLOB_CONTAINER
29
37
  )
30
38
 
31
- self.logger = logging.getLogger("uploader")
39
+ if not self.container_client.exists():
40
+ raise RuntimeError(
41
+ "The configured blob container %s does not exist",
42
+ settings.BLOB_CONTAINER,
43
+ )
44
+
45
+ def store(self, inspection: InspectionBlob, mission: Mission) -> Union[str, dict]:
46
+ if inspection.data is None:
47
+ raise StorageException("Nothing to store. The inspection data is empty")
32
48
 
33
- def store(self, inspection: Inspection, mission: Mission) -> Union[str, dict]:
34
49
  data_path, metadata_path = construct_paths(
35
50
  inspection=inspection, mission=mission
36
51
  )
@@ -43,7 +58,7 @@ class BlobStorage(StorageInterface):
43
58
  return self._upload_file(path=data_path, data=inspection.data)
44
59
 
45
60
  def _upload_file(self, path: Path, data: bytes) -> Union[str, dict]:
46
- blob_client = self._get_blob_client(path)
61
+ blob_client = self.container_client.get_blob_client(path.as_posix())
47
62
  try:
48
63
  blob_client.upload_blob(data=data)
49
64
  except ResourceExistsError as e:
@@ -62,20 +77,3 @@ class BlobStorage(StorageInterface):
62
77
  "blob_name": blob_client.blob_name,
63
78
  }
64
79
  return absolute_inspection_path
65
-
66
- def _get_blob_service_client(self) -> BlobServiceClient:
67
- try:
68
- return BlobServiceClient.from_connection_string(
69
- self.storage_connection_string
70
- )
71
- except Exception as e:
72
- self.logger.error("Unable to retrieve blob service client. Error: %s", e)
73
- raise e
74
-
75
- def _get_container_client(
76
- self, blob_service_client: BlobServiceClient
77
- ) -> ContainerClient:
78
- return blob_service_client.get_container_client(self.container_name)
79
-
80
- def _get_blob_client(self, path_to_blob: Path) -> BlobClient:
81
- return self.container_client.get_blob_client(path_to_blob.as_posix())
@@ -4,7 +4,7 @@ from pathlib import Path
4
4
  from isar.config.settings import settings
5
5
  from isar.storage.storage_interface import StorageException, StorageInterface
6
6
  from isar.storage.utilities import construct_metadata_file, construct_paths
7
- from robot_interface.models.inspection.inspection import Inspection
7
+ from robot_interface.models.inspection.inspection import InspectionBlob
8
8
  from robot_interface.models.mission.mission import Mission
9
9
 
10
10
 
@@ -13,7 +13,10 @@ class LocalStorage(StorageInterface):
13
13
  self.root_folder: Path = Path(settings.LOCAL_STORAGE_PATH)
14
14
  self.logger = logging.getLogger("uploader")
15
15
 
16
- def store(self, inspection: Inspection, mission: Mission) -> str:
16
+ def store(self, inspection: InspectionBlob, mission: Mission) -> str:
17
+ if inspection.data is None:
18
+ raise StorageException("Nothing to store. The inspection data is empty")
19
+
17
20
  local_path, local_metadata_path = construct_paths(
18
21
  inspection=inspection, mission=mission
19
22
  )
@@ -1,19 +1,19 @@
1
1
  from abc import ABCMeta, abstractmethod
2
2
  from typing import Union
3
3
 
4
- from robot_interface.models.inspection.inspection import Inspection
4
+ from robot_interface.models.inspection.inspection import InspectionBlob
5
5
  from robot_interface.models.mission.mission import Mission
6
6
 
7
7
 
8
8
  class StorageInterface(metaclass=ABCMeta):
9
9
  @abstractmethod
10
- def store(self, inspection: Inspection, mission: Mission) -> Union[str, dict]:
10
+ def store(self, inspection: InspectionBlob, mission: Mission) -> Union[str, dict]:
11
11
  """
12
12
  Parameters
13
13
  ----------
14
14
  mission : Mission
15
15
  Mission the inspection is a part of.
16
- inspection : Inspection
16
+ inspection : InspectionBlob
17
17
  The inspection object to be stored.
18
18
 
19
19
  Returns
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: isar
3
- Version: 1.32.1
3
+ Version: 1.32.3
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
@@ -16,7 +16,7 @@ isar/config/configuration_error.py,sha256=rO6WOhafX6xvVib8WxV-eY483Z0PpN-9PxGsq5
16
16
  isar/config/log.py,sha256=f_mLLz5RSa0kZkdpi1m0iMdwwDc4RQp12mnT6gu2exE,1303
17
17
  isar/config/logging.conf,sha256=a7ZBvZkrMDaPU3eRGAjL_eZz6hZsa6BaRJOfx8mbnnM,629
18
18
  isar/config/open_telemetry.py,sha256=965IlPi7urVTL0Yy4uYu4e1P2Ne6HC_RXizM2vCX9kY,2371
19
- isar/config/settings.py,sha256=dRQwL6qCnFoyJkMiBxzVv_JwTfs8UJTnuPnwPlQFhUM,13187
19
+ isar/config/settings.py,sha256=LTY_1ReDOaIpCH_B3s3Jzz7CniZBE7upYUOKkW5gd3g,13325
20
20
  isar/config/certs/ca-cert.pem,sha256=qoNljfad_qcMxhXJIUMLd7nT-Qwf_d4dYSdoOFEOE8I,2179
21
21
  isar/config/keyvault/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
22
  isar/config/keyvault/keyvault_error.py,sha256=zvPCsZLjboxsxthYkxpRERCTFxYV8R5WmACewAUQLwk,41
@@ -72,30 +72,30 @@ isar/state_machine/states/intervention_needed.py,sha256=A0QYz1vD1tDKAealihXDuoGu
72
72
  isar/state_machine/states/monitor.py,sha256=366CZSEf1HRVqpm0RkFjIDGnc_9fjeer7qwu1fvbcKQ,3670
73
73
  isar/state_machine/states/offline.py,sha256=5wdNzC1wG0cWrpuT_r_mk8UNFHA4QSyg8ejXUTAg4Io,1137
74
74
  isar/state_machine/states/paused.py,sha256=osmLZhm0-2jcZmNRauveeidCBYayDZvLy-1TNYv6CgQ,1091
75
- isar/state_machine/states/returning_home.py,sha256=6NEszX7phRN46ST25YFZZja75Z1RHSswWSv7V1-26wU,3424
75
+ isar/state_machine/states/returning_home.py,sha256=xs6iWrscar3rWiLejJUy3kTfE-w2ak52gDHLMYX8k30,3527
76
76
  isar/state_machine/states/robot_standing_still.py,sha256=78W465FlVBCTUpmjQHzO5MT7fI6_M8Rh9gS-M8Y9irs,1903
77
77
  isar/state_machine/states/stopping.py,sha256=fMXXvcXtzML-Q5A-uRD_gXePy51fnt9jhOTVFN-3qqA,2420
78
78
  isar/state_machine/states/unknown_status.py,sha256=Y-g9cgme5zriyZ6YUzFRYhOvv9ZylCSwfaY8MJ7xEJ0,1791
79
79
  isar/state_machine/transitions/mission.py,sha256=mUOtEyK2UX_kdK-_L4wq5a60882H2KnlxImO72YMtuo,5557
80
- isar/state_machine/transitions/return_home.py,sha256=Vy_Q_mmTj4wsWL8qxUkmC1CTXEzGsdKNYb4V4rw2IeE,3202
80
+ isar/state_machine/transitions/return_home.py,sha256=AAkpCBMlnHolwtlz-GQQcB9_DzzJqVKTD9UR1-uzZgI,4237
81
81
  isar/state_machine/transitions/robot_status.py,sha256=c1ceyWRGCtx-KTDtxHXRD7oPbt8TQ2ej24A0wyim8vc,2720
82
82
  isar/state_machine/transitions/functions/fail_mission.py,sha256=jHHXhfQVYQEzCXgTEhv5e6uEK9p6iDPFFXqS9bzs_-A,720
83
83
  isar/state_machine/transitions/functions/finish_mission.py,sha256=TRQrk7HdllmAkwsp25HRZAFAk46Y1hLx3jmkIAKrHDI,1442
84
84
  isar/state_machine/transitions/functions/pause.py,sha256=gWr-s76gL0-otrZxCBNmTxUicrAVsdNWDQmHSAOvs6E,1977
85
85
  isar/state_machine/transitions/functions/resume.py,sha256=ji4GjQvQQCr_jYRUGYHSYt-vePtO2z7VAUeKF-hyLBw,2106
86
- isar/state_machine/transitions/functions/return_home.py,sha256=UlniwYvpz74hxqgN0TyVv3LCmiMsqsosKEtEGLqkNj0,1139
86
+ isar/state_machine/transitions/functions/return_home.py,sha256=5WPO40MtuRKm9-NtyrS6m0IVEit14MXfMKjgZ2sCXRU,1666
87
87
  isar/state_machine/transitions/functions/robot_status.py,sha256=P1Cu8xVysbiKRKL4E8mSyoL2-72HfxrLvvOcdnBOlvw,889
88
88
  isar/state_machine/transitions/functions/start_mission.py,sha256=PcD9ANNN3Hxyq6hzvpISMiR94-y1BPNupU-wlRysqT8,2581
89
89
  isar/state_machine/transitions/functions/stop.py,sha256=ZG33TK3VuJwT-LAQ0a3thgt714yCIu42_bo-u1-V1J0,2956
90
90
  isar/state_machine/transitions/functions/utils.py,sha256=Wa72Ocq4QT1E6qkpEJZQ3h5o33pGvx7Tlkt2JZ2Grbk,314
91
91
  isar/state_machine/utils/common_event_handlers.py,sha256=hyzOvj5EA4Ob9DjbtbnPKge_t6Umd0_Cc-b6wfy8CP8,5777
92
92
  isar/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
93
- isar/storage/blob_storage.py,sha256=D67y3Z939iXoRxs8npOuKOhgs2o6dYz2ivTm5IXXhJE,3168
94
- isar/storage/local_storage.py,sha256=Bnmoi5gyN8r-oRh0aHrOdGqaH3JqRScFKMRXYojW5kY,1855
95
- isar/storage/storage_interface.py,sha256=DYDry4I7aZpDHJhsBF6s8zrgokFAc7fdKJKfA8AvL7o,828
93
+ isar/storage/blob_storage.py,sha256=QueyHzCJfUUyOLxBeYwK0Ot7w_CYakBEhtTtITelKAo,3026
94
+ isar/storage/local_storage.py,sha256=-9Bz2WmniLKwKMeAdrgoMzkj781AOLIUsfaqQERqpUk,1985
95
+ isar/storage/storage_interface.py,sha256=DRIiy0mRZL3KMZysG0R2Cque6hoqd5haZBw11WM53Vc,840
96
96
  isar/storage/uploader.py,sha256=uD1DzvJ2yYtNAwQGa7UD7kNOxZfKxJ1cCdi7sfOVZ10,9443
97
97
  isar/storage/utilities.py,sha256=oLH0Rp7UtrQQdilfITnmXO1Z0ExdeDhBImYHid55vBA,3449
98
- isar-1.32.1.dist-info/licenses/LICENSE,sha256=3fc2-ebLwHWwzfQbulGNRdcNob3SBQeCfEVUDYxsuqw,14058
98
+ isar-1.32.3.dist-info/licenses/LICENSE,sha256=3fc2-ebLwHWwzfQbulGNRdcNob3SBQeCfEVUDYxsuqw,14058
99
99
  robot_interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
100
100
  robot_interface/robot_interface.py,sha256=-jCAKkZ2eiyzUyHVQmOzw4hMgLWR7pE8MHj-WZo85ZY,7978
101
101
  robot_interface/test_robot_interface.py,sha256=FV1urn7SbsMyWBIcTKjsBwAG4IsXeZ6pLHE0mA9EGGs,692
@@ -119,8 +119,8 @@ robot_interface/telemetry/payloads.py,sha256=Fqkfv77_T2Ttk5EjWRU5HH0XAxFhIuz7k-L
119
119
  robot_interface/utilities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
120
120
  robot_interface/utilities/json_service.py,sha256=qkzVkb60Gi_pto-b5n1vNzCrQze2yqgIJqSLNLYj1Fg,1034
121
121
  robot_interface/utilities/uuid_string_factory.py,sha256=_NQIbBQ56w0qqO0MUDP6aPpHbxW7ATRhK8HnQiBSLkc,76
122
- isar-1.32.1.dist-info/METADATA,sha256=AOF9icV4ETW8Ddolnlh6hQzjWm1B_3Z9Go1B4q3WfOQ,31217
123
- isar-1.32.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
124
- isar-1.32.1.dist-info/entry_points.txt,sha256=TFam7uNNw7J0iiDYzsH2gfG0u1eV1wh3JTw_HkhgKLk,49
125
- isar-1.32.1.dist-info/top_level.txt,sha256=UwIML2RtuQKCyJJkatcSnyp6-ldDjboB9k9JgKipO-U,21
126
- isar-1.32.1.dist-info/RECORD,,
122
+ isar-1.32.3.dist-info/METADATA,sha256=M8uIww8u8xCTsjqhdGmJjsF0a7Jrh5CcKx7RBhyDgQc,31217
123
+ isar-1.32.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
124
+ isar-1.32.3.dist-info/entry_points.txt,sha256=TFam7uNNw7J0iiDYzsH2gfG0u1eV1wh3JTw_HkhgKLk,49
125
+ isar-1.32.3.dist-info/top_level.txt,sha256=UwIML2RtuQKCyJJkatcSnyp6-ldDjboB9k9JgKipO-U,21
126
+ isar-1.32.3.dist-info/RECORD,,
File without changes