All Products
Document Center

Batch Compute:Preparation

Last Updated:May 11, 2018

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.

1. Install command line tool

  1. pip install batchcompute-cli
  2. # If you have installed the tool before, use the following command to upgrade the tool:
  3. 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:

  1. sudo apt-get update
  2. sudo apt-get install python-pip

2. Log on to tool

  1. bcs login cn-shenzhen <access_key_id> <access_key_secret>


  1. bcs login cn-shenzhen # Press Enter
  2. input accessKeyId: # Enter the accessKeyId
  3. 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.

3. Configure an OSS directory

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.

  1. bcs set --osspath oss://mybucket-shenzhen/cli/

4. Configure default image and instance type

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.

  • Commands
  1. bcs set --image img-ubuntu-vpc #Set the default image to img-ubuntu
  2. 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.

5. Configure VPC-Connected instance that is used by default

The version of the Batch Compute-cli tool must be 1.5.5 or later.

  1. bcs set --vpc_cidr_block

Configure the CIDR block of the VPC instance that is used by default. The default setting is used if you do not specify vpc_cidr_block when submitting codes or creating a cluster.

6. View help information

You can append -h to every command to view the help information of the command.

  1. bcs -h # View the help information of the bcs command
  2. bcs job -h # View the help information of the job command
  3. bcs sub -h # View the help information of the submit command
  4. ...

7. Submit job

For more information about how to submit a job, click here.