tencent cloud

Batch Compute

Product Introduction
What's Batch?
Scenarios
Strengths
Glossary
Quota & Limits
Data Security
Purchase Guide
Getting Started
Preparation
Using CLI - Submit a Job
Using CLI - Compute Environment
Configuring a Job
Using Console
Console User Guide
Task Template Management
Job Management
User Guide
How to create images usable by BatchCompute
Windows Custom Images
Environment Variables
Entering COS & CFS Paths
Event Notice & Callback
Cloud Access Management
Command Line Interface
Preparation
Quick Start
Running Remote Package
Mapping Remote Storage
Use Cases
Building Cluster Using Compute Environment
Example: 3ds Max 2018 Rendering
Example: Deep Learning
API Documentation
History
Introduction
API Category
Making API Requests
Compute Environment APIs
Configuration Viewing-related APIs
Task Template-related APIs
Job-related APIs
Data Types
Error Codes
SDK Documentation
Instructions
FAQs
Contact Us
Glossary

Quick Start

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-08-29 16:00:33

Overview

This document describes the usage methods and computing capability of Batch.

Prerequisites

Complete preparations based on the instructions in Preparation, and learn how to configure the general part of the custom information.

Viewing the Demo

Note:
Modify the general part of the custom information in 1_SimpleStart.py based on the instructions in Preparation.
Open 1_SimpleStart.py in an editor.
# custom (Change to your info)
imageId = "img-m4q71qnf"
Application = {
"DeliveryForm": "LOCAL",
"Command": " python -c \\"fib=lambda n:1 if n<=2 else fib(n-1)+fib(n-2); print(fib(20))\\" "
}
StdoutRedirectPath = "your cos path"
StderrRedirectPath = "your cos path"
All information except Application in the general part is described in Preparation. Set the parameters of Application based on the following table.
Configuration Item
Description
DeliveryForm
Three methods are available for delivering an application: software packaging, container image, and direct running within a CVM instance. LOCAL indicates direct running within a CVM instance.
Command:
The command for starting a job. In this example, a Python script is executed. Starting from 1, the script adds up the first 20 numbers of the Fibonacci sequence and outputs the result to StdOutput.

Submitting a Job

Run the following command to run the Python script. The demo encapsulates the job submission process by using Python scripts and the Batch command line tool.
python 1_SimpleStart.py
The returned result is as follows, indicating that the job is successfully submitted:
{
"RequestId": "393292f4-5583-48ad-a9f5-f673138ea637",
"JobId": "job-o0xxxxxq7"
}
If the submit operation fails, check the returned value, or contact us.

Viewing State

Run the following command to view the execution status through DescribeJob:
$ tccli batch DescribeJob --version 2017-03-12 --JobId job-xxx
Note:
--Replace job-xxx with the JobId that is returned after you submit the job.
The returned result is as follows (some information is omitted):
{
"EndTime": "2019-10-08T04:06:58Z",
"JobState": "SUCCEED",
"TaskInstanceMetrics": {
...
},
"Zone": "ap-guangzhou-6",
"TaskMetrics": {
...
},
"JobName": "TestJob",
"Priority": 1,
"RequestId": "7a5f4c94-1357-486c-9c48-8286ba01b5b2",
"TaskSet": [
...
],
"StateReason": null,
"JobId": "job-o0xxxxxq7",
"DependenceSet": [],
"CreateTime": "2019-10-08T04:05:54Z"
}
The common values of JobState in the returned result are as follows:
STARTING: Launching
RUNNING: Running
SUCCEED: Running successfully
FAILED: Failed to run

Viewing the Result

1. Log in to the COS console. In the left sidebar, click Bucket List.
2. Click the ID of the desired bucket, go to the object list page, and view the log files that store the execution results. See the figure below:

If the job succeeds, view the standard output in stdout.job-xxx.xxxx.0.log. The content is as follows:
6765
If the job fails, view the standard error in stderr.job-xxx.xxxx.0.log. The content may be as follows:
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: ` python -c \\"fib=lambda n:1 if n<=2 else fib(n-1)+fib(n-2); print(fib(20))\\" '


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백