diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 16c0160fd..d8989f611 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,19 +4,17 @@ ### Prerequisites -1. **Install Python 3.13**: - - Download and install Python 3.13 from the official [Python website](https://www.python.org/downloads/) +1. **Install Python ≥ 3.10**: + - Download and install Python 3.10 from the official [Python website](https://www.python.org/downloads/) - Verify the installation by running: ```sh - python3.13 --version + python3.10 --version ``` Alternative: [mise](https://mise.jdx.dev/lang/python.html) 2. **Install [uv](https://docs.astral.sh/uv/)**: - ```sh - pip install uv - ``` + Follow the official installation instructions for your operating system. 3. **Create a virtual environment in the current working directory**: ```sh @@ -25,45 +23,61 @@ 4. **Install dependencies**: ```sh - uv sync --all-extras + uv sync --all-extras --no-cache + ``` + +For additional commands related to linting, formatting, and building, run `just --list`. + +### Using the SDK Locally + +1. Create a project directory: + ```sh + mkdir project + cd project ``` -See `just --list` for linting, formatting and build commands. +2. Initialize the Python project: + ```sh + uv init . --python 3.10 + ``` +3. Set the SDK path: + ```sh + PATH_TO_SDK=/Users/YOUR_USERNAME/uipath-python + ``` -### Use SDK Locally -1. Create a folder on your own device `mkdir project; cd project` -2. Initialize the python project `uv` `uv init . --python 3.9` -3. Obtain the project path `PATH_TO_SDK=/Users/YOU_USER/uipath-python` -4. Install the sdk in editable mode `uv add --editable ${PATH_TO_SDK}` +4. Install the SDK in editable mode: + ```sh + uv add --editable ${PATH_TO_SDK} + ``` -:information_source: Instead of cloning the project into `.venv/lib/python3.9/site-packages/uipath`, this mode creates a file named `_uipath.pth` inside `.venv/lib/python3.9/site-packages`. This file contains the value of `PATH_TO_SDK`, which is added to `sys.path`—the list of directories where python searches for packages. (Run `python -c 'import sys; print(sys.path)'` to see the entries.) +> **Note:** Instead of cloning the project into `.venv/lib/python3.10/site-packages/uipath`, this mode creates a file named `_uipath.pth` inside `.venv/lib/python3.10/site-packages`. This file contains the value of `PATH_TO_SDK`, which is added to `sys.path`—the list of directories where Python searches for packages. To view the entries, run `python -c 'import sys; print(sys.path)'`. ## API Style Guide -### General Rule: -- use key instead of ID +### General Rule +- Use `key` instead of `id` for resource identifiers -### Standard Methods & Naming Conventions +### Standard Methods and Naming Conventions #### Retrieve a Single Resource -- **Method Name:** `retrieve` instead of get -- **Usage:** To obtain a specific resource instance using its unique identifier (using *key* instead of ID). -- **Extended:** - - `retrieve_by_[field_name]` (for fields other than key) +- **Method Name:** `retrieve` +- **Purpose:** Obtain a specific resource instance using its unique identifier (using `key` instead of `id`) +- **Variations:** + - `retrieve_by_[field_name]` (for fields other than `key`) #### List Multiple Resources - **Method Name:** `list` -- **Usage:** To fetch a collection of resources, optionally filtered by query parameters. +- **Purpose:** Fetch a collection of resources, optionally filtered by query parameters - **Example:** - ```python - resources = Resource.list(filters={}) - ``` + ```python + resources = Resource.list(filters={}) + ``` #### Create a Resource - **Method Name:** `create` -- **Usage:** To add a new resource to the system. +- **Purpose:** Add a new resource to the system #### Update a Resource - **Method Name:** `update` -- **Usage:** To modify an existing resource. +- **Purpose:** Modify an existing resource diff --git a/README.md b/README.md index 1772e113d..8e90ebe7e 100644 --- a/README.md +++ b/README.md @@ -4,29 +4,29 @@ [![PyPI - Version](https://img.shields.io/pypi/v/uipath)](https://img.shields.io/pypi/v/uipath) [![Python versions](https://img.shields.io/pypi/pyversions/uipath.svg)](https://pypi.org/project/uipath/) - A Python SDK that enables programmatic interaction with UiPath Platform services including processes, assets, buckets, context grounding, data services, jobs, and more. The package also features a CLI for creation, packaging, and deployment of automations to UiPath Platform. -Use the [UiPath LangChain SDK](https://github.com/UiPath/uipath-langchain-python) to pack and publish LangGraph Agents. +Use the [UiPath LangChain SDK](https://github.com/UiPath/uipath-langchain-python) to pack and publish LangGraph Agents. + ## Table of Contents -- [Installation](#installation) -- [Configuration](#configuration) - - [Environment Variables](#environment-variables) -- [Basic Usage](#basic-usage) -- [Available Services](#available-services) -- [Examples](#examples) - - [Buckets Service](#buckets-service) - - [Context Grounding Service](#context-grounding-service) -- [Command Line Interface (CLI)](#command-line-interface-cli) - - [Authentication](#authentication) - - [Initialize a Project](#initialize-a-project) - - [Debug a Project](#debug-a-project) - - [Package a Project](#package-a-project) - - [Publish a Package](#publish-a-package) -- [Project Structure](#project-structure) -- [Development](#development) - - [Setting Up a Development Environment](#setting-up-a-development-environment) +- [Installation](#installation) +- [Configuration](#configuration) + - [Environment Variables](#environment-variables) +- [Basic Usage](#basic-usage) +- [Available Services](#available-services) +- [Examples](#examples) + - [Buckets Service](#buckets-service) + - [Context Grounding Service](#context-grounding-service) +- [Command Line Interface (CLI)](#command-line-interface-cli) + - [Authentication](#authentication) + - [Initialize a Project](#initialize-a-project) + - [Debug a Project](#debug-a-project) + - [Package a Project](#package-a-project) + - [Publish a Package](#publish-a-package) +- [Project Structure](#project-structure) +- [Development](#development) + - [Setting Up a Development Environment](#setting-up-a-development-environment) ## Installation @@ -69,15 +69,24 @@ asset = sdk.assets.retrieve(name="MyAsset") ## Available Services The SDK provides access to various UiPath services: -- `sdk.processes` - Manage and execute UiPath automation processes -- `sdk.assets` - Work with assets (variables, credentials) stored in UiPath -- `sdk.buckets` - Manage cloud storage containers for automation files -- `sdk.connections` - Handle connections to external systems -- `sdk.context_grounding` - Work with semantic contexts for AI-enabled automation -- `sdk.jobs` - Monitor and manage automation jobs -- `sdk.queues` - Work with transaction queues -- `sdk.actions` - Work with Action Center -- `sdk.api_client` - Direct access to the API client for custom requests + +- `sdk.processes` - Manage and execute UiPath automation processes + +- `sdk.assets` - Work with assets (variables, credentials) stored in UiPath + +- `sdk.buckets` - Manage cloud storage containers for automation files + +- `sdk.connections` - Handle connections to external systems + +- `sdk.context_grounding` - Work with semantic contexts for AI-enabled automation + +- `sdk.jobs` - Monitor and manage automation jobs + +- `sdk.queues` - Work with transaction queues + +- `sdk.actions` - Work with Action Center + +- `sdk.api_client` - Direct access to the API client for custom requests ## Examples @@ -140,10 +149,12 @@ uipath pack Packages your project into a `.nupkg` file that can be deployed to UiPath. **Note:** Your `pyproject.toml` must include: -- A description field (avoid characters: &, <, >, ", ', ;) -- Author information + +- A description field (avoid characters: &, <, >, ", ', ;) +- Author information Example: + ```toml description = "Your package description" authors = [{name = "Your Name", email = "your.email@example.com"}] @@ -160,12 +171,13 @@ Publishes the most recently created package to your UiPath Orchestrator. ## Project Structure To properly use the CLI for packaging and publishing, your project should include: -- A `pyproject.toml` file with project metadata -- A `uipath.json` file (generated by `uipath init`) -- Any Python files needed for your automation + +- A `pyproject.toml` file with project metadata +- A `uipath.json` file (generated by `uipath init`) +- Any Python files needed for your automation ## Development ### Setting Up a Development Environment -Please read our [contribution guidelines](CONTRIBUTING.md) before submitting a pull request. +Please read [CONTRIBUTING.md](https://uipath.github.io/uipath-python/how_to_contribute/) before submitting a pull request. diff --git a/docs/getting_started.md b/docs/getting_started.md new file mode 100644 index 000000000..de23fd98e --- /dev/null +++ b/docs/getting_started.md @@ -0,0 +1,205 @@ +# Getting Started + +## Prerequisites + +- Python 3.10 or higher +- `pip` or `uv` package manager +- A UiPath Platform account with appropriate permissions + +## Creating a New Project + +We recommend using `uv` for package management. To create a new project: + +```shell +mkdir example +cd example +uv init . --python 3.10 +``` + +This command creates a basic project structure. + +### Installing the UiPath SDK + +Add the UiPath SDK to your project: + +```shell +uv add uipath +``` + +To verify the installation, run: + +```shell +uv run uipath --version +``` + +### Authentication + +To debug your script locally and publish your project, you need to authenticate with UiPath: + +```shell +uv run uipath auth +``` + +This command opens a new browser window. If you encounter any issues, copy the URL from the terminal and paste it into your browser. After authentication, select your tenant by typing its corresponding number in the terminal. + +After completing this step, your project will contain a `.env` file with your access token, UiPath URL, and other configuration details. + +### Writing Your Code + +Open `main.py` in your code editor. You can start with this example code: + +```python +from dataclasses import dataclass +from typing import Optional + + +@dataclass +class EchoIn: + message: str + repeat: Optional[int] = 1 + prefix: Optional[str] = None + + +@dataclass +class EchoOut: + message: str + + +def main(input: EchoIn) -> EchoOut: + result = [] + for _ in range(input.repeat or 1): + line = input.message + if input.prefix: + line = f"{input.prefix}: {line}" + result.append(line) + + return EchoOut(message="\n".join(result)) +``` + +### Initializing the UiPath Project + +To create a UiPath project, run the following command in your terminal: + +```shell +uv run uipath init +``` + +> **Note:**: The `uipath init` command will execute your `main.py` file to analyze its structure and collect information about inputs and outputs. + +This creates a `uipath.json` file containing the project metadata. + +### Debugging Your Project + +To debug your project, run: + +```shell +uv run uipath run main.py '{"message": "test"}' +``` + +If you see output similar to the following, congratulations! You're almost ready to create your first coded package for UiPath: + +```shell +[2025-04-11 10:13:58,857][INFO] {'message': 'test'} +``` + +### Packaging and Publishing + +Before packaging your project, add your details to the `pyproject.toml` file. Add the following line below the `description` field: + +```toml +authors = [{ name = "Your name", email = "your.email@uipath.com" }] +``` + +Then, package your project: + +```shell +uv run uipath pack +``` + +Finally, publish your package. After selecting your publishing destination (tenant or personal workspace), you'll see details about your package and the success message: + +```shell +Publishing most recent package: test.0.1.0.nupkg +Package published successfully! +``` + +## Using the SDK + +### Creating a Process Client + +Now, let's create a new project to invoke the process we just created. We'll skip the installation and authentication steps since they're covered above. + +Create a new project: + +```shell +mkdir test2 +cd test2 +uv init . --python 3.10 +uv add uipath +``` + +### Configuring the Project + +First, open `.env` in your code editor and specify the folder where you want to run the code. For example, to use the "Shared" folder: + +```shell +UIPATH_FOLDER_PATH=Shared +``` + +### Writing the Client Code + +Open `main.py` in your code editor and add the following code: + +```python +from uipath import UiPath + + +def main(): + sdk = UiPath() + sdk.processes.invoke( + "test-pack", + input_arguments={ + "message": "Hello, World!", + "repeat": 3, + "prefix": "[Echo]" + } + ) +``` + +> **Note:**: `test-pack` is the name of the process we created from the previous package. + +### Verifying the Execution + +Open your browser and navigate to UiPath. Go to the specified folder, and you'll see a new job for `test-pack` has been executed. The output will be: + +``` +[Echo]: Hello, World! Echo: Hello, World! Echo: Hello, World! +``` + +## Using an Agent Based on LangGraph + +To use the UiPath SDK with a LangGraph-based project: + +1. Add the `uipath-langchain` package to your project: + + ```shell + uv add uipath-langchain + ``` + +2. Initialize the project by running the following command in your activated virtual environment: + + ```shell + uipath init + ``` + + > **Note:**: The `uipath init` command will execute your code to analyze its structure and collect information about inputs and outputs. + +3. Package and publish your project: + ```shell + uipath pack + uipath publish + ``` + +This will create and publish your package to the UiPath platform, making it available for use in your automation workflows. + +For more examples and implementation patterns, check out the [sample projects](https://github.com/UiPath/uipath-langchain-python/tree/main/samples) in our GitHub repository. diff --git a/mkdocs.yml b/mkdocs.yml index f062f95ad..8cd289ca3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -34,6 +34,7 @@ theme: logo: assets/uipath-logo.svg nav: + - Getting Started: getting_started.md - Home: - index.md - Actions: actions.md diff --git a/pyproject.toml b/pyproject.toml index a5c0d7e0e..863279e52 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "uipath" -version = "2.0.4.dev4" +version = "2.0.5" description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools." readme = { file = "README.md", content-type = "text/markdown" } requires-python = ">=3.10" @@ -56,7 +56,7 @@ dev = [ ] [project.optional-dependencies] -langchain = ["uipath-langchain==0.0.85"] +langchain = ["uipath-langchain>=0.0.88,<0.1.0"] [tool.ruff] line-length = 88 diff --git a/uv.lock b/uv.lock index 56fd18076..a692e7c82 100644 --- a/uv.lock +++ b/uv.lock @@ -2320,7 +2320,7 @@ wheels = [ [[package]] name = "uipath" -version = "2.0.4" +version = "2.0.5" source = { editable = "." } dependencies = [ { name = "click" }, @@ -2366,7 +2366,7 @@ requires-dist = [ { name = "tenacity", specifier = ">=9.0.0" }, { name = "tomli", specifier = ">=2.2.1" }, { name = "types-requests", specifier = ">=2.32.0.20250306" }, - { name = "uipath-langchain", marker = "extra == 'langchain'", specifier = "==0.0.85" }, + { name = "uipath-langchain", marker = "extra == 'langchain'", specifier = ">=0.0.88,<0.1.0" }, ] provides-extras = ["langchain"] @@ -2388,7 +2388,7 @@ dev = [ [[package]] name = "uipath-langchain" -version = "0.0.85" +version = "0.0.88" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "httpx" }, @@ -2403,31 +2403,11 @@ dependencies = [ { name = "python-dotenv" }, { name = "requests" }, { name = "types-requests" }, - { name = "uipath-sdk" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/2e/57/958c044efb2e9af8fea8c83faf6c6629d023de39bd023d7f3fa838ce25f1/uipath_langchain-0.0.85.tar.gz", hash = "sha256:037765b0b11ce0cfa10c55ab3402644f6621981be6c2d746513ea570e9e2d3bc", size = 27712 } -wheels = [ - { url = "https://files.pythonhosted.org/packages/3e/91/385e38ba954833f9f1cd39104e43dda8db49c9deb30675c8a6f573c24742/uipath_langchain-0.0.85-py3-none-any.whl", hash = "sha256:6bb89cda147934d14e780685357072308fa597a9746872c3f195a1a6bf73b9e7", size = 41292 }, -] - -[[package]] -name = "uipath-sdk" -version = "0.0.112" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "click" }, - { name = "httpx" }, - { name = "pydantic" }, - { name = "pytest-asyncio" }, - { name = "python-dotenv" }, - { name = "requests" }, - { name = "tenacity" }, - { name = "tomli" }, - { name = "types-requests" }, + { name = "uipath" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/39/df/5622c2f9f0aef4f1583eb3d02deaf991a00f12a78a1d1a4234679fa9c164/uipath_sdk-0.0.112.tar.gz", hash = "sha256:39c9540df41ae5d6da8240649347a0c0c95fb1200324093603c270598406f20a", size = 55208 } +sdist = { url = "https://files.pythonhosted.org/packages/80/0e/e05ecfc5a5b6b7f277dca18e61724c1a923ae4c9af39f71f2c8dce52343d/uipath_langchain-0.0.88.tar.gz", hash = "sha256:f06cc80c9499ae4309275119a9abf5d74c881aaef6731c6efb5b525a1291ef33", size = 1188502 } wheels = [ - { url = "https://files.pythonhosted.org/packages/d7/04/18f01fec3148db875c77e75dd8a5203695b6624b806f8758f01240848f79/uipath_sdk-0.0.112-py3-none-any.whl", hash = "sha256:05361f301f2309cff80c2676e34e8c212a8e1c22fedad383ae2f31decde6e508", size = 81182 }, + { url = "https://files.pythonhosted.org/packages/3a/7a/68ec6fcb4698af7f27c30a2107c349fb6115b84373dba38413346e8c5a57/uipath_langchain-0.0.88-py3-none-any.whl", hash = "sha256:78c92bebbd4a3651adcf914d3563a551222bef86f54cb3eb270d93a39ede7d28", size = 50641 }, ] [[package]]