このページでは、SDK のインストール、プロジェクトのスキャフォールディング、最初の Python 関数のローカルでの実行について説明します。
前提条件
- Python 3.10 以降。
pipとともにインストールされるuipathCLI および SDK- Orchestrator へのアクセス権 (パブリッシュおよび呼び出し用) を持つ UiPath アカウント。
SDK をインストールします
pip install uipath
pip install uipath
インストールを確認します。
uipath --version
uipath --version
プロジェクトのスキャフォールディング
新しい関数プロジェクトを作成します。
uipath new my-function
uipath new my-function
これにより、編集するファイルのスキャフォールディングが行われます。
| ファイル | 目的 |
|---|---|
main.py | 関数ロジックと Input/Output モデル。実行可能な例として開始されます。 |
pyproject.toml | プロジェクトのメタデータと依存関係。 |
uipath.json | 呼び出し可能なエントリ ポイントを宣言します。スキャフォールドは main を登録します。 |
最初の関数を記述する
の でスキャフォールディングされたロジックを置き換えますmain.py
from pydantic.dataclasses import dataclass
@dataclass
class Input:
message: str = ""
@dataclass
class Output:
reply: str = ""
def main(input: Input) -> Output:
return Output(reply=f"Hello, {input.message}!")
from pydantic.dataclasses import dataclass
@dataclass
class Input:
message: str = ""
@dataclass
class Output:
reply: str = ""
def main(input: Input) -> Output:
return Output(reply=f"Hello, {input.message}!")
スキャフォールディング uipath.json は、すでにこのエントリ ポイントを宣言しています。
{
"functions": {
"main": "main.py:main"
}
}
{
"functions": {
"main": "main.py:main"
}
}
キー (main) は、CLI コマンドで使用されるエントリ ポイント名です。値 はファイルと関数を参照します。関数の名前を変更するか、エントリ ポイントを追加した場合にのみ更新してください。
プロジェクト スキーマを生成する
InputとOutputを定義したら、スキーマとバインドを生成します。
uipath init
uipath init
これにより、コードと uipath.json が読み取られ、以下が生成されます。
| ファイル | 目的 |
|---|---|
entry-points.json | 入力/出力: モデルから派生した JSON スキーマで、変数のバインドに使用されます。 |
bindings.json | Resource binding manifest, created with an empty structure only when the file does not already exist. |
Re-run uipath init whenever you change your Input or Output models. It regenerates entry-points.json and never modifies bindings.json — resource bindings are maintained by hand. For what they do and how to declare them, see Resource bindings.
ローカルで実行する
uipath run main '{"message": "world"}'
uipath run main '{"message": "world"}'
Local runs resolve platform resources through the entries in bindings.json, so you can test against real Orchestrator assets and buckets before publishing. The same entries are what let each resource be remapped when the package runs in another tenant.
次のステップ
- Python 関数の構築 — 型指定されたスキーマ、エラー処理、複数のエントリ ポイント。
- Resource bindings — declare the platform resources your function reaches.
- パッケージ化してパブリッシュ する — Orchestrator にデプロイします。