agentleFS
AI-ModConAI-ModCon/genesis-skills/skills/amsc-skills/iri-api/SKILL.md

iri-api

Skill30 starsChanged 50 days agoBSD-2-ClauseView on GitHub

Use this skill to work with IRI API deployments at NERSC (https://api.iri.nersc.gov) and ALCF (https://api.alcf.anl.gov) via reproducible scripts, including Globus token lifecycle management (status, refresh, interactive login) and OpenAPI-driven endpoint execution for facility/status/account/compute/filesystem/task workflows. Trigger this skill when the task mentions IRI API, openapi.json-driven calls, authenticated endpoint access, job submission/status/cancel, file operations, task polling/cleanup, or running jobs on Perlmutter or Polaris.

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. About 0 are common, 2 are distinctive, and 15 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 15

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use scripted workflows. Prefer the bundled scripts over hand-written curl commands.

    line 10
  2. Very specific:

    Use the unified token manager for both sites.

    line 21
  3. Distinctive:

    Ensure a usable token for authenticated endpoints:

    line 43
  4. Very specific:

    If the IRI API still returns 401, force a fresh identity-provider login:

    line 48
  5. Very specific:

    Call an endpoint by operationId:

    line 59
  6. Very specific:

    Use scripts/token_manager.py for all token lifecycle actions.

    line 67
  7. Very specific:

    Default token file: ~/.globus/auth_tokens.json

    line 102
  8. Very specific:

    If validation reports empty session_info.authentications, re-run with --force-login --prompt-login and complete the flow in a Chrome …

    line 107
  9. Very specific:

    Use scripts/iri_api_call.py for all API calls.

    line 111
  10. Very specific:

    Use --ensure-token so calls auto-refresh/login if needed.

    line 135
  11. Very specific:

    Prefer --operation-id over manual --method/--path.

    line 203
  12. Very specific:

    Use --facility nersc or --facility alcf on scripts/iri_api_call.py so the API server and bearer token selection stay aligned.

    line 211
  13. Distinctive:

    Before generating a compute job request, check whether the user wants any of the following:

    line 215
  14. Very specific:

    If any of those are needed, use a pre_launch or post_launch script to carry that logic instead of trying to force it into a single launch …

    line 220
  15. Very specific:

    Do not include #SBATCH or #PBS directives in pre_launch or post_launch.

    line 223
  16. Very specific:

    Put extra srun or mpiexec lines, affinity settings, environment setup, and teardown logic in those scripts as plain shell commands.

    line 225
  17. Very specific:

    Use templates from references/examples/:

    line 245

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

IRI API

Use scripted workflows. Prefer the bundled scripts over hand-written curl commands.

Deployments

SiteBase URLAuth scriptReference
NERSC (Perlmutter)https://api.iri.nersc.gov (default)scripts/token_manager.py ensure --facilities nerscreferences/NERSC.md
ALCF (Polaris)https://api.alcf.anl.govscripts/token_manager.py ensure --facilities alcfreferences/ALCF.md

Before doing any work, read the reference file for the relevant site. Do not proceed from memory.

Use the unified token manager for both sites. By default it can manage both NERSC and ALCF tokens together, but when the user is focused on one site, scope it with --facilities nersc or --facilities alcf.

--facility is a global flag on iri_api_call.py and must come before the subcommand:

# Correct
python3 scripts/iri_api_call.py --facility nersc call --operation-id getProjects --ensure-token
python3 scripts/iri_api_call.py --facility alcf call --operation-id launchJob ...

# Wrong
python3 scripts/iri_api_call.py call --facility nersc --operation-id getProjects

--base-url and --openapi-url follow the same rule: they are global flags and must also come before the subcommand.

Quick Start

  1. Check token state:
python3 scripts/token_manager.py status --json
  1. Ensure a usable token for authenticated endpoints:
python3 scripts/token_manager.py ensure --min-ttl 300

If the IRI API still returns 401, force a fresh identity-provider login:

python3 scripts/token_manager.py ensure --force-login --prompt-login --validate-iri
  1. List available operations from OpenAPI:
python3 scripts/iri_api_call.py --facility nersc list-operations
python3 scripts/iri_api_call.py --facility alcf list-operations
  1. Call an endpoint by operationId:
python3 scripts/iri_api_call.py --facility nersc call --operation-id getResources
python3 scripts/iri_api_call.py --facility alcf call --operation-id getResources

Token Management

Use scripts/token_manager.py for all token lifecycle actions.

  • Check token state:
python3 scripts/token_manager.py status --json
python3 scripts/token_manager.py status --facilities nersc --json
python3 scripts/token_manager.py status --facilities alcf --json
  • Ensure usable tokens:
python3 scripts/token_manager.py ensure --min-ttl 300
python3 scripts/token_manager.py ensure --facilities nersc --min-ttl 300
python3 scripts/token_manager.py ensure --facilities alcf --min-ttl 300
  • Refresh or login for selected facilities only:
python3 scripts/token_manager.py ensure --facilities nersc --refresh-only
python3 scripts/token_manager.py ensure --facilities alcf --refresh-only
  • Validate the facility token against the matching API:
python3 scripts/token_manager.py ensure --facilities nersc --validate-iri --validate-facility nersc
python3 scripts/token_manager.py ensure --facilities alcf --validate-iri --validate-facility alcf
  • Print selected facility access tokens:
python3 scripts/token_manager.py ensure --print-token
python3 scripts/token_manager.py ensure --facilities alcf --print-token

Notes:

  • Default token file: ~/.globus/auth_tokens.json
  • The saved file preserves the full Globus token response, including other_tokens.
  • The usable IRI API bearer token is extracted from other_tokens, not the top-level Globus Auth token.
  • Required scopes are enforced by script validation.
  • globus-sdk is required for refresh/login operations.
  • If validation reports empty session_info.authentications, re-run with --force-login --prompt-login and complete the flow in a Chrome incognito window.

Endpoint Execution

Use scripts/iri_api_call.py for all API calls.

Operation Discovery

  • List all operations:
python3 scripts/iri_api_call.py --facility nersc list-operations
python3 scripts/iri_api_call.py --facility alcf list-operations
  • See generated static reference: references/operations.md

Public Endpoints (No Token Required)

Examples:

python3 scripts/iri_api_call.py --facility nersc call --operation-id getFacility
python3 scripts/iri_api_call.py --facility nersc call --operation-id getIncidents
python3 scripts/iri_api_call.py --facility nersc call --operation-id getResource --path-param resource_id=perlmutter

Authenticated Endpoints (Token Required)

Use --ensure-token so calls auto-refresh/login if needed.

  • Account / project context:
python3 scripts/iri_api_call.py --facility nersc call --operation-id getProjects --ensure-token
python3 scripts/iri_api_call.py --facility alcf call --operation-id getProjects --ensure-token
  • Submit compute job (request body from file):
python3 scripts/iri_api_call.py --facility nersc call \
  --operation-id launchJob \
  --path-param resource_id=perlmutter \
  --json-file /path/to/job.json \
  --ensure-token
  • Query one job:
python3 scripts/iri_api_call.py --facility nersc call \
  --operation-id getJob \
  --path-param resource_id=perlmutter \
  --path-param job_id=12345 \
  --ensure-token
  • Cancel job:
python3 scripts/iri_api_call.py --facility nersc call \
  --operation-id cancelJob \
  --path-param resource_id=perlmutter \
  --path-param job_id=12345 \
  --ensure-token
  • Filesystem list/view:
python3 scripts/iri_api_call.py --facility nersc call \
  --operation-id ls \
  --path-param resource_id=perlmutter \
  --query path=/global/cfs/cdirs \
  --ensure-token

python3 scripts/iri_api_call.py --facility nersc call \
  --operation-id view \
  --path-param resource_id=perlmutter \
  --query path=/path/to/file.txt \
  --ensure-token
  • Upload file:
python3 scripts/iri_api_call.py --facility nersc call \
  --operation-id upload \
  --path-param resource_id=perlmutter \
  --query path=/path/on/resource/target.dat \
  --upload-file /local/path/source.dat \
  --ensure-token
  • Poll task state:
python3 scripts/iri_api_call.py --facility nersc call --operation-id getTasks --ensure-token
python3 scripts/iri_api_call.py --facility nersc call --operation-id getTask --path-param task_id=<task_id> --ensure-token

Shared Parameter Rules

  • Prefer --operation-id over manual --method/--path.
  • Provide required path params via repeated --path-param key=value.
  • Provide query params via repeated --query key=value.
  • Use one of:
    • --json-file /path/to/body.json
    • --json-body '{"key":"value"}'
    • --upload-file /path/to/local.file for multipart endpoints
  • For binary or large outputs, use --output-file /path/to/out.bin.
  • Use --facility nersc or --facility alcf on scripts/iri_api_call.py so the API server and bearer token selection stay aligned.

Job Construction Guidance

Before generating a compute job request, check whether the user wants any of the following:

  • A multistep job with multiple srun or mpiexec lines.
  • Additional job-control behavior that is not covered by the API attributes fields.
  • Explicit affinity or binding control beyond the basic resource request.

If any of those are needed, use a pre_launch or post_launch script to carry that logic instead of trying to force it into a single launch line or into unsupported attributes.

Rules for these scripts:

  • Do not include #SBATCH or #PBS directives in pre_launch or post_launch.
  • The scheduler directives belong in the batch script generated by the API server, not inside the pre/post scripts.
  • Put extra srun or mpiexec lines, affinity settings, environment setup, and teardown logic in those scripts as plain shell commands.
  • For NERSC-oriented launch structure and Slurm examples, use https://docs.nersc.gov/jobs/examples/.
  • For ALCF-oriented launch structure and PBS examples, use https://docs.alcf.anl.gov/running-jobs/example-job-scripts/#cpu-mpi-openmp-examples.

Reproducibility and Reference Refresh

Regenerate endpoint reference after OpenAPI updates:

python3 scripts/generate_operation_reference.py \
  --openapi references/openapi.json \
  --output references/operations.md

Regenerate request payload templates:

python3 scripts/generate_examples.py

Use templates from references/examples/:

  • compute-launch-job.json
  • compute-status-filters.json
  • filesystem-mkdir.json
  • filesystem-mv.json
  • filesystem-cp.json
  • filesystem-compress.json
  • filesystem-extract.json
  • filesystem-chmod.json
  • filesystem-chown.json

Example calls using generated templates:

python3 scripts/iri_api_call.py --facility nersc call \
  --operation-id launchJob \
  --path-param resource_id=perlmutter \
  --json-file references/examples/compute-launch-job.json \
  --ensure-token

python3 scripts/iri_api_call.py --facility nersc call \
  --operation-id mkdir \
  --path-param resource_id=perlmutter \
  --json-file references/examples/filesystem-mkdir.json \
  --ensure-token

Useful Endpoint Groups

  • Facility + status (public): infrastructure metadata and incident visibility.
  • Account (auth): user projects and allocation hierarchy.
  • Compute (auth): submit/update/status/cancel jobs.
  • Filesystem (auth): list/read/write/upload/download and file operations.
  • Task (auth): check asynchronous task progress and cleanup.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.