clerk-sdk 0.1.9__py3-none-any.whl → 0.2.0__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 (42) 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 +144 -0
  10. clerk/gui_automation/client_actor/__init__.py +4 -0
  11. clerk/gui_automation/client_actor/client_actor.py +178 -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 +109 -0
  16. clerk/gui_automation/exceptions/__init__.py +0 -0
  17. clerk/gui_automation/exceptions/modality/__init__.py +0 -0
  18. clerk/gui_automation/exceptions/modality/exc.py +46 -0
  19. clerk/gui_automation/exceptions/websocket.py +6 -0
  20. clerk/gui_automation/ui_actions/__init__.py +1 -0
  21. clerk/gui_automation/ui_actions/actions.py +781 -0
  22. clerk/gui_automation/ui_actions/base.py +200 -0
  23. clerk/gui_automation/ui_actions/support.py +68 -0
  24. clerk/gui_automation/ui_state_inspector/__init__.py +0 -0
  25. clerk/gui_automation/ui_state_inspector/gui_vision.py +184 -0
  26. clerk/gui_automation/ui_state_inspector/models.py +184 -0
  27. clerk/gui_automation/ui_state_machine/__init__.py +11 -0
  28. clerk/gui_automation/ui_state_machine/ai_recovery.py +110 -0
  29. clerk/gui_automation/ui_state_machine/decorators.py +71 -0
  30. clerk/gui_automation/ui_state_machine/exceptions.py +42 -0
  31. clerk/gui_automation/ui_state_machine/models.py +40 -0
  32. clerk/gui_automation/ui_state_machine/state_machine.py +838 -0
  33. clerk/models/remote_device.py +7 -0
  34. clerk/utils/__init__.py +0 -0
  35. clerk/utils/logger.py +118 -0
  36. clerk/utils/save_artifact.py +35 -0
  37. {clerk_sdk-0.1.9.dist-info → clerk_sdk-0.2.0.dist-info}/METADATA +11 -1
  38. clerk_sdk-0.2.0.dist-info/RECORD +48 -0
  39. clerk_sdk-0.1.9.dist-info/RECORD +0 -15
  40. {clerk_sdk-0.1.9.dist-info → clerk_sdk-0.2.0.dist-info}/WHEEL +0 -0
  41. {clerk_sdk-0.1.9.dist-info → clerk_sdk-0.2.0.dist-info}/licenses/LICENSE +0 -0
  42. {clerk_sdk-0.1.9.dist-info → clerk_sdk-0.2.0.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,118 @@
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", "output", "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
+ logger.setLevel(logging.DEBUG)
104
+
105
+ # Log the message based on the level
106
+ if level.lower() == "info":
107
+ logger.info(message)
108
+ elif level.lower() == "audit":
109
+ logger.info("AUDIT: " + message)
110
+ elif level.lower() == "debug":
111
+ logger.debug(message)
112
+ elif level.lower() == "warning":
113
+ logger.warning(message)
114
+ elif level.lower() == "error":
115
+ logger.error(message)
116
+
117
+ # Remove handlers to avoid duplicate logs
118
+ logger.handlers.clear()
@@ -0,0 +1,35 @@
1
+ import os
2
+ from typing import Optional
3
+
4
+
5
+ def save_artifact(
6
+ filename: str, file_bytes: bytes, subfolder: Optional[str] = None
7
+ ) -> str:
8
+ """
9
+ Save an artifact to a specified path.
10
+
11
+ Args:
12
+ artifact: The artifact to save.
13
+ filename (str): The name of the file to save.
14
+ file_bytes (bytes): The bytes of the file to save.
15
+ subfolder (str): The subfolder where the artifact will be saved. Defaults to "artifacts".
16
+ Returns:
17
+ str: The path to the saved artifact.
18
+ """
19
+
20
+ # get the run ID from environment variable or default to "unknown"
21
+ run_id = os.getenv("_RUN_ID", "unknown")
22
+
23
+ # create the base path for artifacts
24
+ base_path = os.path.join(os.getcwd(), "data", "artifacts", run_id)
25
+ if subfolder:
26
+ base_path = os.path.join(base_path, subfolder)
27
+
28
+ os.makedirs(base_path, exist_ok=True)
29
+
30
+ # save the file
31
+ file_path = os.path.join(base_path, filename)
32
+ with open(file_path, "wb") as f:
33
+ f.write(file_bytes)
34
+
35
+ 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.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
@@ -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,48 @@
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=FFK1xXGEvz3ZuUnmgvibhDIvdrOcBpa6pG-Z1cqzhKc,4256
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=5hQ2KPLnXueUu6tOq-w44dDm3_Lxx4nA_mMnAZmqfVY,5167
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=AUDawosvwTXpIT0jLKzrgVUG0Fqu_Qs_AhAm3zgRfIo,3706
18
+ clerk/gui_automation/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
+ clerk/gui_automation/exceptions/websocket.py,sha256=-MdwSwlf1hbnu55aDgk3L1znkTZ6xJS6po5VpEGD9ck,117
20
+ clerk/gui_automation/exceptions/modality/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
+ clerk/gui_automation/exceptions/modality/exc.py,sha256=P-dMuCTyVZYD3pbGpCf_1SYEgaETn13c51pmfbsXr5k,1436
22
+ clerk/gui_automation/ui_actions/__init__.py,sha256=-EDQ5375HXrvG3sfFY7zOPC405YcBL6xXRACm2p-YyI,23
23
+ clerk/gui_automation/ui_actions/actions.py,sha256=hhxl5VMDNSXdqm2L0tZqs6IhJHVXtlSVSdwsiz2BbDI,27449
24
+ clerk/gui_automation/ui_actions/base.py,sha256=4CjOkMZNLt8W0tLO91tOkz8CCea0m2IRBIOpWNMOZUA,7230
25
+ clerk/gui_automation/ui_actions/support.py,sha256=oPu_xNOQb6i83pSDQ9if14Jh-noT2q0o-Rl3y5DrHLE,2160
26
+ clerk/gui_automation/ui_state_inspector/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
+ clerk/gui_automation/ui_state_inspector/gui_vision.py,sha256=lRnF3IMLViOB-UE447A4kc8BO7NKqqLV1NZKRswRKWg,7707
28
+ clerk/gui_automation/ui_state_inspector/models.py,sha256=uuzYhE9is4Z-TmsVMA1mwf0mQGs_PDLqdSZKbe8dHSs,5691
29
+ clerk/gui_automation/ui_state_machine/__init__.py,sha256=bTPZsPJkDLCwP2mdtBj4fU7C7ekOh0b-VPRKFEV3bPo,301
30
+ clerk/gui_automation/ui_state_machine/ai_recovery.py,sha256=3_Gu_RPxta4eXmXWH3WA31c15sJL-dk1m1H2bOFV7so,3772
31
+ clerk/gui_automation/ui_state_machine/decorators.py,sha256=gBOpIusjsXlA7FEiszDCFKTS6vXx3LBNMz_SQJNkMWg,2134
32
+ clerk/gui_automation/ui_state_machine/exceptions.py,sha256=9KWg20dnCssMdMu632E0nP5vkndgYNI4cDCDW-vMkQA,1436
33
+ clerk/gui_automation/ui_state_machine/models.py,sha256=1fpNYPsff0dyLg1wNJl-xQyMYvy4cSDy4OLxa0ej-0U,1395
34
+ clerk/gui_automation/ui_state_machine/state_machine.py,sha256=6WJQ5NsI9hOqN-VM0lYf_mv-xOQd0UjolGXJ0M58L1I,35230
35
+ clerk/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
+ clerk/models/document.py,sha256=Bbt3YSvGcOrJJjJBYjbDGXpZIaQAYdq_-uIr2urwy5s,525
37
+ clerk/models/document_statuses.py,sha256=ytTQhgACs2m22qz51_7Ti0IxzbVyl-fl7uF7CnDEyLA,279
38
+ clerk/models/file.py,sha256=7n6bV6ukRA-uh7MFxUx_TEMNpVAdNe5O0nKIeneCQhg,459
39
+ clerk/models/remote_device.py,sha256=2jijS-9WWq7y6xIbAaDaPnzZo3-tjp2-dCQvNKP8YSU,109
40
+ clerk/models/response_model.py,sha256=R62daUN1YVOwgnrh_epvFRsQcOwT7R4u97l73egvm-c,232
41
+ clerk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
+ clerk/utils/logger.py,sha256=OxpWOo7IMBajp6rwkZH8-7E9VxRNzJNfxC8fDFClDVo,3425
43
+ clerk/utils/save_artifact.py,sha256=Y4lxcGKxr-5tKdY66Z4BghI4p0Vk4LtEBNsh6Nh01zc,1021
44
+ clerk_sdk-0.2.0.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
45
+ clerk_sdk-0.2.0.dist-info/METADATA,sha256=9p4HdIoMfDoXlQX6rT0e624wqy2bGxAlhS1PJ0L02fQ,3508
46
+ clerk_sdk-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
47
+ clerk_sdk-0.2.0.dist-info/top_level.txt,sha256=99eQiU6d05_-f41tmSFanfI_SIJeAdh7u9m3LNSfcv4,6
48
+ clerk_sdk-0.2.0.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,,