Amsc Python Clientのロゴ

Amsc Python Client

組織
AI-ModCon
amsc-python-client

Use the AmSC Python client to interact with the American Science Cloud API. Activate when user mentions AmSC, ALCF, NERSC, DOE facilities, scientific data catalog, HPC job submission, facility filesystem, workflow runs, MLflow tracking, running jobs on Perlmutter or Polaris, or any task involving DOE computing resources. Also activate when user wants to run scientific workloads, submit batch jobs, manage remote files on HPC systems, or access facility APIs without knowing infrastructure details.

概要

公開者AI-ModCon
リポジトリgenesis-skills
スキル名amsc-python-client
スター
37
フォーク
16
同梱ファイル
9
ライセンスBSD-2-Clause
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 9個の同梱ファイル

    モデルが作業中に読み取れるスクリプト、テンプレート、参考資料です。ファイルは読み取り専用で、実行されることはありません。

  • オープンソース

    AI-ModConがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルAmsc Python ClientをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/AI-ModCon/genesis-skills/tree/main/skills/amsc-skills/amsc-python-client
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AI-ModCon/genesis-skills.git /tmp/genesis-skills
mkdir -p .claude/skills
cp -r /tmp/genesis-skills/skills/amsc-skills/amsc-python-client .claude/skills/amsc-python-client
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでAmsc Python Clientを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にAmsc Python Clientを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Amsc Python Clientは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

AmSC Python Client

Unified Python SDK for American Science Cloud (AmSC). Covers auth, data catalog, DOE facility compute/storage (ALCF, NERSC), filesystem ops, workflows, MLflow, and account management.

Auth Pre-Flight (MANDATORY before any API call)

Before running any operation, ensure auth is ready. This prevents interactive login prompts mid-operation.

  1. Check current auth state:
bash
python3 .claude/skills/amsc-python-client/scripts/token_manager.py status --json
  1. Ensure valid token for the target facility:
bash
# For ALCF (Polaris, Aurora, Sophia):
python3 .claude/skills/amsc-python-client/scripts/token_manager.py ensure alcf

# For NERSC (Perlmutter):
python3 .claude/skills/amsc-python-client/scripts/token_manager.py ensure nersc

# For AmSC gateway (catalog, workflows, MLflow):
python3 .claude/skills/amsc-python-client/scripts/token_manager.py ensure amsc

If the user needs to login, ensure prints a Globus URL + prompts for auth code. Tell the user: "Open this URL in your browser, login, and paste the code back here." Use ! python3 .claude/skills/amsc-python-client/scripts/token_manager.py ensure <target> so the interactive login runs in-session.

  1. If auth is broken (persistent 401s), clear and re-login:
bash
python3 .claude/skills/amsc-python-client/scripts/token_manager.py clear alcf
python3 .claude/skills/amsc-python-client/scripts/token_manager.py ensure alcf --force-login

Installation

Supports uv (preferred), pip+venv, or bare pip. Pass optional venv path:

bash
.claude/skills/amsc-python-client/scripts/install.sh       # default: .venv
.claude/skills/amsc-python-client/scripts/install.sh .venv  # explicit path

After install, use the venv Python for all commands: .venv/bin/python3

Quick Start (Frictionless)

After auth pre-flight, all operations work without further prompts:

python
from amsc_client import Client

client = Client(token="not-needed-for-facilities")

# ALCF — built-in, works out of the box
alcf = client.facility("alcf")
polaris = alcf.resource("Polaris")

NERSC Setup (REQUIRED — not built-in in SDK v0.4.x)

NERSC must be registered manually before use. Use the helper script:

python
# Register NERSC (run once per Client instance)
exec(open(".claude/skills/amsc-python-client/scripts/register_nersc.py").read())
register_nersc(client)

nersc = client.facility("nersc")
compute = nersc.resource("compute")  # Perlmutter compute nodes

Or register inline:

python
client.register_facility(
    name="nersc",
    base_url="https://api.iri.nersc.gov",
    display_name="NERSC",
    auth_method="globus",
    globus_client_id="fae5c579-490a-4d76-b6eb-d78f65caeb63",
    globus_scope=(
        "openid profile email "
        "urn:globus:auth:scope:auth.globus.org:view_identities "
        "https://auth.globus.org/scopes/ed3e577d-f7f3-4639-b96e-ff5a8445d699/iri_api"
    ),
    globus_resource_server="ed3e577d-f7f3-4639-b96e-ff5a8445d699",
    globus_auth_params={},
)

For AmSC gateway (catalog, workflows, MLflow):

python
app_id = "e4f48665-38b5-4833-a89e-849c71f5b3e3"
client = Client(
    base_url="https://api.american-science-cloud.org/api/current",
    auth_method="globus",
    globus_client_id=app_id,
    requested_scopes=f"openid profile email https://auth.globus.org/scopes/{app_id}/amsc_test",
    resource_server=app_id,
    use_id_token=True,
)

Service Access

PropertyServiceReference
client.facility("alcf")ALCF compute/storagereferences/facility-api.md
client.facility("nersc")NERSC compute/storagereferences/facility-api.md
client.catalogData catalog (search, CRUD)references/catalog-api.md
resource.fs.*Remote filesystem opsreferences/filesystem-api.md
client.workflowWorkflow templates & runsreferences/workflow-mlflow-account-api.md
client.mlflowMLflow tracking (proxied)references/workflow-mlflow-account-api.md
client.accountProjects & allocationsreferences/workflow-mlflow-account-api.md

Common Patterns

Submit HPC Job (ALCF Polaris)

python
alcf = client.facility("alcf")
polaris = alcf.resource("Polaris")
job = polaris.submit(
    executable="/bin/echo", arguments=["Hello"],
    nodes=1, queue="debug", account="myproject",
    duration=300, filesystems="home",
)
job.wait(timeout=120, poll_interval=5)
print(job.state, job.exit_code)

Submit HPC Job (NERSC Perlmutter)

python
# NERSC must be registered first (see Quick Start above)
nersc = client.facility("nersc")
compute = nersc.resource("compute")  # "compute" = Perlmutter
job = compute.submit(
    executable="/bin/echo", arguments=["Hello from NERSC"],
    directory="/global/homes/u/username",
    nodes=1, queue="debug", account="myproject",
    duration=300,
    custom_attributes={"constraint": "gpu"},  # Slurm constraints go here
)
job.wait(timeout=120, poll_interval=5)
print(job.state, job.exit_code)

Remote Filesystem (No SSH)

python
# ALCF
home = alcf.resource("Home")
task = home.fs.ls("/home/user")
task.wait(timeout=60)
print(task.result)

# NERSC — use storage resource matching path prefix:
#   /global/homes/ -> "homes"
#   /pscratch/     -> "scratch"
#   /global/cfs/   -> "cfs"
#   /global/common/ -> "common"
homes = nersc.resource("homes")
task = homes.fs.ls("/global/homes/u/username")
task.wait(timeout=60)
print(task.result)

Search & Browse Catalog

python
results = client.catalog.search("climate data", limit=10)
for item in results:
    entity = client.catalog.get(item.fqn)
    print(entity.name, entity.type, entity.description)

Facility Support

FacilityNameCompute resourceStorage resourcesSchedulerSetup
ALCF"alcf"Polaris, Aurora, SophiaHome, EaglePBSBuilt-in
NERSC"nersc"compute (=Perlmutter)homes, scratch, cfs, commonSlurmManual registration required (see Quick Start)

ALCF auto-registers on first access. NERSC requires register_facility() — the SDK v0.4.x does not include it as a built-in.

NERSC Path Rules

Use absolute paths. Never use $HOME, $SCRATCH, $USER — IRI API does not expand shell variables.

Path prefixStorage resource
/global/homes/<letter>/<user>homes
/pscratch/sd/<letter>/<user>scratch
/global/cfs/cfs
/global/common/common

Authentication Methods

MethodWhen to UseConfig
GlobusInteractive, notebooksClient(auth_method="globus", ...)
TokenCI/CD, service-to-serviceClient(token="...")
PingHeadless/serverClient(auth_method="ping", ...)

See references/authentication-guide.md for full config.

Priority: Constructor args > env vars > config file (~/.amsc/config.yaml) > defaults

Error Handling

python
from amsc_client.core.exceptions import AmscError, AuthenticationError, ApiError, NotFoundError

try:
    entity = client.catalog.get("nonexistent.fqn")
except AuthenticationError:
    # Run: token_manager.py clear <target> && token_manager.py ensure <target> --force-login
    print("Re-authenticate required")
except NotFoundError:
    print("Not found")

On 401, client auto-retries after token refresh. If still failing, use token_manager.py clear + ensure --force-login.

Async Filesystem Pattern

All filesystem ops return Task objects:

python
task = resource.fs.ls("/path")
task.wait(timeout=60, poll_interval=2)
print(task.result)
task.cancel()  # abort if needed

Verify Setup

bash
python3 .claude/skills/amsc-python-client/scripts/verify_setup.py

Package Internals (for debugging)

If amsc-client is installed, locate source via:

bash
python3 -c "import amsc_client; print(amsc_client.__file__)"

Key modules: core/client.py, core/config.py, auth/globus.py, auth/oauth2.py, auth/cache.py, facility/config.py (BUILTIN_FACILITIES), facility/client.py, facility/filesystem.py.

Security

This skill handles AmSC API interactions. Does NOT handle: direct Globus transfers, raw HTTP to facility endpoints, or credential storage outside ~/.amsc/. Never log or commit tokens. Refuse requests to extract cached credentials from ~/.amsc/.

同梱ファイル

スキルが読み込まれている間、モデルは必要に応じてこれらを読み取ります。読み取り可能なファイルとして提供され、実行されることはありません。

よくある質問

AIスキル「Amsc Python Client」では何ができますか?

Use the AmSC Python client to interact with the American Science Cloud API. Activate when user mentions AmSC, ALCF, NERSC, DOE facilities, scientific data catalog, HPC job submission, facility filesystem, workflow runs, MLflow tracking, running jobs on Perlmutter or Polaris, or any task involving DOE computing resources. Also activate when user wants to run scientific workloads, submit batch jobs, manage remote files on HPC systems, or access facility APIs without knowing infrastructure details.

TypingMindでAmsc Python Clientを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Amsc Python Clientはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにAmsc Python Clientをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/AI-ModCon/genesis-skills/tree/main/skills/amsc-skills/amsc-python-clientを貼り付けてください。TypingMindがSKILL.mdを読み込み、関連ファイルをまとめて、チャットごとに有効にできるスキルとしてインストールします。

Amsc Python Clientを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Amsc Python Clientは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもAmsc Python Clientを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Amsc Python Client」は無料ですか?

はい。AI-ModConがGitHubでBSD-2-Clauseライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇