clerk-sdk 0.1.9__py3-none-any.whl → 0.2.1__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.
Files changed (43) hide show
  1. clerk/base.py +94 -0
  2. clerk/client.py +3 -104
  3. clerk/decorator/models.py +1 -0
  4. clerk/decorator/task_decorator.py +1 -0
  5. clerk/gui_automation/__init__.py +0 -0
  6. clerk/gui_automation/action_model/__init__.py +0 -0
  7. clerk/gui_automation/action_model/model.py +126 -0
  8. clerk/gui_automation/action_model/utils.py +26 -0
  9. clerk/gui_automation/client.py +148 -0
  10. clerk/gui_automation/client_actor/__init__.py +4 -0
  11. clerk/gui_automation/client_actor/client_actor.py +176 -0
  12. clerk/gui_automation/client_actor/exception.py +22 -0
  13. clerk/gui_automation/client_actor/model.py +192 -0
  14. clerk/gui_automation/decorators/__init__.py +1 -0
  15. clerk/gui_automation/decorators/gui_automation.py +135 -0
  16. clerk/gui_automation/exceptions/__init__.py +0 -0
  17. clerk/gui_automation/exceptions/agent_manager.py +6 -0
  18. clerk/gui_automation/exceptions/modality/__init__.py +0 -0
  19. clerk/gui_automation/exceptions/modality/exc.py +46 -0
  20. clerk/gui_automation/exceptions/websocket.py +6 -0
  21. clerk/gui_automation/ui_actions/__init__.py +1 -0
  22. clerk/gui_automation/ui_actions/actions.py +781 -0
  23. clerk/gui_automation/ui_actions/base.py +200 -0
  24. clerk/gui_automation/ui_actions/support.py +69 -0
  25. clerk/gui_automation/ui_state_inspector/__init__.py +0 -0
  26. clerk/gui_automation/ui_state_inspector/gui_vision.py +184 -0
  27. clerk/gui_automation/ui_state_inspector/models.py +184 -0
  28. clerk/gui_automation/ui_state_machine/__init__.py +11 -0
  29. clerk/gui_automation/ui_state_machine/ai_recovery.py +110 -0
  30. clerk/gui_automation/ui_state_machine/decorators.py +71 -0
  31. clerk/gui_automation/ui_state_machine/exceptions.py +42 -0
  32. clerk/gui_automation/ui_state_machine/models.py +40 -0
  33. clerk/gui_automation/ui_state_machine/state_machine.py +838 -0
  34. clerk/models/remote_device.py +7 -0
  35. clerk/utils/__init__.py +0 -0
  36. clerk/utils/logger.py +124 -0
  37. clerk/utils/save_artifact.py +37 -0
  38. {clerk_sdk-0.1.9.dist-info → clerk_sdk-0.2.1.dist-info}/METADATA +11 -1
  39. clerk_sdk-0.2.1.dist-info/RECORD +49 -0
  40. clerk_sdk-0.1.9.dist-info/RECORD +0 -15
  41. {clerk_sdk-0.1.9.dist-info → clerk_sdk-0.2.1.dist-info}/WHEEL +0 -0
  42. {clerk_sdk-0.1.9.dist-info → clerk_sdk-0.2.1.dist-info}/licenses/LICENSE +0 -0
  43. {clerk_sdk-0.1.9.dist-info → clerk_sdk-0.2.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,7 @@
1
+ from pydantic import BaseModel
2
+
3
+
4
+ class RemoteDevice(BaseModel):
5
+ id: str
6
+ name: str
7
+ wss_token: str
File without changes
clerk/utils/logger.py ADDED
@@ -0,0 +1,124 @@
1
+ import inspect
2
+ import os
3
+ import logging
4
+ import sys
5
+
6
+ if sys.platform == "win32":
7
+ base_path = os.path.join(os.getcwd(), "data", "artifacts")
8
+ else:
9
+ base_path = "/app/data/artifacts"
10
+
11
+ os.makedirs(base_path, exist_ok=True)
12
+
13
+
14
+ def debug(message: str):
15
+ """
16
+ Logs a debug message.
17
+
18
+ This function logs a debug message by calling the _log function with "DEBUG" as the level.
19
+
20
+ Args:
21
+ module (str): The name of the module or component that generated the log message.
22
+ message (str): The log message to be logged.
23
+ """
24
+ _log("DEBUG", message)
25
+
26
+
27
+ def info(message: str):
28
+ """
29
+ Logs an info message.
30
+
31
+ This function logs an info message by calling the _log function with "INFO" as the level.
32
+
33
+ Args:
34
+ module (str): The name of the module or component that generated the log message.
35
+ message (str): The log message to be logged.
36
+ """
37
+ _log("INFO", message)
38
+
39
+
40
+ def warning(message: str):
41
+ """
42
+ Logs a warning message.
43
+
44
+ This function logs a warning message by calling the _log function with "WARNING" as the level.
45
+
46
+ Args:
47
+ module (str): The name of the module or component that generated the log message.
48
+ message (str): The log message to be logged.
49
+ """
50
+ _log("WARNING", message)
51
+
52
+
53
+ def error(message: str):
54
+ """
55
+ Logs an error message.
56
+
57
+ This function logs an error message by calling the _log function with "ERROR" as the level.
58
+
59
+ Args:
60
+ module (str): The name of the module or component that generated the log message.
61
+ message (str): The log message to be logged.
62
+ """
63
+ _log("ERROR", message)
64
+
65
+
66
+ def _log(level: str, message: str):
67
+ """
68
+ Log a message to a file in the artifacts folder using the Python logging module.
69
+
70
+ Args:
71
+ level (str): The log level of the message (e.g., "INFO", "DEBUG", "WARNING", "ERROR", "AUDIT").
72
+ module (str): The name of the module or component that generated the log message.
73
+ message (str): The log message to be logged.
74
+
75
+ Returns:
76
+ None
77
+
78
+ Example Usage:
79
+ _log_to_console("INFO", "module_name", "This is an info message")
80
+
81
+ """
82
+ # Get run_id from environment variable or default to "unknown"
83
+ run_id = os.getenv("_RUN_ID", "unknown")
84
+
85
+ # Create the base path for artifacts
86
+ logs_path = os.path.join(base_path, run_id)
87
+ os.makedirs(logs_path, exist_ok=True)
88
+ # Define the log file path
89
+ log_file_path = os.path.join(logs_path, "logs.txt")
90
+
91
+ # Get the calling file (two levels up the stack)
92
+ frame = inspect.stack()[2]
93
+ module = os.path.basename(frame.filename)
94
+
95
+ # Configure the logger
96
+ logger = logging.getLogger(module)
97
+ if not logger.handlers:
98
+ fh = logging.FileHandler(log_file_path)
99
+ format = "%(asctime)s - %(name)s - %(levelname)s: - %(message)s"
100
+ formatter = logging.Formatter(format)
101
+ fh.setFormatter(formatter)
102
+ logger.addHandler(fh)
103
+ # → console handler (same formatter)
104
+ sh = logging.StreamHandler(sys.stdout)
105
+ sh.setFormatter(formatter)
106
+ logger.addHandler(sh)
107
+
108
+ logger.setLevel(logging.DEBUG)
109
+ logger.propagate = False # keep root logger from printing duplicates
110
+
111
+ # Log the message based on the level
112
+ if level.lower() == "info":
113
+ logger.info(message)
114
+ elif level.lower() == "audit":
115
+ logger.info("AUDIT: " + message)
116
+ elif level.lower() == "debug":
117
+ logger.debug(message)
118
+ elif level.lower() == "warning":
119
+ logger.warning(message)
120
+ elif level.lower() == "error":
121
+ logger.error(message)
122
+
123
+ # Remove handlers to avoid duplicate logs
124
+ logger.handlers.clear()
@@ -0,0 +1,37 @@
1
+ import os
2
+ from typing import Optional
3
+ from clerk.utils import logger
4
+
5
+
6
+ def save_artifact(
7
+ filename: str, file_bytes: bytes, subfolder: Optional[str] = None
8
+ ) -> str:
9
+ """
10
+ Save an artifact to a specified path.
11
+
12
+ Args:
13
+ artifact: The artifact to save.
14
+ filename (str): The name of the file to save.
15
+ file_bytes (bytes): The bytes of the file to save.
16
+ subfolder (str): The subfolder where the artifact will be saved. Defaults to "artifacts".
17
+ Returns:
18
+ str: The path to the saved artifact.
19
+ """
20
+
21
+ # get the run ID from environment variable or default to "unknown"
22
+ run_id = os.getenv("_RUN_ID", "unknown")
23
+
24
+ # create the base path for artifacts
25
+ base_path = os.path.join(os.getcwd(), "data", "artifacts", run_id)
26
+ if subfolder:
27
+ base_path = os.path.join(base_path, subfolder)
28
+
29
+ os.makedirs(base_path, exist_ok=True)
30
+
31
+ # save the file
32
+ file_path = os.path.join(base_path, filename)
33
+ with open(file_path, "wb") as f:
34
+ f.write(file_bytes)
35
+
36
+ logger.debug(f"Artifact successfully saved at: {file_path}")
37
+ return file_path
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clerk-sdk
3
- Version: 0.1.9
3
+ Version: 0.2.1
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
@@ -14,6 +14,15 @@ License-File: LICENSE
14
14
  Requires-Dist: pydantic<3.0.0,>=2.0.0
15
15
  Requires-Dist: backoff<3.0.0,>=2.0.0
16
16
  Requires-Dist: requests<3.0.0,>=2.32.3
17
+ Provides-Extra: all
18
+ Requires-Dist: pydantic<3.0.0,>=2.0.0; extra == "all"
19
+ Requires-Dist: backoff<3.0.0,>=2.0.0; extra == "all"
20
+ Requires-Dist: requests<3.0.0,>=2.32.3; extra == "all"
21
+ Requires-Dist: networkx<4.0.0,>=3.5.0; extra == "all"
22
+ Requires-Dist: websockets>=15.0.1; extra == "all"
23
+ Provides-Extra: gui-automation
24
+ Requires-Dist: networkx<4.0.0,>=3.5.0; extra == "gui-automation"
25
+ Requires-Dist: websockets>=15.0.1; extra == "gui-automation"
17
26
  Dynamic: author
18
27
  Dynamic: author-email
19
28
  Dynamic: classifier
@@ -21,6 +30,7 @@ Dynamic: description
21
30
  Dynamic: description-content-type
22
31
  Dynamic: home-page
23
32
  Dynamic: license-file
33
+ Dynamic: provides-extra
24
34
  Dynamic: requires-dist
25
35
  Dynamic: requires-python
26
36
  Dynamic: summary
@@ -0,0 +1,49 @@
1
+ clerk/__init__.py,sha256=LWpbImG7352mUJYC1tRm_zsn5rnt4sFl5ldoq5f0dlo,26
2
+ clerk/base.py,sha256=Ayb2zCQr8fqKZM_Qh3nVxVJOQkkYt-eD5VtpPXd1TLs,2669
3
+ clerk/client.py,sha256=6nWWWjGB7a6FNUWsZRM-IoBb_mshRi6g5KX8meMiJ2E,576
4
+ clerk/decorator/__init__.py,sha256=4VCGOFNq7pA7iJS410V_R9eWfjxP7mwxwa4thwaUTf8,39
5
+ clerk/decorator/models.py,sha256=JWFOJuUh3F40iOL0aoNgUC9GRHU3Fcq3GOjSXA7Gwng,394
6
+ clerk/decorator/task_decorator.py,sha256=srb8AC3tNj1RWC4iNkkwkUuG33B8TtxfTpOm1Oi373Y,2169
7
+ clerk/gui_automation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ clerk/gui_automation/client.py,sha256=LJFHdWreH0pZnRUZJ6jd4Xp3kYJjOjNLEUfHD0ly2Y0,4405
9
+ clerk/gui_automation/action_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ clerk/gui_automation/action_model/model.py,sha256=sbTySgOq4Xv_r2p7q_ji1bGCHgRS1HXC9Z39thwCQ9c,3829
11
+ clerk/gui_automation/action_model/utils.py,sha256=xzFxgN-bTK6HKGS7J-esQZ-ePj_yG72T-2ZVhcWvKjw,798
12
+ clerk/gui_automation/client_actor/__init__.py,sha256=SVuL6-oo1Xc0oJkjMKrO6mJwpPGjrCLKhDV6r2Abtf8,66
13
+ clerk/gui_automation/client_actor/client_actor.py,sha256=Me3NHc0nMA7Y5CUcnE0ZHT1P7dQRGR6duCAKwn0Tg6g,5081
14
+ clerk/gui_automation/client_actor/exception.py,sha256=zdnImHZ88yf52Xq3aMHivEU3aJg-r2c-r8x8XZnI3ic,407
15
+ clerk/gui_automation/client_actor/model.py,sha256=wVpFCi1w2kh4kAV8oNx489vf_SLUQnqhc02rFD5NIJA,6335
16
+ clerk/gui_automation/decorators/__init__.py,sha256=OCgXStEumscgT-RyVy5OKS7ml1w9y-lEnjCVnxuRnQs,43
17
+ clerk/gui_automation/decorators/gui_automation.py,sha256=efB38zIcHsDubfnRgc_o1MgYEJAH7Sfv9oqKB7toZW4,4690
18
+ clerk/gui_automation/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ clerk/gui_automation/exceptions/agent_manager.py,sha256=KFWFWQ7X_8Z9XG__SMzb1jKI3yNoVTPJAXzW5O-fSXc,101
20
+ clerk/gui_automation/exceptions/websocket.py,sha256=-MdwSwlf1hbnu55aDgk3L1znkTZ6xJS6po5VpEGD9ck,117
21
+ clerk/gui_automation/exceptions/modality/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ clerk/gui_automation/exceptions/modality/exc.py,sha256=P-dMuCTyVZYD3pbGpCf_1SYEgaETn13c51pmfbsXr5k,1436
23
+ clerk/gui_automation/ui_actions/__init__.py,sha256=-EDQ5375HXrvG3sfFY7zOPC405YcBL6xXRACm2p-YyI,23
24
+ clerk/gui_automation/ui_actions/actions.py,sha256=hhxl5VMDNSXdqm2L0tZqs6IhJHVXtlSVSdwsiz2BbDI,27449
25
+ clerk/gui_automation/ui_actions/base.py,sha256=4CjOkMZNLt8W0tLO91tOkz8CCea0m2IRBIOpWNMOZUA,7230
26
+ clerk/gui_automation/ui_actions/support.py,sha256=BS9QReyP_F9-oGPt0fuy5BD9kC9-E5mOE05Zk0M1Hzw,2176
27
+ clerk/gui_automation/ui_state_inspector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
+ clerk/gui_automation/ui_state_inspector/gui_vision.py,sha256=lRnF3IMLViOB-UE447A4kc8BO7NKqqLV1NZKRswRKWg,7707
29
+ clerk/gui_automation/ui_state_inspector/models.py,sha256=uuzYhE9is4Z-TmsVMA1mwf0mQGs_PDLqdSZKbe8dHSs,5691
30
+ clerk/gui_automation/ui_state_machine/__init__.py,sha256=bTPZsPJkDLCwP2mdtBj4fU7C7ekOh0b-VPRKFEV3bPo,301
31
+ clerk/gui_automation/ui_state_machine/ai_recovery.py,sha256=3_Gu_RPxta4eXmXWH3WA31c15sJL-dk1m1H2bOFV7so,3772
32
+ clerk/gui_automation/ui_state_machine/decorators.py,sha256=gBOpIusjsXlA7FEiszDCFKTS6vXx3LBNMz_SQJNkMWg,2134
33
+ clerk/gui_automation/ui_state_machine/exceptions.py,sha256=9KWg20dnCssMdMu632E0nP5vkndgYNI4cDCDW-vMkQA,1436
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=6WJQ5NsI9hOqN-VM0lYf_mv-xOQd0UjolGXJ0M58L1I,35230
36
+ clerk/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
+ clerk/models/document.py,sha256=Bbt3YSvGcOrJJjJBYjbDGXpZIaQAYdq_-uIr2urwy5s,525
38
+ clerk/models/document_statuses.py,sha256=ytTQhgACs2m22qz51_7Ti0IxzbVyl-fl7uF7CnDEyLA,279
39
+ clerk/models/file.py,sha256=7n6bV6ukRA-uh7MFxUx_TEMNpVAdNe5O0nKIeneCQhg,459
40
+ clerk/models/remote_device.py,sha256=2jijS-9WWq7y6xIbAaDaPnzZo3-tjp2-dCQvNKP8YSU,109
41
+ clerk/models/response_model.py,sha256=R62daUN1YVOwgnrh_epvFRsQcOwT7R4u97l73egvm-c,232
42
+ clerk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
+ clerk/utils/logger.py,sha256=_jYOSEc1WCsY9DvU8cIWUPmz41QNjpHTEZ7WrUnmFPA,3650
44
+ clerk/utils/save_artifact.py,sha256=Lwl3l3QqKnSFLFpfEEa-dJ-dV9OxvCU3ADkuYZ18U-Q,1117
45
+ clerk_sdk-0.2.1.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
46
+ clerk_sdk-0.2.1.dist-info/METADATA,sha256=QEgrEZmgLaFSscyy0ob9Sr5Y4npmMXFbxF-kPxsk8lE,3508
47
+ clerk_sdk-0.2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
48
+ clerk_sdk-0.2.1.dist-info/top_level.txt,sha256=99eQiU6d05_-f41tmSFanfI_SIJeAdh7u9m3LNSfcv4,6
49
+ clerk_sdk-0.2.1.dist-info/RECORD,,
@@ -1,15 +0,0 @@
1
- clerk/__init__.py,sha256=LWpbImG7352mUJYC1tRm_zsn5rnt4sFl5ldoq5f0dlo,26
2
- clerk/client.py,sha256=UEbs5AhnBs6JWstLzT-TPHZ-yxyBwTFDLemv-yh25K4,3386
3
- clerk/decorator/__init__.py,sha256=4VCGOFNq7pA7iJS410V_R9eWfjxP7mwxwa4thwaUTf8,39
4
- clerk/decorator/models.py,sha256=FKs7oCq50hmvbzYWuscvqlL7boPYzMKv0Vg3tznmwao,361
5
- clerk/decorator/task_decorator.py,sha256=ns7eYcv835HoeRIJtB79HC6gMUUfboxY3lsIn5JakqI,2159
6
- clerk/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- clerk/models/document.py,sha256=Bbt3YSvGcOrJJjJBYjbDGXpZIaQAYdq_-uIr2urwy5s,525
8
- clerk/models/document_statuses.py,sha256=ytTQhgACs2m22qz51_7Ti0IxzbVyl-fl7uF7CnDEyLA,279
9
- clerk/models/file.py,sha256=7n6bV6ukRA-uh7MFxUx_TEMNpVAdNe5O0nKIeneCQhg,459
10
- clerk/models/response_model.py,sha256=R62daUN1YVOwgnrh_epvFRsQcOwT7R4u97l73egvm-c,232
11
- clerk_sdk-0.1.9.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
12
- clerk_sdk-0.1.9.dist-info/METADATA,sha256=npxd_MCKjeQxbI9lMlgAfYi1QIVF8ewaWO-c6uTxFMY,3041
13
- clerk_sdk-0.1.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
- clerk_sdk-0.1.9.dist-info/top_level.txt,sha256=99eQiU6d05_-f41tmSFanfI_SIJeAdh7u9m3LNSfcv4,6
15
- clerk_sdk-0.1.9.dist-info/RECORD,,