Skip to content

Commit 51696d9

Browse files
authored
Merge pull request #45 from UiPath/feat/init-spinner
feat: add spinner for init command
2 parents b6de33c + c197f9e commit 51696d9

File tree

3 files changed

+68
-15
lines changed

3 files changed

+68
-15
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[project]
22
name = "uipath-langchain"
3-
version = "0.0.93"
3+
version = "0.0.94"
44
description = "UiPath Langchain"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.10"
77
dependencies = [
8-
"uipath>=2.0.14, <2.1.0",
8+
"uipath>=2.0.23, <2.1.0",
99
"langgraph>=0.2.70",
1010
"langchain-core>=0.3.34",
1111
"langgraph-checkpoint-sqlite>=2.0.3",

src/uipath_langchain/_cli/cli_init.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import uuid
55
from typing import Any, Dict
66

7+
import click
78
from langgraph.graph.state import CompiledStateGraph
89
from uipath._cli._utils._parse_ast import generate_bindings_json # type: ignore
910
from uipath._cli.middlewares import MiddlewareResult
11+
from uipath._cli.spinner import Spinner
1012

1113
from ._utils._graph import LangGraphConfig
1214

@@ -93,13 +95,15 @@ def generate_schema_from_graph(graph: CompiledStateGraph) -> Dict[str, Any]:
9395

9496
async def langgraph_init_middleware_async(entrypoint: str) -> MiddlewareResult:
9597
"""Middleware to check for langgraph.json and create uipath.json with schemas"""
98+
spinner = Spinner("Initializing UiPath project...")
9699
config = LangGraphConfig()
97100
if not config.exists:
98101
return MiddlewareResult(
99102
should_continue=True
100103
) # Continue with normal flow if no langgraph.json
101104

102105
try:
106+
spinner.start()
103107
config.load_config()
104108
entrypoints = []
105109
all_bindings = {"version": "2.0", "resources": []}
@@ -122,7 +126,6 @@ async def langgraph_init_middleware_async(entrypoint: str) -> MiddlewareResult:
122126
mermaids[graph.name] = compiled_graph.get_graph(xray=1).draw_mermaid()
123127

124128
try:
125-
print("Generating bindings for ", graph.file_path)
126129
# Make sure the file path exists
127130
if os.path.exists(graph.file_path):
128131
file_bindings = generate_bindings_json(graph.file_path)
@@ -132,7 +135,7 @@ async def langgraph_init_middleware_async(entrypoint: str) -> MiddlewareResult:
132135
all_bindings["resources"] = file_bindings["resources"]
133136
except Exception as e:
134137
print(
135-
f"Warning: Could not generate bindings for {graph.file_path}: {str(e)}"
138+
f"⚠️ Warning: Could not generate bindings for {graph.file_path}: {str(e)}"
136139
)
137140

138141
new_entrypoint: dict[str, Any] = {
@@ -145,19 +148,21 @@ async def langgraph_init_middleware_async(entrypoint: str) -> MiddlewareResult:
145148
entrypoints.append(new_entrypoint)
146149

147150
except Exception as e:
151+
spinner.stop()
148152
print(f"Error during graph load: {e}")
149153
return MiddlewareResult(
150154
should_continue=False,
151-
error_message=f"Failed to load graph '{graph.name}': {str(e)}",
155+
error_message=f"Failed to load graph '{graph.name}': {str(e)}",
152156
should_include_stacktrace=True,
153157
)
154158
finally:
155159
await graph.cleanup()
156160

157161
if entrypoint and not entrypoints:
162+
spinner.stop()
158163
return MiddlewareResult(
159164
should_continue=False,
160-
error_message=f"Error: No graph found with name '{entrypoint}'",
165+
error_message=f"Error: No graph found with name '{entrypoint}'",
161166
)
162167

163168
uipath_config = {"entryPoints": entrypoints, "bindings": all_bindings}
@@ -173,21 +178,24 @@ async def langgraph_init_middleware_async(entrypoint: str) -> MiddlewareResult:
173178
with open(mermaid_file_path, "w") as f:
174179
f.write(mermaid_content)
175180
except Exception as write_error:
181+
spinner.stop()
176182
return MiddlewareResult(
177183
should_continue=False,
178-
error_message=f"Error writing mermaid file for '{graph_name}': {str(write_error)}",
184+
error_message=f"Error writing mermaid file for '{graph_name}': {str(write_error)}",
179185
should_include_stacktrace=True,
180186
)
181-
187+
spinner.stop()
182188
return MiddlewareResult(
183189
should_continue=False,
184-
info_message=f"Configuration file {config_path} created successfully.",
190+
info_message=click.style("✓ ", fg="green", bold=True)
191+
+ f" Configuration file {config_path} created successfully.",
185192
)
186193

187194
except Exception as e:
195+
spinner.stop()
188196
return MiddlewareResult(
189197
should_continue=False,
190-
error_message=f"Error processing langgraph configuration: {str(e)}",
198+
error_message=f"Error processing langgraph configuration: {str(e)}",
191199
should_include_stacktrace=True,
192200
)
193201

uv.lock

Lines changed: 50 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)