UiPath Documentation
functions
latest
false
Functions ユーザー ガイド
  • 概要
    • 関数について
  • Python の関数
  • デプロイして実行する

スタート アップ ガイド

このページでは、SDK のインストール、プロジェクトのスキャフォールディング、最初の Python 関数のローカルでの実行について説明します。

前提条件

  • Python 3.10 以降。
  • pipとともにインストールされる uipath CLI および 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 コマンドで使用されるエントリ ポイント名です。値 はファイルと関数を参照します。関数の名前を変更するか、エントリ ポイントを追加した場合にのみ更新してください。

プロジェクト スキーマを生成する

InputOutputを定義したら、スキーマとバインドを生成します。

uipath init
uipath init

これにより、コードと uipath.json が読み取られ、以下が生成されます。

ファイル目的
entry-points.json入力/出力: モデルから派生した JSON スキーマで、変数のバインドに使用されます。
bindings.jsonResource 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.

次のステップ

このページは役に立ちましたか?

接続

ヘルプ リソース サポート

学習する UiPath アカデミー

質問する UiPath フォーラム

最新情報を取得