Skip to content

Commit e87eaaa

Browse files
committed
fix: add tenant/org/folder context
1 parent 7f88656 commit e87eaaa

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
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-runtime"
3-
version = "0.0.13"
3+
version = "0.0.14"
44
description = "Runtime abstractions and interfaces for building agents and automation scripts in the UiPath ecosystem"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath/runtime/context.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55
import os
66
from functools import cached_property
77
from pathlib import Path
8-
from typing import (
9-
Any,
10-
TypeVar,
11-
)
8+
from typing import Any
129

1310
from pydantic import BaseModel, ConfigDict
1411

@@ -23,15 +20,17 @@
2320

2421
logger = logging.getLogger(__name__)
2522

26-
C = TypeVar("C", bound="UiPathRuntimeContext")
27-
2823

2924
class UiPathRuntimeContext(BaseModel):
3025
"""Context information passed throughout the runtime execution."""
3126

3227
entrypoint: str | None = None
3328
input: str | None = None
3429
job_id: str | None = None
30+
tenant_id: str | None = None
31+
org_id: str | None = None
32+
folder_key: str | None = None
33+
process_key: str | None = None
3534
config_path: str = "uipath.json"
3635
runtime_dir: str | None = "__uipath"
3736
result_file: str = "output.json"
@@ -253,7 +252,9 @@ def state_file_path(self) -> str:
253252
return os.path.join("__uipath", "state.db")
254253

255254
@classmethod
256-
def with_defaults(cls: type[C], config_path: str | None = None, **kwargs) -> C:
255+
def with_defaults(
256+
cls, config_path: str | None = None, **kwargs
257+
) -> "UiPathRuntimeContext":
257258
"""Construct a context with defaults, reading env vars and config file."""
258259
resolved_config_path = config_path or os.environ.get(
259260
"UIPATH_CONFIG_PATH", "uipath.json"
@@ -270,6 +271,10 @@ def with_defaults(cls: type[C], config_path: str | None = None, **kwargs) -> C:
270271
# Apply defaults from env
271272
base.job_id = os.environ.get("UIPATH_JOB_KEY")
272273
base.logs_min_level = os.environ.get("LOG_LEVEL", "INFO")
274+
base.org_id = os.environ.get("UIPATH_ORGANIZATION_ID")
275+
base.tenant_id = os.environ.get("UIPATH_TENANT_ID")
276+
base.process_key = os.environ.get("UIPATH_PROCESS_UUID")
277+
base.folder_key = os.environ.get("UIPATH_FOLDER_KEY")
273278

274279
# Override with kwargs
275280
for k, v in kwargs.items():
@@ -278,7 +283,9 @@ def with_defaults(cls: type[C], config_path: str | None = None, **kwargs) -> C:
278283
return base
279284

280285
@classmethod
281-
def from_config(cls: type[C], config_path: str | None = None, **kwargs) -> C:
286+
def from_config(
287+
cls, config_path: str | None = None, **kwargs
288+
) -> "UiPathRuntimeContext":
282289
"""Load configuration from uipath.json file."""
283290
path = config_path or "uipath.json"
284291
config = {}

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)