clerk-sdk 0.2.6__py3-none-any.whl → 0.2.8__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.
@@ -2,7 +2,7 @@ from datetime import timedelta, datetime
2
2
  import os
3
3
  import base64
4
4
  import time
5
- from typing import Optional
5
+ from typing import List, Optional
6
6
  from backoff._typing import Details
7
7
 
8
8
  from clerk.models.ui_operator import TaskStatuses, UiOperatorTask
@@ -60,6 +60,47 @@ def save_screenshot(filename: str, sub_folder: Optional[str] = None) -> str:
60
60
  )
61
61
 
62
62
 
63
+ def try_actions(actions: List[BaseAction]):
64
+ """
65
+ Executes a list of UI actions and handles any errors that occur.
66
+
67
+ This function takes a list of UI actions as input and executes them one by one.
68
+ If an action fails with a RuntimeError, it logs a warning message and moves on to the next action.
69
+ If all actions fail, it logs an error message and raises a RuntimeError.
70
+
71
+ Args:
72
+ actions (List[BaseAction]): A list of UI actions to be executed.
73
+
74
+ Raises:
75
+ TypeError: If any of the actions in the list is not an instance of BaseAction.
76
+ RuntimeError: If all actions fail.
77
+
78
+ Returns:
79
+ None
80
+
81
+ Example Usage:
82
+ actions = [action1, action2, action3]
83
+ try_actions(actions)
84
+ """
85
+ try:
86
+ assert all(isinstance(action, BaseAction) for action in actions)
87
+ for action in actions:
88
+ try:
89
+ action.do()
90
+ return
91
+ except RuntimeError as e:
92
+ logger.warning(
93
+ f"The action {action} was not performed successfully.\nDetails: {str(e)}",
94
+ )
95
+ # all the actions have failed. log an error and raise a runtime error
96
+ logger.error("All actions have failed.")
97
+ raise RuntimeError("All actions have failed")
98
+ except AssertionError as e:
99
+ raise TypeError(
100
+ f"All actions must be valid. Encountered invalid action: {str(e)}"
101
+ )
102
+
103
+
63
104
  def _format_action_string(action: BaseAction) -> str:
64
105
  """
65
106
  Formats action in the same format as the one used in task modules.
@@ -66,9 +66,6 @@ class ScreenPilot:
66
66
  tolerate_repeat_transitions: int = 5
67
67
  tolerate_repeat_states: int = 5
68
68
  enable_force_close_app_process: bool = False
69
- ui_operator_enabled: bool = False
70
- ui_operator_pooling_interval: int = 1 # seconds
71
- ui_operator_timeout: int = 3600 # seconds (1 hour)
72
69
  process_name: Optional[str] = None
73
70
  _acted_since_state_eval: bool = False
74
71
  _ai_recovery_agent: Optional[CourseCorrector] = None
@@ -722,14 +719,6 @@ class ScreenPilot:
722
719
  """
723
720
  return None
724
721
 
725
- @classmethod
726
- def _initialize_env_variables(cls):
727
- os.environ["_ui_operator_enabled"] = str(cls.ui_operator_enabled)
728
- os.environ["_ui_operator_pooling_interval"] = str(
729
- cls.ui_operator_pooling_interval
730
- )
731
- os.environ["_ui_operator_timeout"] = str(cls.ui_operator_timeout)
732
-
733
722
  @classmethod
734
723
  def run(
735
724
  cls, goal_function: Optional[Callable] = None, **kwargs
@@ -746,8 +735,6 @@ class ScreenPilot:
746
735
  Returns:
747
736
  - Exit reason (ScreenPilotOutcome): Exception class that interrupted the state machine execution.
748
737
  """
749
- cls._initialize_env_variables()
750
-
751
738
  if not goal_function:
752
739
  goal_function = cls._default_goal_function
753
740
  cls._act_on_start()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clerk-sdk
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: Library for interacting with Clerk
5
5
  Home-page: https://github.com/F-ONE-Group/clerk_pypi
6
6
  Author: F-ONE Group
@@ -23,7 +23,7 @@ clerk/gui_automation/exceptions/modality/exc.py,sha256=P-dMuCTyVZYD3pbGpCf_1SYEg
23
23
  clerk/gui_automation/ui_actions/__init__.py,sha256=-EDQ5375HXrvG3sfFY7zOPC405YcBL6xXRACm2p-YyI,23
24
24
  clerk/gui_automation/ui_actions/actions.py,sha256=hhxl5VMDNSXdqm2L0tZqs6IhJHVXtlSVSdwsiz2BbDI,27449
25
25
  clerk/gui_automation/ui_actions/base.py,sha256=4CjOkMZNLt8W0tLO91tOkz8CCea0m2IRBIOpWNMOZUA,7230
26
- clerk/gui_automation/ui_actions/support.py,sha256=83D-oVmZxD507kh9-8PsoXt5zD4o225TmkmS0Kh_8Zo,4330
26
+ clerk/gui_automation/ui_actions/support.py,sha256=Ulb8DBfwnrBMaYoMLDgldEy9V--NDUSdhIYXpuODZoU,5772
27
27
  clerk/gui_automation/ui_state_inspector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
28
  clerk/gui_automation/ui_state_inspector/gui_vision.py,sha256=lRnF3IMLViOB-UE447A4kc8BO7NKqqLV1NZKRswRKWg,7707
29
29
  clerk/gui_automation/ui_state_inspector/models.py,sha256=uuzYhE9is4Z-TmsVMA1mwf0mQGs_PDLqdSZKbe8dHSs,5691
@@ -32,7 +32,7 @@ clerk/gui_automation/ui_state_machine/ai_recovery.py,sha256=3_Gu_RPxta4eXmXWH3WA
32
32
  clerk/gui_automation/ui_state_machine/decorators.py,sha256=gBOpIusjsXlA7FEiszDCFKTS6vXx3LBNMz_SQJNkMWg,2134
33
33
  clerk/gui_automation/ui_state_machine/exceptions.py,sha256=9KWg20dnCssMdMu632E0nP5vkndgYNI4cDCDW-vMkQA,1436
34
34
  clerk/gui_automation/ui_state_machine/models.py,sha256=1fpNYPsff0dyLg1wNJl-xQyMYvy4cSDy4OLxa0ej-0U,1395
35
- clerk/gui_automation/ui_state_machine/state_machine.py,sha256=2OfN17N_8dzhul2X19koqGWDZbgjeJu7ExTLpVzf1OA,36130
35
+ clerk/gui_automation/ui_state_machine/state_machine.py,sha256=u2wJqu5WxmZHkzlIHTgK_icZUw3yv9nNuZkh9IaqmXI,35622
36
36
  clerk/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  clerk/models/document.py,sha256=Bbt3YSvGcOrJJjJBYjbDGXpZIaQAYdq_-uIr2urwy5s,525
38
38
  clerk/models/document_statuses.py,sha256=ytTQhgACs2m22qz51_7Ti0IxzbVyl-fl7uF7CnDEyLA,279
@@ -43,8 +43,8 @@ clerk/models/ui_operator.py,sha256=mKTJUFZgv7PeEt5oys28HVZxHOJsofmRQOcRpqj0dbU,2
43
43
  clerk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
44
  clerk/utils/logger.py,sha256=_jYOSEc1WCsY9DvU8cIWUPmz41QNjpHTEZ7WrUnmFPA,3650
45
45
  clerk/utils/save_artifact.py,sha256=Lwl3l3QqKnSFLFpfEEa-dJ-dV9OxvCU3ADkuYZ18U-Q,1117
46
- clerk_sdk-0.2.6.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
47
- clerk_sdk-0.2.6.dist-info/METADATA,sha256=mC8t5huCNbfWuHZ2dy4O3d0-XMHx8yy8n1cFCgLbhzk,3508
48
- clerk_sdk-0.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
- clerk_sdk-0.2.6.dist-info/top_level.txt,sha256=99eQiU6d05_-f41tmSFanfI_SIJeAdh7u9m3LNSfcv4,6
50
- clerk_sdk-0.2.6.dist-info/RECORD,,
46
+ clerk_sdk-0.2.8.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
47
+ clerk_sdk-0.2.8.dist-info/METADATA,sha256=IrsGA9xl2v4g6Pyai2o09RWSl8AyoeWRekLNDfFUu3o,3508
48
+ clerk_sdk-0.2.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
49
+ clerk_sdk-0.2.8.dist-info/top_level.txt,sha256=99eQiU6d05_-f41tmSFanfI_SIJeAdh7u9m3LNSfcv4,6
50
+ clerk_sdk-0.2.8.dist-info/RECORD,,