The Batch Compute-cli command line tool helps you to quickly submit a job and conveniently manage jobs and clusters.
Note:This tool is only tested in Python 2.7, 3.4, and 3.5. Exercise caution, if you are about use it in other versions of Python.
pip install batchcompute-cli
# If you have installed the tool before, use the following command to upgrade the tool:
pip install -U batchcompute-cli
If you have limited permission, prefix the command with sudo.
Install pip if you have not installed it yet. For more information, see “Online pip installation” documentation. The following describes the pip installation on the Ubuntu operating system as an example:
sudo apt-get update
sudo apt-get install python-pip
bcs login cn-shenzhen <access_key_id> <access_key_secret>
bcs login cn-shenzhen # Press Enter
input accessKeyId: # Enter the accessKeyId
input accessKeySecret: # Enter the accessKeySecret
Where, access_key_id and access_key_secret are your AccessKeys. To obtain the AccessKey, see AccessKey.
Alternatively, you can use the AccessKeys of a subaccount.
For more information about supported regions, see Supported regions.
An OSS directory is required for storing the uploaded user applications and job logs.
Create a bucket, for example, mybucket-shenzhen. Note that the region of the bucket must be consistent with that you log on, for example, cn-shenzhen. Then, create a directory (here cli), under this bucket.
bcs set --osspath oss://mybucket-shenzhen/cli/
If the tool version is later than 1.3.0, you must manually configure the default image and instance type.
- Usage of the default image and instance type
The default image or instance type is used, if you do not explicitly specify an image or instance type when creating a cluster or submitting a job.
bcs set --image img-ubuntu-vpc #Set the default image to img-ubuntu
bcs set --type ecs.sn1ne.large #Set the default instance type to ecs.sn1ne.large (2-core; 4 GB)
Note: The default image can be a registered Batch Compute image (ID starting with “img-“) or an ECS image (ID starting with “m-“) that has been shared to Batch Compute. The former is recommended.
The version of the Batch Compute-cli tool must be 1.5.5 or later.
bcs set --vpc_cidr_block 192.168.0.0/16
Configure the CIDR block of the VPC instance that is used by default. The default setting 192.168.0.0/16 is used if you do not specify vpc_cidr_block when submitting codes or creating a cluster.
You can append -h to every command to view the help information of the command.
bcs -h # View the help information of the bcs command
bcs job -h # View the help information of the job command
bcs sub -h # View the help information of the submit command
For more information about how to submit a job, click here.