Skip to main content

PyPI version Python version License MIT

paicli

A CLI tool for OpenPAI, which supports basic opperations like listing up jobs, submitting a new job, suspending a running job, and executing ssh into a running container.

demo

How to install

One can install paicli from PyPI.

$ pip install paicli

Motivating examples

One can utilize and combine the paicli subcommands to achieve several practical operations.

1. Ssh into a running container

When you want to ssh into a running container, all you have to do is just type pai ssh:

$ pai ssh

Then, you can choose a container from your running job list. There is no need to download the key and specify the host explicitly. You can also give a job name of your running job as argument:

$ pai ssh example_job_001

2. Submit multiple jobs with one line

One can use pai submit and some template engine like envsubst.

$ head template.json -n 2
{
  "jobName": "example_job_${JOBID}"
$ for i in `seq 1 3`; do cat example.json | JOBID=$i envsubst | pai submit; done

3. Stop multiple jobs with one line

One can combine pai jobs and pai stop.

$ pai jobs -u sotetsuk -s RUNNING | grep example_job | awk '{print $1}' | xargs pai stop

4. Ssh into multiple running containers and run the same command

One can combine pai jobs and pai ssh. In this example, it shows python processes in multiple jobs with one line.

$ pai jobs -u sotetsuk -s RUNNING | grep example_job | awk '{print $1}' | xargs -n 1 pai ssh -c "ps -aux | grep python"

5. Show all tensorboard URLs in running jobs

One can combine pai jobs and pai host to show all tensorboard URLs. One can use some browser extention to open all URLs (e.g., OpenList)

$ pai jobs -u sotetsuk -s RUNNING | grep example_job | xargs -n 1 pai host | grep tensorboard | awk '{printf "http://%s:%s\n",$2,$4}'
http://10.0.0.1:9999
http://10.0.0.2:9999
http://10.0.0.3:9999

Basic usage

For more detailed usage, one can use --help option for each subcommand like pai config --help.

$ pai --help
Usage: pai [OPTIONS] COMMAND [ARGS]...

  A CLI tool for OpenPAI.

Options:
  --help  Show this message and exit.

Commands:
  config  Write your configuration to a file.
  host    Show host information of the specified job.
  jobs    Show job list.
  ssh     SSH into a running container.
  stop    Stop a running job.
  submit  Submit your job.
  token   Generate a new access token

Configuration

Before utilizing paicli subcommands, you have to initialize your configuration about your PAI environment.

  • Config file: To initialize your config file, run pai config. Then your config file will be located in $HOME/.paicli. You should set your host, port, and username. You can use --profile option to use multiple PAI environments.
  • Access token: Before submitting/stopping a job, you should issue your access token by executing pai token and entering your password. You can skip entering password everytime if you write your password directly to your config file (not recommended).

Author

Sotetsu KOYAMADA

Release files for paicli 0.5.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for paicli 0.5.5
File Size Uploaded
paicli-0.5.5.tar.gz 11.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for paicli 0.5.5
File Interpreter ABI Platform
paicli-0.5.5-py3.7.egg Legacy Egg format - - Details
paicli-0.5.5-py3-none-any.whl Python 3 none any Details

Total release size: 52.1 kB

Release files / paicli-0.5.5.tar.gz

Download URL paicli-0.5.5.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f306b09372717b1260c54ab826b4555d304fef788f2d4461dd320f557446eef1
BLAKE2b-256 checksum
How to use checksums
08bd23c05b37e76bac42ca65be7e7455a1704d7c5c71abe1ea0dfc5fe70a898e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release files / paicli-0.5.5-py3.7.egg

Download URL paicli-0.5.5-py3.7.egg
Size 27.4 kB
Tags Egg
SHA-256 checksum
How to use checksums
e2a540e1492dd5528e69cd260bf9d80afab0e5ebd84bb2bafac01854ac41db86
BLAKE2b-256 checksum
How to use checksums
610b98e1e92d3d2a1f48de99b1803d4015f02d4ab86dc186b7faa02951d1eea6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release files / paicli-0.5.5-py3-none-any.whl

Download URL paicli-0.5.5-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1209c79b4a6a5135c28014af04924cc245e56f806f4d278da0a79e754fee0419
BLAKE2b-256 checksum
How to use checksums
53cf5dd4c20e8c96375186ece711486f551b399752d903f4c4fd9873ddac99cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.5.5 This release

3 release files

0.5.4

3 release files

0.5.2

3 release files

0.5.1

3 release files

0.5.0

3 release files

0.4.2

3 release files

0.4.1

3 release files

0.4.0

3 release files

0.3.4

3 release files

0.3.3

3 release files

0.3.2

3 release files

0.3.1

3 release files

0.3.0

3 release files

0.2.2

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page