All Products
Search
Document Center

Batch Compute:Preparation

Last Updated:Aug 21, 2023

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 to use it in other versions of Python.

1. Install command line tool

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. The following describes the pip installation on the Ubuntu operating system as an example:

sudo apt-get update
sudo apt-get install python-pip

2. Log on to tool

bcs login cn-shenzhen <access_key_id>  <access_key_secret>

Or,

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.

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.

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

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

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.

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.

6. View help information

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
...

7. Submit job

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