uipath 2.0.64__py3-none-any.whl → 2.0.66__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.

Potentially problematic release.


This version of uipath might be problematic. Click here for more details.

@@ -19,20 +19,47 @@ from .._utils._common import serialize_object
19
19
  from ._escalation import Escalation
20
20
 
21
21
 
22
- def _try_convert_to_json_format(value: str) -> str:
22
+ def _try_convert_to_json_format(value: str | None) -> str | None:
23
+ """Attempts to parse a string as JSON and returns the parsed object or original string.
24
+
25
+ Args:
26
+ value: The string value to attempt JSON parsing on.
27
+
28
+ Returns:
29
+ The parsed JSON object if successful, otherwise the original string value.
30
+ """
23
31
  try:
32
+ if not value:
33
+ return None
24
34
  return json.loads(value)
25
35
  except json.decoder.JSONDecodeError:
26
36
  return value
27
37
 
28
38
 
29
- default_escalation = Escalation()
30
-
31
-
32
39
  class HitlReader:
40
+ """Handles reading and retrieving Human-In-The-Loop (HITL) data from UiPath services."""
41
+
33
42
  @classmethod
34
43
  async def read(cls, resume_trigger: UiPathResumeTrigger) -> Optional[str]:
44
+ """Reads data from a UiPath resume trigger based on its type.
45
+
46
+ This method handles different types of resume triggers (ACTION, JOB, API) and retrieves
47
+ the appropriate data from UiPath services. For actions, it retrieves action data with
48
+ optional escalation processing. For jobs, it retrieves job output and validates success.
49
+ For API triggers, it retrieves the API payload.
50
+
51
+ Args:
52
+ resume_trigger: The UiPath resume trigger containing the trigger type and metadata.
53
+
54
+ Returns:
55
+ The retrieved data as a string, or None if no data is available.
56
+
57
+ Raises:
58
+ UiPathRuntimeError: If the job failed, API connection failed, trigger type is unknown,
59
+ or HITL feedback retrieval failed.
60
+ """
35
61
  uipath = UiPath()
62
+ default_escalation = Escalation()
36
63
  match resume_trigger.trigger_type:
37
64
  case UiPathResumeTriggerType.ACTION:
38
65
  if resume_trigger.item_key:
@@ -62,9 +89,10 @@ class HitlReader:
62
89
  raise UiPathRuntimeError(
63
90
  "INVOKED_PROCESS_FAILURE",
64
91
  "Invoked process did not finish successfully.",
65
- _try_convert_to_json_format(str(job.job_error or job.info)),
92
+ _try_convert_to_json_format(str(job.job_error or job.info))
93
+ or "Job error unavailable.",
66
94
  )
67
- return job.output_arguments
95
+ return _try_convert_to_json_format(job.output_arguments)
68
96
 
69
97
  case UiPathResumeTriggerType.API:
70
98
  if resume_trigger.api_resume and resume_trigger.api_resume.inbox_id:
@@ -97,13 +125,30 @@ class HitlReader:
97
125
 
98
126
  @dataclass
99
127
  class HitlProcessor:
100
- """Processes events in a Human-(Robot/Agent)-In-The-Loop scenario."""
128
+ """Processes events in a Human-(Robot/Agent)-In-The-Loop scenario.
129
+
130
+ This class handles the creation and processing of HITL resume triggers for different
131
+ types of UiPath operations including actions, jobs, and API calls. It determines the
132
+ appropriate trigger type based on the input value and creates the corresponding
133
+ resume trigger with proper configuration.
134
+
135
+ Attributes:
136
+ value: The input value to be processed, can be various UiPath model types or strings.
137
+ """
101
138
 
102
139
  value: Any
103
140
 
104
141
  @cached_property
105
142
  def type(self) -> UiPathResumeTriggerType:
106
- """Returns the type of the interrupt value."""
143
+ """Determines the resume trigger type based on the input value.
144
+
145
+ Analyzes the input value type and returns the corresponding UiPath resume trigger type.
146
+ Actions (CreateAction, WaitAction) map to ACTION type, jobs (InvokeProcess, WaitJob)
147
+ map to JOB type, and all other values default to API type.
148
+
149
+ Returns:
150
+ The appropriate UiPathResumeTriggerType based on the input value type.
151
+ """
107
152
  if isinstance(self.value, CreateAction) or isinstance(self.value, WaitAction):
108
153
  return UiPathResumeTriggerType.ACTION
109
154
  if isinstance(self.value, InvokeProcess) or isinstance(self.value, WaitJob):
@@ -112,8 +157,26 @@ class HitlProcessor:
112
157
  return UiPathResumeTriggerType.API
113
158
 
114
159
  async def create_resume_trigger(self) -> UiPathResumeTrigger:
115
- """Returns the resume trigger."""
160
+ """Creates a UiPath resume trigger based on the input value and its type.
161
+
162
+ This method processes the input value and creates an appropriate resume trigger
163
+ for HITL scenarios. It handles different input types:
164
+ - Actions: Creates or references UiPath actions with folder information
165
+ - Jobs: Invokes processes or references existing jobs with folder information
166
+ - API: Creates API triggers with generated inbox IDs
167
+ - String with escalation: Creates escalated actions
168
+
169
+ Returns:
170
+ A configured UiPathResumeTrigger ready for HITL processing.
171
+
172
+ Raises:
173
+ UiPathRuntimeError: If action/job creation fails, escalation fails, or an
174
+ unknown model type is encountered.
175
+ Exception: If any underlying UiPath service calls fail.
176
+ """
116
177
  uipath = UiPath()
178
+ default_escalation = Escalation()
179
+
117
180
  try:
118
181
  hitl_input = self.value
119
182
  resume_trigger = UiPathResumeTrigger(
@@ -0,0 +1,52 @@
1
+ """Debug utilities for UiPath CLI."""
2
+
3
+ import os
4
+
5
+ from ._console import ConsoleLogger
6
+
7
+ console = ConsoleLogger()
8
+
9
+
10
+ def setup_debugging(debug: bool, debug_port: int = 5678) -> bool:
11
+ """Setup debugging with debugpy if requested.
12
+
13
+ Args:
14
+ debug: Whether to enable debugging
15
+ debug_port: Port for the debug server (default: 5678)
16
+
17
+ Returns:
18
+ bool: True if debugging was setup successfully or not requested, False on error
19
+ """
20
+ if not debug:
21
+ return True
22
+
23
+ # Set environment variables to improve debugging
24
+ os.environ["PYDEVD_DISABLE_FILE_VALIDATION"] = "1"
25
+ os.environ["PYDEVD_USE_FRAME_EVAL"] = "NO"
26
+
27
+ # Try to import debugpy, log warning if not available
28
+ try:
29
+ import debugpy # type: ignore[import-not-found]
30
+ except ImportError:
31
+ console.warning(
32
+ "debugpy not found, please install it and retry: '[uv] pip install debugpy'"
33
+ )
34
+ return False
35
+
36
+ # Configure debugpy for better breakpoint handling
37
+ try:
38
+ # Clear any existing listeners
39
+ debugpy.configure(subProcess=False)
40
+
41
+ debugpy.listen(debug_port)
42
+ console.info(f"🐛 Debug server started on port {debug_port}")
43
+ console.info("📌 Waiting for debugger to attach...")
44
+ console.info(" - VS Code: Run -> Start Debugging -> Python: Remote Attach")
45
+
46
+ debugpy.wait_for_client()
47
+ console.success("Debugger attached successfully!")
48
+
49
+ return True
50
+ except Exception as e:
51
+ console.error(f"Failed to start debug server on port {debug_port}: {str(e)}")
52
+ return False
uipath/_cli/cli_run.py CHANGED
@@ -9,6 +9,8 @@ from uuid import uuid4
9
9
  import click
10
10
  from dotenv import load_dotenv
11
11
 
12
+ from uipath._cli._utils._debug import setup_debugging
13
+
12
14
  from .._utils.constants import (
13
15
  ENV_JOB_ID,
14
16
  )
@@ -27,7 +29,9 @@ load_dotenv(override=True)
27
29
 
28
30
 
29
31
  def python_run_middleware(
30
- entrypoint: Optional[str], input: Optional[str], resume: bool
32
+ entrypoint: Optional[str],
33
+ input: Optional[str],
34
+ resume: bool,
31
35
  ) -> MiddlewareResult:
32
36
  """Middleware to handle Python script execution.
33
37
 
@@ -35,6 +39,8 @@ def python_run_middleware(
35
39
  entrypoint: Path to the Python script to execute
36
40
  input: JSON string with input data
37
41
  resume: Flag indicating if this is a resume execution
42
+ debug: Enable debugging with debugpy
43
+ debug_port: Port for debug server (default: 5678)
38
44
 
39
45
  Returns:
40
46
  MiddlewareResult with execution status and messages
@@ -112,9 +118,25 @@ Usage: `uipath run <entrypoint_path> <input_arguments> [-f <input_json_file_path
112
118
  type=click.Path(exists=True),
113
119
  help="File path for the .json input",
114
120
  )
121
+ @click.option(
122
+ "--debug",
123
+ is_flag=True,
124
+ help="Enable debugging with debugpy. The process will wait for a debugger to attach.",
125
+ )
126
+ @click.option(
127
+ "--debug-port",
128
+ type=int,
129
+ default=5678,
130
+ help="Port for the debug server (default: 5678)",
131
+ )
115
132
  @track(when=lambda *_a, **_kw: env.get(ENV_JOB_ID) is None)
116
133
  def run(
117
- entrypoint: Optional[str], input: Optional[str], resume: bool, file: Optional[str]
134
+ entrypoint: Optional[str],
135
+ input: Optional[str],
136
+ resume: bool,
137
+ file: Optional[str],
138
+ debug: bool,
139
+ debug_port: int,
118
140
  ) -> None:
119
141
  """Execute the project."""
120
142
  if file:
@@ -123,12 +145,19 @@ def run(
123
145
  console.error("Input file extension must be '.json'.")
124
146
  with open(file) as f:
125
147
  input = f.read()
148
+ # Setup debugging if requested
149
+
150
+ if not setup_debugging(debug, debug_port):
151
+ console.error(f"Failed to start debug server on port {debug_port}")
152
+
126
153
  # Process through middleware chain
127
154
  result = Middlewares.next("run", entrypoint, input, resume)
128
155
 
129
156
  if result.should_continue:
130
157
  result = python_run_middleware(
131
- entrypoint=entrypoint, input=input, resume=resume
158
+ entrypoint=entrypoint,
159
+ input=input,
160
+ resume=resume,
132
161
  )
133
162
 
134
163
  # Handle result from middleware
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: uipath
3
- Version: 2.0.64
3
+ Version: 2.0.66
4
4
  Summary: Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools.
5
5
  Project-URL: Homepage, https://uipath.com
6
6
  Project-URL: Repository, https://github.com/UiPath/uipath-python
@@ -13,7 +13,7 @@ uipath/_cli/cli_invoke.py,sha256=IjndcDWBpvAqGCRanQU1vfmxaBF8FhyZ7gWuZqwjHrU,381
13
13
  uipath/_cli/cli_new.py,sha256=9378NYUBc9j-qKVXV7oja-jahfJhXBg8zKVyaon7ctY,2102
14
14
  uipath/_cli/cli_pack.py,sha256=8Ahk0vr_8eqMsq9ehhYWNfeII0VIiZVBXMpRF7Dbvtg,15018
15
15
  uipath/_cli/cli_publish.py,sha256=Ba0TJ1TSfuQbLU2AIgtM8QWkLHgr4tsAP1CaX12113U,6010
16
- uipath/_cli/cli_run.py,sha256=0q_DqM2QNfD8yOqUZB_5BTg96pCLzbHE1enD_XAj6CE,5215
16
+ uipath/_cli/cli_run.py,sha256=zYg-9U6mkofdGsE0IGjYi1dOMlG8CdBxiVGxfFiLq5Y,5882
17
17
  uipath/_cli/middlewares.py,sha256=IiJgjsqrJVKSXx4RcIKHWoH-SqWqpHPbhzkQEybmAos,3937
18
18
  uipath/_cli/spinner.py,sha256=bS-U_HA5yne11ejUERu7CQoXmWdabUD2bm62EfEdV8M,1107
19
19
  uipath/_cli/_auth/_auth_server.py,sha256=p93_EvJpdoLLkiVmLygHRKo9ru1-PZOEAaEhNFN3j6c,6424
@@ -27,7 +27,7 @@ uipath/_cli/_auth/localhost.crt,sha256=oGl9oLLOiouHubAt39B4zEfylFvKEtbtr_43SIliX
27
27
  uipath/_cli/_auth/localhost.key,sha256=X31VYXD8scZtmGA837dGX5l6G-LXHLo5ItWJhZXaz3c,1679
28
28
  uipath/_cli/_runtime/_contracts.py,sha256=Rxs-uEOA490fLPNimB8LqZW7KI-72O0BLY4Jm7Fa1ms,14316
29
29
  uipath/_cli/_runtime/_escalation.py,sha256=x3vI98qsfRA-fL_tNkRVTFXioM5Gv2w0GFcXJJ5eQtg,7981
30
- uipath/_cli/_runtime/_hitl.py,sha256=zcyQmU-lTMklMpAPY8ifAbyo9Dv6ZDp6iCOoVFZxE0c,8331
30
+ uipath/_cli/_runtime/_hitl.py,sha256=aexwe0dIXvh6SlVS1jVnO_aGZc6e3gLsmGkCyha5AHo,11300
31
31
  uipath/_cli/_runtime/_logging.py,sha256=lA2LsakOrcSLnJWgo80-BYzIQBUWfqzzJGI1M61Gu0s,7874
32
32
  uipath/_cli/_runtime/_runtime.py,sha256=-ZA7MZctX3e_YX_SN9XFjtsQKaCZCdBL3YRYFmsacN4,10162
33
33
  uipath/_cli/_templates/.psmdcp.template,sha256=C7pBJPt98ovEljcBvGtEUGoWjjQhu9jls1bpYjeLOKA,611
@@ -38,6 +38,7 @@ uipath/_cli/_templates/package.nuspec.template,sha256=YZyLc-u_EsmIoKf42JsLQ55OGe
38
38
  uipath/_cli/_utils/_common.py,sha256=wQ0a_lGj0bsuNvwxUfnLwg6T3IdatdfkrPcZMoufJNU,2058
39
39
  uipath/_cli/_utils/_console.py,sha256=rj4V3yeR1wnJzFTHnaE6wcY9OoJV-PiIQnLg_p62ClQ,6664
40
40
  uipath/_cli/_utils/_constants.py,sha256=mCeSWLURgw_dOMXjzyYBAvxKN3Vcd1vf7XKHgbdrOds,25
41
+ uipath/_cli/_utils/_debug.py,sha256=XlMkjtXT6hqyn7huioLDaVSYqo9fyWCvTkqEJh_ZEGw,1598
41
42
  uipath/_cli/_utils/_folders.py,sha256=usjLNOMdhvelEv0wsJ-v6q-qiUR1tbwXJL4Sd_SOocI,970
42
43
  uipath/_cli/_utils/_input_args.py,sha256=pyQhEcQXHdFHYTVNzvfWp439aii5StojoptnmCv5lfs,4094
43
44
  uipath/_cli/_utils/_parse_ast.py,sha256=A-QToBIf-oP7yP2DQTHO6blkk6ik5z_IeaIwtEWO4e0,19516
@@ -90,8 +91,8 @@ uipath/tracing/__init__.py,sha256=GKRINyWdHVrDsI-8mrZDLdf0oey6GHGlNZTOADK-kgc,22
90
91
  uipath/tracing/_otel_exporters.py,sha256=x0PDPmDKJcxashsuehVsSsqBCzRr6WsNFaq_3_HS5F0,3014
91
92
  uipath/tracing/_traced.py,sha256=qeVDrds2OUnpdUIA0RhtF0kg2dlAZhyC1RRkI-qivTM,18528
92
93
  uipath/tracing/_utils.py,sha256=ZeensQexnw69jVcsVrGyED7mPlAU-L1agDGm6_1A3oc,10388
93
- uipath-2.0.64.dist-info/METADATA,sha256=3wKXRRMa7h8XVtGrCXXr6S9YUkHwsr_C-MYQ2eSqn_k,6304
94
- uipath-2.0.64.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
95
- uipath-2.0.64.dist-info/entry_points.txt,sha256=9C2_29U6Oq1ExFu7usihR-dnfIVNSKc-0EFbh0rskB4,43
96
- uipath-2.0.64.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
97
- uipath-2.0.64.dist-info/RECORD,,
94
+ uipath-2.0.66.dist-info/METADATA,sha256=YvHAH6jQRsjeveGyJ8_IarkNOYgTQ4v9fHY_04rtw4E,6304
95
+ uipath-2.0.66.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
96
+ uipath-2.0.66.dist-info/entry_points.txt,sha256=9C2_29U6Oq1ExFu7usihR-dnfIVNSKc-0EFbh0rskB4,43
97
+ uipath-2.0.66.dist-info/licenses/LICENSE,sha256=-KBavWXepyDjimmzH5fVAsi-6jNVpIKFc2kZs0Ri4ng,1058
98
+ uipath-2.0.66.dist-info/RECORD,,