Skip to content

Commit 29ade91

Browse files
committed
fix(env): choose the correct .env file from cwd
1 parent e7f6285 commit 29ade91

16 files changed

Lines changed: 22 additions & 36 deletions

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.1.31"
3+
version = "2.1.32"
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/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import click
55

6+
from ._utils._common import load_environment_variables
67
from .cli_auth import auth as auth
78
from .cli_deploy import deploy as deploy # type: ignore
89
from .cli_dev import dev as dev
@@ -43,6 +44,7 @@ def _get_safe_version() -> str:
4344
help="Display the current version of uipath.",
4445
)
4546
def cli(lv: bool, v: bool) -> None:
47+
load_environment_variables()
4648
if lv:
4749
try:
4850
version = importlib.metadata.version("uipath-langchain")

src/uipath/_cli/_auth/_auth_server.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
import time
88
from typing import Optional
99

10-
from dotenv import load_dotenv
11-
10+
from .._utils._common import load_environment_variables
1211
from ._oidc_utils import get_auth_config
1312

14-
load_dotenv(override=True)
13+
load_environment_variables()
1514

1615
# Server port
1716
PORT = 6234

src/uipath/_cli/_evals/progress_reporter.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
import json
44
import logging
55
import os
6-
from typing import Any, List
6+
from typing import TYPE_CHECKING, Any, List
7+
8+
if TYPE_CHECKING:
9+
pass
710

8-
from uipath import UiPath
911
from uipath._cli._evals._evaluators import EvaluatorBase
1012
from uipath._cli._evals._models._evaluation_set import EvaluationStatus
1113
from uipath._cli._evals._models._evaluators import EvalItemResult, ScoreType
@@ -32,6 +34,8 @@ def __init__(
3234
no_of_evals: Number of evaluations in the set
3335
evaluators: List of evaluator instances
3436
"""
37+
from uipath import UiPath
38+
3539
self._eval_set_id = eval_set_id
3640
self.agent_snapshot = agent_snapshot
3741
self._no_of_evals = no_of_evals

src/uipath/_cli/_utils/_common.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from urllib.parse import urlparse
44

55
import click
6+
from dotenv import find_dotenv, load_dotenv
67

78
from ..spinner import Spinner
89

@@ -102,3 +103,7 @@ def clean_directory(directory: str) -> None:
102103

103104
if os.path.isfile(file_path) and file_name.endswith(".py"):
104105
os.remove(file_path)
106+
107+
108+
def load_environment_variables():
109+
load_dotenv(dotenv_path=find_dotenv(usecwd=True), override=True)

src/uipath/_cli/cli_auth.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from urllib.parse import urlparse
88

99
import click
10-
from dotenv import load_dotenv
1110

1211
from ..telemetry import track
1312
from ._auth._auth_server import HTTPServer
@@ -18,7 +17,6 @@
1817
from ._utils._common import environment_options
1918
from ._utils._console import ConsoleLogger
2019

21-
load_dotenv(override=True)
2220
console = ConsoleLogger()
2321

2422

src/uipath/_cli/cli_eval.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
from typing import List, Optional, Tuple
66

77
import click
8-
from dotenv import load_dotenv
98

109
from .._utils.constants import ENV_JOB_ID
1110
from ..telemetry import track
1211
from ._evals.evaluation_service import EvaluationService
1312
from ._utils._console import ConsoleLogger
1413

1514
console = ConsoleLogger()
16-
load_dotenv(override=True)
1715

1816

1917
class LiteralOption(click.Option):

src/uipath/_cli/cli_init.py

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

88
import click
9-
from dotenv import load_dotenv
109

1110
from .._utils.constants import ENV_TELEMETRY_ENABLED
1211
from ..telemetry import track
@@ -125,9 +124,6 @@ def write_config_file(config_data: Dict[str, Any]) -> None:
125124
@track
126125
def init(entrypoint: str, infer_bindings: bool) -> None:
127126
"""Create uipath.json with input/output schemas and bindings."""
128-
current_path = os.getcwd()
129-
load_dotenv(os.path.join(current_path, ".env"), override=True)
130-
131127
with console.spinner("Initializing UiPath project ..."):
132128
current_directory = os.getcwd()
133129
generate_env_file(current_directory)

src/uipath/_cli/cli_invoke.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import click
77
import httpx
8-
from dotenv import load_dotenv
98

109
from ._utils._console import ConsoleLogger
1110

@@ -21,7 +20,6 @@
2120
from ._utils._processes import get_release_info
2221

2322
logger = logging.getLogger(__name__)
24-
load_dotenv(override=True)
2523
console = ConsoleLogger()
2624

2725

@@ -63,8 +61,6 @@ def invoke(
6361
with open(file) as f:
6462
input = f.read()
6563
with console.spinner("Loading configuration ..."):
66-
current_path = os.getcwd()
67-
load_dotenv(os.path.join(current_path, ".env"), override=True)
6864
[base_url, token] = get_env_vars()
6965

7066
url = f"{base_url}/orchestrator_/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs"

src/uipath/_cli/cli_publish.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import click
66
import httpx
7-
from dotenv import load_dotenv
87

98
from .._utils._ssl_context import get_httpx_client_kwargs
109
from ..telemetry import track
@@ -70,9 +69,6 @@ def get_available_feeds(
7069
@track
7170
def publish(feed):
7271
"""Publish the package."""
73-
current_path = os.getcwd()
74-
load_dotenv(os.path.join(current_path, ".env"), override=True)
75-
7672
[base_url, token] = get_env_vars()
7773
headers = {"Authorization": f"Bearer {token}"}
7874

0 commit comments

Comments
 (0)