clerk-sdk 0.2.2__py3-none-any.whl → 0.2.4__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.
- clerk/gui_automation/decorators/gui_automation.py +16 -9
- {clerk_sdk-0.2.2.dist-info → clerk_sdk-0.2.4.dist-info}/METADATA +1 -1
- {clerk_sdk-0.2.2.dist-info → clerk_sdk-0.2.4.dist-info}/RECORD +6 -6
- {clerk_sdk-0.2.2.dist-info → clerk_sdk-0.2.4.dist-info}/WHEEL +0 -0
- {clerk_sdk-0.2.2.dist-info → clerk_sdk-0.2.4.dist-info}/licenses/LICENSE +0 -0
- {clerk_sdk-0.2.2.dist-info → clerk_sdk-0.2.4.dist-info}/top_level.txt +0 -0
|
@@ -24,8 +24,10 @@ global_ws: Union[ClientConnection, None] = None
|
|
|
24
24
|
clerk_client = RPAClerk()
|
|
25
25
|
wss_uri = "wss://agent-manager.f-one.group/action"
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
REMOTE_DEVICE_ALLOCATION_TIMEOUT = int(os.getenv("REMOTE_DEVICE_ALLOCATION_TIMEOUT", 1))
|
|
28
|
+
REMOTE_DEVICE_ALLOCATION_MAX_TRIES = int(
|
|
29
|
+
os.getenv("REMOTE_DEVICE_ALLOCATION_MAX_TRIES", 60)
|
|
30
|
+
)
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
def _allocate_remote_device(
|
|
@@ -46,14 +48,14 @@ def _allocate_remote_device(
|
|
|
46
48
|
|
|
47
49
|
except NoClientsAvailable:
|
|
48
50
|
logger.warning(
|
|
49
|
-
f"No clients are available for {group_name} group. Initiating a {
|
|
51
|
+
f"No clients are available for {group_name} group. Initiating a {REMOTE_DEVICE_ALLOCATION_TIMEOUT} minute wait. Retry count: {retries}"
|
|
50
52
|
)
|
|
51
|
-
retries
|
|
52
|
-
if retries == MAX_CLIENT_AVAILABILITY_RETRIES:
|
|
53
|
+
if retries >= REMOTE_DEVICE_ALLOCATION_MAX_TRIES:
|
|
53
54
|
raise ClientAvailabilityTimeout(
|
|
54
|
-
f"No clients available for {group_name} group after {
|
|
55
|
+
f"No clients available for {group_name} group after {REMOTE_DEVICE_ALLOCATION_TIMEOUT * REMOTE_DEVICE_ALLOCATION_MAX_TRIES} minutes"
|
|
55
56
|
)
|
|
56
|
-
time.sleep(
|
|
57
|
+
time.sleep(REMOTE_DEVICE_ALLOCATION_TIMEOUT * 60)
|
|
58
|
+
retries += 1
|
|
57
59
|
|
|
58
60
|
|
|
59
61
|
def _deallocate_target(
|
|
@@ -65,7 +67,9 @@ def _deallocate_target(
|
|
|
65
67
|
os.environ.pop("REMOTE_DEVICE_NAME", None)
|
|
66
68
|
|
|
67
69
|
|
|
68
|
-
def gui_automation(
|
|
70
|
+
def gui_automation(
|
|
71
|
+
reserve_client: bool = False,
|
|
72
|
+
):
|
|
69
73
|
"""
|
|
70
74
|
Decorator that:
|
|
71
75
|
• Allocates a remote device,
|
|
@@ -88,6 +92,7 @@ def gui_automation():
|
|
|
88
92
|
@functools.wraps(func)
|
|
89
93
|
def wrapper(payload: ClerkCodePayload, *args, **kwargs):
|
|
90
94
|
global global_ws
|
|
95
|
+
force_deallocate = False
|
|
91
96
|
os.environ["PROC_ID"] = payload.run_id
|
|
92
97
|
|
|
93
98
|
remote_device = _allocate_remote_device(
|
|
@@ -116,9 +121,11 @@ def gui_automation():
|
|
|
116
121
|
|
|
117
122
|
except Exception as e:
|
|
118
123
|
os.environ.pop("PROC_ID", None)
|
|
124
|
+
force_deallocate = True
|
|
119
125
|
raise
|
|
120
126
|
finally:
|
|
121
|
-
|
|
127
|
+
if not reserve_client or force_deallocate:
|
|
128
|
+
_deallocate_target(clerk_client, remote_device, payload.run_id)
|
|
122
129
|
|
|
123
130
|
if global_ws and global_ws.state is State.OPEN:
|
|
124
131
|
close_task = event_loop.create_task(close_ws_connection(global_ws))
|
|
@@ -14,7 +14,7 @@ clerk/gui_automation/client_actor/client_actor.py,sha256=Me3NHc0nMA7Y5CUcnE0ZHT1
|
|
|
14
14
|
clerk/gui_automation/client_actor/exception.py,sha256=zdnImHZ88yf52Xq3aMHivEU3aJg-r2c-r8x8XZnI3ic,407
|
|
15
15
|
clerk/gui_automation/client_actor/model.py,sha256=wVpFCi1w2kh4kAV8oNx489vf_SLUQnqhc02rFD5NIJA,6335
|
|
16
16
|
clerk/gui_automation/decorators/__init__.py,sha256=OCgXStEumscgT-RyVy5OKS7ml1w9y-lEnjCVnxuRnQs,43
|
|
17
|
-
clerk/gui_automation/decorators/gui_automation.py,sha256=
|
|
17
|
+
clerk/gui_automation/decorators/gui_automation.py,sha256=O0zZTNeJT_eH1AfWt3h7BWWsuZhqoGo_eIzsu0pmzoQ,5061
|
|
18
18
|
clerk/gui_automation/exceptions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
clerk/gui_automation/exceptions/agent_manager.py,sha256=KFWFWQ7X_8Z9XG__SMzb1jKI3yNoVTPJAXzW5O-fSXc,101
|
|
20
20
|
clerk/gui_automation/exceptions/websocket.py,sha256=-MdwSwlf1hbnu55aDgk3L1znkTZ6xJS6po5VpEGD9ck,117
|
|
@@ -42,8 +42,8 @@ clerk/models/response_model.py,sha256=R62daUN1YVOwgnrh_epvFRsQcOwT7R4u97l73egvm-
|
|
|
42
42
|
clerk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
43
43
|
clerk/utils/logger.py,sha256=_jYOSEc1WCsY9DvU8cIWUPmz41QNjpHTEZ7WrUnmFPA,3650
|
|
44
44
|
clerk/utils/save_artifact.py,sha256=Lwl3l3QqKnSFLFpfEEa-dJ-dV9OxvCU3ADkuYZ18U-Q,1117
|
|
45
|
-
clerk_sdk-0.2.
|
|
46
|
-
clerk_sdk-0.2.
|
|
47
|
-
clerk_sdk-0.2.
|
|
48
|
-
clerk_sdk-0.2.
|
|
49
|
-
clerk_sdk-0.2.
|
|
45
|
+
clerk_sdk-0.2.4.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
|
|
46
|
+
clerk_sdk-0.2.4.dist-info/METADATA,sha256=QXyRQO8-rueo0kDZJqTiFqQotcnfzQG2JD7O-_LtdUI,3508
|
|
47
|
+
clerk_sdk-0.2.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
48
|
+
clerk_sdk-0.2.4.dist-info/top_level.txt,sha256=99eQiU6d05_-f41tmSFanfI_SIJeAdh7u9m3LNSfcv4,6
|
|
49
|
+
clerk_sdk-0.2.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|