Basic Introduction to the bayes Command Line Tool
HyperAI provides a command line tool bayes for convenient direct interaction with HyperAI services from the command line interface. Compared to interacting directly through the web interface, the command line tool is simpler and more efficient in many aspects such as "creating Python scripts" and "uploading datasets".
Installation
The HyperAI CLI is now written in Python, and you can install it through Python's package manager pip. The installation steps are detailed in Installing the bayes Command Line Tool.
After installation, you can verify the installation with the following command:
$ pip show openbayes-cliThis will display detailed information about the CLI tool's version, installation location, dependencies, etc. Then use the following command to verify whether the CLI tool is working properly:
$ bayes statusIf the installation is successful, this command will display your connection status and basic system information.
Seeing the above information in the command line indicates that the bayes tool has been successfully installed. Next, you can log in to your account through the command bayes login:
$ bayes login username
Please enter the password for username:
username has successfully logged in to openbayesThen we can use bayes -h to see what specific operations can be performed:
$ bayes -h
Usage: bayes [OPTIONS] COMMAND [ARGS]...
HyperAI Command Line Tool
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --install-completion Install completion for the current shell. │
│ --show-completion Show completion for the current shell, to copy it or customize the installation. │
│ --help -h Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ data Dataset related operations │
│ gear Container related operations │
│ hpc High performance computing related operations │
│ login Login │
│ logout Logout │
│ org Organization related operations │
│ ssh SSH related operations │
│ status Login information │
│ switch Switch server environment │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯Use "bayes [command] --help" to get more information about a command.
Getting Help Information for Subcommands
You can get detailed help information for any subcommand by adding the --help or -h parameter. For example, to view help information for dataset-related operations:
$ bayes data -h
Usage: bayes data [OPTIONS] COMMAND [ARGS]...
Dataset related operations
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help -h Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ create Create a new dataset │
│ ls Display user's datasets │
│ new-version Create a new empty dataset version │
│ open Open dataset page in browser │
│ upload Upload local data to dataset │
│ versions Display version list of user's dataset │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Similarly, you can view the help information for container-related operations:
```bash
$ bayes gear -h
Usage: bayes gear [OPTIONS] COMMAND [ARGS]...
Container-related operations
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --help -h Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ bindings View bindable data for running containers │
│ download Download container output │
│ env View available environments for running containers │
│ init Initialize container │
│ logs View container logs │
│ ls View all containers │
│ open Open container page in browser │
│ resource View available resources for running containers │
│ restart Resume container execution │
│ run Run container │
│ status View all tasks under container │
│ stop Stop container │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯Quick Start
Login
$ bayes login username
Please enter the password for username:
username has successfully logged in HyperAI
If you need to use SSH, please re-run the bayes ssh init commandFollow the prompt and execute the command bayes ssh init to add SSH configuration for convenient SSH access to containers. For more information, see Connect to Running Jupyter Instance via SSH.
Initialize Container
Create a new directory and initialize a new container in that directory:
$ mkdir new-bayes-test
$ cd new-bayes-test
$ bayes gear init new-bayes-test
Container initialized successfullyList the current directory:
$ ls -a
. .. .openbayesgear .openbayesignore openbayes.yamlYou can see three files have been generated:
.openbayesgearsaves the metadata of the current container, please do not delete..openbayesignoreis similar to.gitignore, used to ignore unwanted content in the directory when uploading data or code. For detailed documentation, refer to gitignore.openbayes.yamlis the configuration file for the openbayes command line. For details, see HyperAI Configuration File.
Create a Python Script Task
Create a simple main.py file:
$ cat <<EOF > main.py
import time
for i in range(100):
time.sleep(1)
print(i)
print('done')
EOFExecute the command:
$ bayes gear run task -f -- python main.py
Currently operating under personal account admin...
command info: python main.py
Uploading source code...
Preparing to upload source code...
Obtaining upload authorization...
Starting to scan files, please wait...
Found 5 files in total, 10.3 kB in total, starting upload...
Upload progress: 100% (5/5): 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10.3k/10.3k [00:05<00:00, 2.04kB/s]
✅ Source code uploaded successfully! 5 files uploaded
Requesting server to create container...
Container created successfully
Visit https://openbayes.com/console/admin/jobs/ia0j6m6fzp1l to view detailed container information
Container is runningThe container logs are as follows:
bayes cmd exists.
/usr/local/bin/bayes
Successfully switched to bayes
If you need to use SSH, please re-run the bayes ssh init command
Successfully logged into HyperAI
If you need to use SSH, please re-run the bayes ssh init command
Successfully switched to personal account admin
curl: (5) Could not resolve proxy: alchemist-experience
proxy alchemist-experience:7890 not working, ignoring
0
1
2
...
95
96
97
98
99
doneFor more information, see Managing Containers with bayes.
Upgrade
You can upgrade to the latest version with the following command:
$ pip install --upgrade openbayes-cliIf you want to upgrade directly from the official PyPI source, avoiding local cache and third-party mirrors, you can use the following command:
# Without using cache
$ pip install --upgrade openbayes-cli --no-cache-dir
# Using official PyPI source
$ pip install --upgrade openbayes-cli --index-url https://pypi.org/simpleUsage Philosophy
The bayes command-line tool is intended to complement the shortcomings of certain operations in the web interface and improve the experience of operations that are more suitable for the command-line interface; it is not meant for users to operate completely independently without the web interface. Especially in dataset creation and Python script creation, it offers significant improvements over the web interface workflow. We will focus on introducing these two scenarios later.
The command-line tool provides many commands to facilitate users switching from the command-line interface to the web interface to view container or data content. Conversely, the web interface will also add more command-line operation prompts in the future to facilitate users navigating between the two interfaces.
Using the Command-Line Tool in Jupyter Workspace
Currently, the command-line tool has been integrated into the Jupyter workspace. After opening a "Terminal" in Jupyter, the following prompt will appear:
Following the prompt, enter the command bayes gear init to automatically complete account login and initialize the openbayes.yaml file (for more information about configuration files, see HyperAI Configuration File).