clerk-sdk 0.2.7__tar.gz → 0.3.0__tar.gz

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.
Files changed (62) hide show
  1. {clerk_sdk-0.2.7/clerk_sdk.egg-info → clerk_sdk-0.3.0}/PKG-INFO +1 -1
  2. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/decorator/task_decorator.py +7 -1
  3. clerk_sdk-0.3.0/clerk/exceptions/exceptions.py +13 -0
  4. clerk_sdk-0.3.0/clerk/exceptions/remote_device.py +4 -0
  5. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/ui_actions/support.py +42 -1
  6. clerk_sdk-0.3.0/clerk/utils/__init__.py +0 -0
  7. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/utils/logger.py +3 -3
  8. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/utils/save_artifact.py +3 -3
  9. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0/clerk_sdk.egg-info}/PKG-INFO +1 -1
  10. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk_sdk.egg-info/SOURCES.txt +3 -0
  11. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/setup.py +1 -1
  12. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/LICENSE +0 -0
  13. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/MANIFEST.in +0 -0
  14. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/README.md +0 -0
  15. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/__init__.py +0 -0
  16. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/base.py +0 -0
  17. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/client.py +0 -0
  18. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/decorator/__init__.py +0 -0
  19. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/decorator/models.py +0 -0
  20. {clerk_sdk-0.2.7/clerk/gui_automation → clerk_sdk-0.3.0/clerk/exceptions}/__init__.py +0 -0
  21. {clerk_sdk-0.2.7/clerk/gui_automation/action_model → clerk_sdk-0.3.0/clerk/gui_automation}/__init__.py +0 -0
  22. {clerk_sdk-0.2.7/clerk/gui_automation/exceptions → clerk_sdk-0.3.0/clerk/gui_automation/action_model}/__init__.py +0 -0
  23. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/action_model/model.py +0 -0
  24. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/action_model/utils.py +0 -0
  25. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/client.py +0 -0
  26. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/client_actor/__init__.py +0 -0
  27. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/client_actor/client_actor.py +0 -0
  28. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/client_actor/exception.py +0 -0
  29. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/client_actor/model.py +0 -0
  30. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/decorators/__init__.py +0 -0
  31. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/decorators/gui_automation.py +0 -0
  32. {clerk_sdk-0.2.7/clerk/gui_automation/exceptions/modality → clerk_sdk-0.3.0/clerk/gui_automation/exceptions}/__init__.py +0 -0
  33. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/exceptions/agent_manager.py +0 -0
  34. {clerk_sdk-0.2.7/clerk/gui_automation/ui_state_inspector → clerk_sdk-0.3.0/clerk/gui_automation/exceptions/modality}/__init__.py +0 -0
  35. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/exceptions/modality/exc.py +0 -0
  36. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/exceptions/websocket.py +0 -0
  37. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/requirements.txt +0 -0
  38. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/ui_actions/__init__.py +0 -0
  39. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/ui_actions/actions.py +0 -0
  40. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/ui_actions/base.py +0 -0
  41. {clerk_sdk-0.2.7/clerk/models → clerk_sdk-0.3.0/clerk/gui_automation/ui_state_inspector}/__init__.py +0 -0
  42. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/ui_state_inspector/gui_vision.py +0 -0
  43. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/ui_state_inspector/models.py +0 -0
  44. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/ui_state_machine/__init__.py +0 -0
  45. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/ui_state_machine/ai_recovery.py +0 -0
  46. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/ui_state_machine/decorators.py +0 -0
  47. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/ui_state_machine/exceptions.py +0 -0
  48. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/ui_state_machine/models.py +0 -0
  49. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/gui_automation/ui_state_machine/state_machine.py +0 -0
  50. {clerk_sdk-0.2.7/clerk/utils → clerk_sdk-0.3.0/clerk/models}/__init__.py +0 -0
  51. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/models/document.py +0 -0
  52. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/models/document_statuses.py +0 -0
  53. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/models/file.py +0 -0
  54. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/models/remote_device.py +0 -0
  55. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/models/response_model.py +0 -0
  56. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk/models/ui_operator.py +0 -0
  57. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk_sdk.egg-info/dependency_links.txt +0 -0
  58. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk_sdk.egg-info/requires.txt +0 -0
  59. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/clerk_sdk.egg-info/top_level.txt +0 -0
  60. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/pyproject.toml +0 -0
  61. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/requirements.txt +0 -0
  62. {clerk_sdk-0.2.7 → clerk_sdk-0.3.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clerk-sdk
3
- Version: 0.2.7
3
+ Version: 0.3.0
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
@@ -1,7 +1,10 @@
1
1
  import os
2
2
  import pickle
3
+ import traceback
3
4
  from typing import Callable, Optional
4
5
  from functools import wraps
6
+
7
+ from clerk.exceptions.exceptions import ApplicationException
5
8
  from .models import ClerkCodePayload
6
9
 
7
10
  input_pkl: str = "/app/data/input/input.pkl"
@@ -35,7 +38,10 @@ def clerk_code():
35
38
  if not isinstance(output, ClerkCodePayload):
36
39
  raise TypeError("Function must return a ClerkCodePayload instance.")
37
40
  except Exception as e:
38
- output = e
41
+ # parse no standard errors into the standard Application Error
42
+ output = ApplicationException(
43
+ type=str(type(e)), message=str(e), traceback=traceback.format_exc()
44
+ )
39
45
 
40
46
  # 3. write to output.pkl
41
47
  try:
@@ -0,0 +1,13 @@
1
+ from typing import Optional
2
+
3
+
4
+ class AppBaseException(Exception):
5
+ def __init__(self, type_: str, message: str, traceback: Optional[str] = None):
6
+ super().__init__(message)
7
+ self.type = type_
8
+ self.message = message
9
+ self.traceback = traceback
10
+
11
+
12
+ class ApplicationException(AppBaseException):
13
+ pass
@@ -0,0 +1,4 @@
1
+ class RemoteDeviceAllocationError(Exception):
2
+ """Exception raised when there is an error allocating a remote device."""
3
+
4
+ pass
@@ -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.
File without changes
@@ -79,11 +79,11 @@ def _log(level: str, message: str):
79
79
  _log_to_console("INFO", "module_name", "This is an info message")
80
80
 
81
81
  """
82
- # Get run_id from environment variable or default to "unknown"
83
- run_id = os.getenv("_RUN_ID", "unknown")
82
+ # Get artifact folder from environment variable or default to "unknown"
83
+ _artifacts_folder = os.getenv("_artifacts_folder", "unknown")
84
84
 
85
85
  # Create the base path for artifacts
86
- logs_path = os.path.join(base_path, run_id)
86
+ logs_path = os.path.join(base_path, _artifacts_folder)
87
87
  os.makedirs(logs_path, exist_ok=True)
88
88
  # Define the log file path
89
89
  log_file_path = os.path.join(logs_path, "logs.txt")
@@ -18,11 +18,11 @@ def save_artifact(
18
18
  str: The path to the saved artifact.
19
19
  """
20
20
 
21
- # get the run ID from environment variable or default to "unknown"
22
- run_id = os.getenv("_RUN_ID", "unknown")
21
+ # get the artifact folder from environment variable or default to "unknown"
22
+ _artifacts_folder = os.getenv("_artifacts_folder", "unknown")
23
23
 
24
24
  # create the base path for artifacts
25
- base_path = os.path.join(os.getcwd(), "data", "artifacts", run_id)
25
+ base_path = os.path.join(os.getcwd(), "data", "artifacts", _artifacts_folder)
26
26
  if subfolder:
27
27
  base_path = os.path.join(base_path, subfolder)
28
28
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clerk-sdk
3
- Version: 0.2.7
3
+ Version: 0.3.0
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
@@ -10,6 +10,9 @@ clerk/client.py
10
10
  clerk/decorator/__init__.py
11
11
  clerk/decorator/models.py
12
12
  clerk/decorator/task_decorator.py
13
+ clerk/exceptions/__init__.py
14
+ clerk/exceptions/exceptions.py
15
+ clerk/exceptions/remote_device.py
13
16
  clerk/gui_automation/__init__.py
14
17
  clerk/gui_automation/client.py
15
18
  clerk/gui_automation/requirements.txt
@@ -13,7 +13,7 @@ gui_requirements = get_requirements("./clerk/gui_automation")
13
13
 
14
14
  setup(
15
15
  name="clerk-sdk",
16
- version="0.2.7",
16
+ version="0.3.0",
17
17
  description="Library for interacting with Clerk",
18
18
  long_description=open("README.md").read(),
19
19
  long_description_content_type="text/markdown",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes