Skip to content

Commit 6890077

Browse files
authored
Merge pull request #389 from UiPath/feat/bindings
infer bindings
2 parents 7aa0b28 + 3b26f78 commit 6890077

17 files changed

+476
-204
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath"
3-
version = "2.0.59"
3+
version = "2.0.60"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.10"

src/uipath/_cli/_utils/_constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BINDINGS_VERSION = "2.2"

src/uipath/_cli/_utils/_parse_ast.py

Lines changed: 29 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@
33
import ast
44
import os
55
from dataclasses import dataclass, field
6-
from typing import Any, Dict, List, Optional
7-
8-
from ..._services import AssetsService, BucketsService, ProcessesService
6+
from typing import Any, Dict, List, Optional, Tuple
7+
8+
from ..._services import (
9+
AssetsService,
10+
BucketsService,
11+
ContextGroundingService,
12+
ProcessesService,
13+
)
914
from ..._utils import get_inferred_bindings_names
15+
from ._constants import BINDINGS_VERSION
1016

1117

1218
@dataclass
@@ -33,6 +39,14 @@ def extract_string_arg(self, index: int = 0) -> Optional[str]:
3339
"processes": "process",
3440
"buckets": "bucket",
3541
"connections": "connection",
42+
"context_grounding": "index",
43+
}
44+
45+
supported_bindings_by_service = {
46+
"assets": AssetsService,
47+
"processes": ProcessesService,
48+
"buckets": BucketsService,
49+
"context_grounding": ContextGroundingService,
3650
}
3751

3852

@@ -67,48 +81,10 @@ class ServiceUsage:
6781
def get_component_info(self) -> List[Dict[str, str]]:
6882
"""Extract component names and folders based on the service type."""
6983
result = []
70-
71-
if self.service_name == "assets":
72-
for call in self.method_calls:
73-
inferred_bindings = get_inferred_bindings_names(AssetsService)
74-
if call.method_name in inferred_bindings:
75-
name = extract_parameter(
76-
call, inferred_bindings[call.method_name]["name"], 0
77-
)
78-
folder_path = extract_parameter(
79-
call, inferred_bindings[call.method_name]["folder_path"]
80-
)
81-
if name:
82-
result.append(
83-
{
84-
"name": name,
85-
"folder": folder_path or "",
86-
"method": call.method_name,
87-
}
88-
)
89-
90-
elif self.service_name == "processes":
91-
for call in self.method_calls:
92-
inferred_bindings = get_inferred_bindings_names(ProcessesService)
93-
if call.method_name in inferred_bindings:
94-
name = extract_parameter(
95-
call, inferred_bindings[call.method_name]["name"], 0
96-
)
97-
folder_path = extract_parameter(
98-
call, inferred_bindings[call.method_name]["folder_path"]
99-
)
100-
if name:
101-
result.append(
102-
{
103-
"name": name,
104-
"folder": folder_path or "",
105-
"method": call.method_name,
106-
}
107-
)
108-
109-
elif self.service_name == "buckets":
84+
has_support, service_cls = self._support_for_bindings_inference()
85+
if has_support:
11086
for call in self.method_calls:
111-
inferred_bindings = get_inferred_bindings_names(BucketsService)
87+
inferred_bindings = get_inferred_bindings_names(service_cls)
11288
if call.method_name in inferred_bindings:
11389
name = extract_parameter(
11490
call, inferred_bindings[call.method_name]["name"], 0
@@ -125,9 +101,9 @@ def get_component_info(self) -> List[Dict[str, str]]:
125101
}
126102
)
127103

104+
# custom logic for connections bindings
128105
elif self.service_name == "connections":
129106
for call in self.method_calls:
130-
connection_id = None
131107
if len(call.args) > 0:
132108
connection_id = call.args[0]
133109
if connection_id:
@@ -141,6 +117,12 @@ def get_component_info(self) -> List[Dict[str, str]]:
141117

142118
return result
143119

120+
def _support_for_bindings_inference(self) -> Tuple[bool, Any]:
121+
return (
122+
self.service_name in supported_bindings_by_service,
123+
supported_bindings_by_service.get(self.service_name, None),
124+
)
125+
144126

145127
def extract_parameter(
146128
method_call: ServiceMethodCall,
@@ -462,11 +444,10 @@ def convert_to_bindings_format(sdk_usage_data):
462444
"defaultValue": connection_id,
463445
"isExpression": is_connection_id_expression,
464446
"displayName": "Connection",
465-
"description": "The connection to be used",
466447
}
467448
},
468449
"metadata": {
469-
"BindingsVersion": "2.1",
450+
"BindingsVersion": BINDINGS_VERSION,
470451
"Connector": connector_name,
471452
"UseConnectionService": "True",
472453
},
@@ -500,7 +481,7 @@ def convert_to_bindings_format(sdk_usage_data):
500481
},
501482
"metadata": {
502483
"ActivityName": method_name,
503-
"BindingsVersion": "2.1",
484+
"BindingsVersion": BINDINGS_VERSION,
504485
"DisplayLabel": "FullName",
505486
},
506487
}

src/uipath/_cli/cli_init.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Optional
77

88
import click
9+
from dotenv import load_dotenv
910

1011
from ..telemetry import track
1112
from ._utils._console import ConsoleLogger
@@ -56,6 +57,9 @@ def get_user_script(directory: str, entrypoint: Optional[str] = None) -> Optiona
5657
@track
5758
def init(entrypoint: str) -> None:
5859
"""Create uipath.json with input/output schemas and bindings."""
60+
current_path = os.getcwd()
61+
load_dotenv(os.path.join(current_path, ".env"), override=True)
62+
5963
with console.spinner("Initializing UiPath project ..."):
6064
current_directory = os.getcwd()
6165
generate_env_file(current_directory)

0 commit comments

Comments
 (0)