-
分享文档到微博
-
-
复制链接到剪贴板
链接复制成功!
ma-j9九游会登录
$ma-cli dli-job -h usage: ma-cli dli-job [options] command [args]... dli spark job submission and query job details. options: -h, -h, --help show this message and exit. commands: get-job get dli spark job details. get-log get dli spark log details. get-queue get dli spark queues info. get-resource get dli resources info. stop stop dli spark job by job id. submit submit dli spark batch job. upload upload local file or obs object to dli resources.
|
命令 |
命令详情 |
|---|---|
|
get-job |
查询dli spark作业列表及详情。 |
|
get-log |
查询dli spark运行日志。 |
|
get-queue |
查询dli队列。 |
|
get-resource |
查询dli分组资源。 |
|
stop |
停止dli spark作业。 |
|
submit |
提交dli spark作业。 |
|
upload |
上传本地文件或obs文件到dli分组资源。 |
使用ma-cli dli-job get-job命令查询dli spark作业
执行ma-cli dli-job get-job查询dli spark作业列表或单个作业详情。
ma-cli dli-job get-job -h
usage: ma-cli dli-job get-job [options]
get dli spark details.
example:
# get dli spark job details by job name
ma-cli dli-job get-job -n ${job_name}
# get dli spark job details by job id
ma-cli dli-job get-job -i ${job_id}
# get dli spark job list
ma-cli dli-job get-job --page-size 5 --page-num 1
options:
-i, --job-id text get dli spark job details by job id.
-n, --job-name text get dli spark job details by job name.
-pn, --page-num integer range specify which page to query. [x>=1]
-ps, --page-size integer range the maximum number of results for this query. [x>=1]
-v, --verbose show detailed information about dli spark job details.
-c, --config-file path configure file path for authorization.
-d, --debug debug mode. shows full stack trace when error occurs.
-p, --profile text cli connection profile to use. the default profile is "default".
-h, -h, --help show this message and exit.
|
参数名 |
参数类型 |
是否必选 |
参数说明 |
|---|---|---|---|
|
-i / --job-id |
string |
否 |
查询指定dli spark作业id的任务详情。 |
|
-n / --job-name |
string |
否 |
查询指定作业名称的dli spark作业或根据作业名称关键字过滤dli spark作业。 |
|
-pn / --page-num |
int |
否 |
作业索引页,默认是第1页。 |
|
-ps / --page-size |
int |
否 |
每页显示的作业数量,默认是20。 |
|
-v / --verbose |
bool |
否 |
显示详细的信息开关,默认关闭。 |
示例:查询dli spark所有作业。
ma-cli dli-job get-job

使用ma-cli dli-job submit命令提交dli spark作业
执行ma-cli dli-job submit命令提交dli spark作业。
ma-cli dli-job submit命令需要指定一个位置参数yaml_file表示作业的配置文件路径,如果不指定该参数,则表示配置文件为空。配置文件是一个yaml格式的文件,里面的参数就是命令的option参数。此外,如果用户在命令行中同时指定yaml_file配置文件和option参数,命令行中指定的option参数的值将会覆盖配置文件相同的值。
命令参数预览
ma-cli dli-job submit -h
usage: ma-cli dli-job submit [options] [yaml_file]...
submit dli spark job.
example:
ma-cli dli-job submit --name test-spark-from-sdk
--file test/sub_dli_task.py
--obs-bucket dli-bucket
--queue dli_test
--spark-version 2.4.5
--driver-cores 1
--driver-memory 1g
--executor-cores 1
--executor-memory 1g
--num-executors 1
options:
--file text python file or app jar.
-cn, --class-name text your application's main class (for java / scala apps).
--name text job name.
--image text full swr custom image path.
--queue text execute queue name.
-obs, --obs-bucket text dli obs bucket to save logs.
-sv, --spark-version text spark version.
-st, --sc-type [a|b|c] compute resource type.
--feature [basic|custom|ai] type of the spark image used by a job (default: basic).
-ec, --executor-cores integer executor cores.
-em, --executor-memory text executor memory (eg. 2g/2048mb).
-ne, --num-executors integer executor number.
-dc, --driver-cores integer driver cores.
-dm, --driver-memory text driver memory (eg. 2g/2048mb).
--conf text arbitrary spark configuration property (eg. ).
--resources text resources package path.
--files text files to be placed in the working directory of each executor.
--jars text jars to include on the driver and executor class paths.
-pf, --py-files text python files to place on the pythonpath for python apps.
--groups text user group resources.
--args text spark batch job parameter args.
-q, --quiet exit without waiting after submit successfully.
-c, --config-file path configure file path for authorization.
-d, --debug debug mode. shows full stack trace when error occurs.
-p, --profile text cli connection profile to use. the default profile is "default".
-h, -h, --help show this message and exit.
yaml文件预览
# dli-demo.yaml
name: test-spark-from-sdk
file: test/sub_dli_task.py
obs-bucket: ${your_bucket}
queue: dli_notebook
spark-version: 2.4.5
driver-cores: 1
driver-memory: 1g
executor-cores: 1
executor-memory: 1g
num-executors: 1
## [optional]
jars:
- ./test.jar
- obs://your-bucket/jars/test.jar
- your_group/test.jar
## [optional]
files:
- ./test.csv
- obs://your-bucket/files/test.csv
- your_group/test.csv
## [optional]
python-files:
- ./test.py
- obs://your-bucket/files/test.py
- your_group/test.py
## [optional]
resources:
- name: your_group/test.py
type: pyfile
- name: your_group/test.csv
type: file
- name: your_group/test.jar
type: jar
- name: ./test.py
type: pyfile
- name: obs://your-bucket/files/test.py
type: pyfile
## [optional]
groups:
- group1
- group2
指定options参数提交dli spark作业示例:
$ ma-cli dli-job submit --name test-spark-from-sdk \
--file test/sub_dli_task.py \
--obs-bucket ${your_bucket} \
--queue dli_test \
--spark-version 2.4.5 \
--driver-cores 1 \
--driver-memory 1g \
--executor-cores 1 \
--executor-memory 1g \
--num-executors 1
|
参数名 |
参数类型 |
是否必选 |
参数说明 |
|---|---|---|---|
|
yaml_file |
string |
否 |
dli spark作业的配置文件本地路径,如果不传则表示配置文件为空。 |
|
--file |
string |
是 |
程序运行入口文件,支持本地文件路径、obs路径或者用户已上传到dli资源管理系统的类型为jar或pyfile的程序包名。 |
|
-cn / --class_name |
string |
是 |
批处理作业的java/spark主类。 |
|
--name |
string |
否 |
创建时用户指定的作业名称,不能超过128个字符。 |
|
--image |
string |
否 |
自定义镜像路径,格式为:组织名/镜像名:镜像版本。当用户设置“feature”为“custom”时,该参数生效。用户可通过与“feature”参数配合使用,指定作业运行使用自定义的spark镜像。 |
|
-obs / --obs-bucket |
string |
否 |
保存spark作业的obs桶,需要保存作业时配置该参数。同时也可作为提交本地文件到resource的中转站。 |
|
-sv/ --spark-version |
string |
否 |
作业使用spark组件的版本号。 |
|
-st / `--sc-type |
string |
否 |
如果当前spark组件版本为2.3.2,则不填写该参数。 如果当前spark组件版本为2.3.3,则在“feature”为“basic”或“ai”时填写。如果不填写,则使用默认的spark组件版本号2.3.2。 |
|
--feature |
string |
否 |
作业特性。表示用户作业使用的spark镜像类型,默认值为basic。
|
|
--queue |
string |
否 |
用于指定队列,填写已创建dli的队列名。必须为通用类型的队列。队列名称的获取请参考表5。 |
|
-ec / --executor-cores |
string |
否 |
spark应用每个executor的cpu核数。该配置项会替换sc_type中对应的默认参数。 |
|
-em / --executor-memory |
string |
否 |
spark应用的executor内存,参数配置例如2g,2048m。该配置项会替换“sc_type”中对应的默认参数,使用时必须带单位,否则会启动失败。 |
|
-ne / --num-executors |
string |
否 |
spark应用executor的个数。该配置项会替换sc_type中对应的默认参数。 |
|
-dc / --driver-cores |
string |
否 |
spark应用driver的cpu核数。该配置项会替换sc_type中对应的默认参数。 |
|
-dm / --driver-memory |
string |
否 |
spark应用的driver内存,参数配置例如2g,2048m。该配置项会替换“sc_type”中对应的默认参数,使用时必须带单位,否则会启动失败。 |
|
--conf |
array of string |
否 |
batch配置项,参考。如果需要指定多个参数,可以使用--conf conf1 --conf conf2。 |
|
--resources |
array of string |
否 |
资源包名称。支持本地文件,obs路径及用户已上传到dli资源管理系统的文件。如果需要指定多个参数,可以使用--resources resource1 --resources resource2。 |
|
--files |
array of string |
否 |
用户已上传到dli资源管理系统的类型为file的资源包名。也支持指定obs路径,例如:obs://桶名/包名。同时也支持本地文件。如果需要指定多个参数,可以使用--files file1 --files file2。 |
|
--jars |
array of string |
否 |
用户已上传到dli资源管理系统的类型为jar的程序包名。也支持指定obs路径,例如:obs://桶名/包名。也支持本地文件。如果需要指定多个参数,可以使用--jars jar1 --jars jar2。 |
|
-pf /--python-files |
array of string |
否 |
用户已上传到dli资源管理系统的类型为pyfile的资源包名。也支持指定obs路径,例如:obs://桶名/包名。也支持本地文件。如果需要指定多个参数,可以使用--python-files py1 --python-files py2。 |
|
--groups |
array of string |
否 |
资源分组名称,如果需要指定多个参数,可以使用--groups group1 --groups group2。 |
|
--args |
array of string |
否 |
传入主类的参数,即应用程序参数。如果需要指定多个参数,可以使用--args arg1 --args arg2。 |
|
-q / --quiet |
bool |
否 |
提交dli spark作业成功后直接退出,不再同步打印任务状态。 |
示例
- 通过yaml_file文件提交dli spark作业。
$ma-cli dli-job submit dli_job.yaml

- 指定命令行options参数提交dli spark作业。
$ma-cli dli-job submit --name test-spark-from-sdk \ > --file test/jumpstart-trainingjob-gallery-pytorch-sample.ipynb \ > --queue dli_ma_notebook \ > --spark-version 2.4.5 \ > --driver-cores 1 \ > --driver-memory 1g \ > --executor-cores 1 \ > --executor-memory 1g \ > --num-executors 1

使用ma-cli dli-job get-log命令查询dli spark运行日志
执行ma-cli dli-job get-log命令查询dli spark作业后台的日志。
$ ma-cli dli-job get-log -h
usage: ma-cli dli-job get-log [options]
get dli spark job log details.
example:
# get job log by job id
ma-cli dli-job get-log --job-id ${job_id}
options:
-i, --job-id text get dli spark job details by job id. [required]
-c, --config-file text configure file path for authorization.
-d, --debug debug mode. shows full stack trace when error occurs.
-p, --profile text cli connection profile to use. the default profile is "default".
-h, -h, --help show this message and exit.
|
参数名 |
参数类型 |
是否必选 |
参数说明 |
|---|---|---|---|
|
-i / --job-id |
string |
是 |
查询指定dli spark作业id的任务日志。 |
示例:查询指定作业id的dli spark作业运行日志。
ma-cli dli-job get-log --job-id ${your_job_id}

使用ma-cli dli-job get-queue命令查询dli队列
执行ma-cli dli-job get-queue命令查询dli队列。
ma-cli dli-job get-queue -h
usage: ma-cli dli-job get-queue [options]
get dli queues info.
example:
# get dli queue details by queue name
ma-cli dli-job get-queue --queue-name $queue_name}
options:
-pn, --page-num integer range specify which page to query. [x>=1]
-ps, --page-size integer range the maximum number of results for this query. [x>=1]
-n, --queue-name text get dli queue details by queue name.
-t, --queue-type [sql|general|all]
dli queue type (default "all").
-tags, --tags text get dli queues by tags.
-c, --config-file path configure file path for authorization.
-d, --debug debug mode. shows full stack trace when error occurs.
-p, --profile text cli connection profile to use. the default profile is "default".
-h, -h, --help show this message and exit.
|
参数名 |
参数类型 |
是否必选 |
参数说明 |
|---|---|---|---|
|
-n / --queue-name |
string |
否 |
指定需要查询的dli队列名称。 |
|
-t / --queue-type |
string |
否 |
指定查询的dli队列类型,支持sql、general和all,默认是all。 |
|
-tags / --tags |
string |
否 |
指定查询的dli队列tags。 |
|
-pn / --page-num |
int |
否 |
dli队列页索引,默认是第1页。 |
|
-ps / --page-size |
int |
否 |
每页显示的dli队列数量,默认是20。 |
示例:查询队列名为“dli_ma_notebook”的队列信息。
ma-cli dli-job get-queue --queue-name dli_ma_notebook

使用ma-cli dli-job get-resource命令查询dli分组资源
执行ma-cli dli-job get-resource命令获取dli资源详细信息,如资源名称,资源类型等。
$ ma-cli dli-job get-resource -h
usage: ma-cli dli-job get-resource [options]
get dli resource info.
example:
# get dli resource details by resource name
ma-cli dli-job get-resource --resource-name ${resource_name}
options:
-n, --resource-name text get dli resource details by resource name.
-k, --kind [jar|pyfile|file|modelfile]
dli resources type.
-g, --group text get dli resources by group.
-tags, --tags text get dli resources by tags.
-c, --config-file text configure file path for authorization.
-d, --debug debug mode. shows full stack trace when error occurs.
-p, --profile text cli connection profile to use. the default profile is "default".
-h, -h, --help show this message and exit.
|
参数名 |
参数类型 |
是否必选 |
参数说明 |
|---|---|---|---|
|
-n / --resource-name |
string |
否 |
按dli分组资源名称查询dli资源详细信息。 |
|
-k / --kind |
string |
否 |
按dli分组资源类型查询dli资源详细信息,支持jar、pyfile、file和modelfile。 |
|
-g / --group |
string |
否 |
按dli分组资源组名查询dli资源组详细信息。 |
|
-tags / --tags |
string |
否 |
通过dli分组资源tags获取dli资源详细信息。 |
示例:查询所有dli分组资源信息。
ma-cli dli-job get-resource

使用ma-cli dli-job upload命令上传文件到dli分组资源
ma-cli dli-job upload命令支持将本地文件或obs文件上传到dli资源组。
$ ma-cli dli-job upload -h
usage: ma-cli dli-job upload [options] paths...
upload dli resource.
tips: --obs-path is need when upload local file.
example:
# upload an obs path to dli resource
ma-cli dli-job upload obs://your-bucket/test.py -g test-group --kind pyfile
# upload a local path to dli resource
ma-cli dli-job upload ./test.py -g test-group -obs ${your-bucket} --kind pyfile
# upload local path and obs path to dli resource
ma-cli dli-job upload ./test.py obs://your-bucket/test.py -g test-group -obs ${your-bucket}
options:
-k, --kind [jar|pyfile|file] dli resources type.
-g, --group text dli resources group.
-tags, --tags text dli resources tags, follow --tags `key1`=`value1`.
-obs, --obs-bucket text obs bucket for upload local file.
-async, --is-async whether to upload resource packages in asynchronous mode. the default value is false.
-c, --config-file text configure file path for authorization.
-d, --debug debug mode. shows full stack trace when error occurs.
-p, --profile text cli connection profile to use. the default profile is "default".
-h, -h, --help show this message and exit.
|
参数名 |
参数类型 |
是否必选 |
参数说明 |
|---|---|---|---|
|
paths |
string |
是 |
需要上传到dli分组资源的本地文件路径或者obs路径,支持同时传入多个路径。 |
|
-k / --kind |
string |
否 |
上传文件的类型,支持jar、pyfile和file。 |
|
-g / --group |
string |
否 |
上传文件的dli分组名。 |
|
-tags / --tags |
string |
否 |
上传文件的tag。 |
|
-obs / --obs-bucket |
string |
否 |
如果上传文件包含本地路径,则需要指定一个obs桶作为中转。 |
|
-async / --is-async |
bool |
否 |
异步上传文件,推荐使用。 |
示例
- 上传本地文件到dli分组资源
ma-cli dli-job upload ./test.py -obs ${your-bucket} --kind pyfile
- 上传obs文件到dli分组资源
ma-cli dli-job upload obs://your-bucket/test.py --kind pyfile

使用ma-cli dli-job stop命令停止dli spark作业
执行ma-cli dli-job stop命令停止dli spark作业。
$ ma-cli dli-job stop -h
usage: ma-cli dli-job stop [options]
stop dli spark job by job id.
example:
stop training job by job id
ma-cli dli-job stop --job-id ${job_id}
options:
-i, --job-id text get dli spark job event by job id. [required]
-y, --yes confirm stop operation.
-c, --config-file text configure file path for authorization.
-d, --debug debug mode. shows full stack trace when error occurs.
-p, --profile text cli connection profile to use. the default profile is "default".
-h, -h, --help show this message and exit.
|
参数名 |
参数类型 |
是否必选 |
参数说明 |
|---|---|---|---|
|
-i / --job-id |
string |
是 |
dli spark作业id。 |
|
-y / --yes |
bool |
否 |
强制关闭指定dli spark作业。 |
示例
ma-cli dli-job stop -i ${your_job_id}

相关文档
意见反馈
文档内容是否对您有帮助?
如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨