下面使用 Python SDK 的方式,创建一个 App,作用是拷贝一个输入路径 inputparam1 的内容到一个输出路径 output,并打印自定义的环境变量,App 相关定义如下:
#encoding=utf-8
import sys
from batchcompute import Client, ClientError
from batchcompute import CN_BEIJING as REGION
from batchcompute.resources import (
JobDescription, TaskDescription, DAG, AutoCluster, GroupDescription, ClusterDescription, AppDescription
)
ACCESS_KEY_ID='xxxx' # 填写您的 ACCESS_KEY_ID
ACCESS_KEY_SECRET='xxxx' # 填写您的 ACCESS_KEY_SECRET
def main():
try:
client = Client(REGION, ACCESS_KEY_ID, ACCESS_KEY_SECRET)
app_desc = {
"Name":"DemoApp_vm",
"Daemonize":False,
"VM":{
"ECSImageId":"img-ubuntu-vpc",
},
"CommandLine":"/bin/bash -c 'cp -r ${inputparam1} ${output} && echo ${inputparam2} && echo $env1'",
"InputParameters":{
"inputparam1":{
"Description":"",
"Type":"String",
"Default":"",
"LocalPath":"/home/input/"
},
"inputparam2":{
"Description":"",
"Type":"String",
"Default":"",
"LocalPath":""
}
},
"OutputParameters":{
"output":{
"Description":"",
"Type":"String",
"LocalPath":"/home/output/"
}
},
"Config":{
"ResourceType":{
"Default":"OnDemand",
"Overwritable":True
},
"InstanceType":{
"Description":"",
"Default":"ecs.c5.large",
"Overwritable":True
},
"InstanceCount":{
"Description":"",
"Default":1,
"Overwritable":True
},
"MinDiskSize":{
"Description":"",
"Default":40,
"Overwritable":True
},
"DiskType":{
"Description":"",
"Default":"cloud_efficiency",
"Overwritable":True
},
"MaxRetryCount":{
"Description":"",
"Default":0,
"Overwritable":True
},
"Timeout":{
"Description":"",
"Default":86400,
"Overwritable":True
}
},
"EnvVars":{
"env1":"abcd"
}
}
appName = client.create_app(app_desc).Name
print('App created: %s' % appName)
except ClientError, e:
print (e.get_status_code(), e.get_code(), e.get_requestid(), e.get_msg())
if __name__ == '__main__':
sys.exit(main())
#encoding=utf-8
import sys
from batchcompute import Client, ClientError
from batchcompute import CN_BEIJING as REGION
from batchcompute.resources import (
JobDescription, TaskDescription, DAG, AutoCluster, GroupDescription, ClusterDescription, AppDescription
)
ACCESS_KEY_ID='xxxx' # 填写您的 ACCESS_KEY_SECRET
ACCESS_KEY_SECRET='xxxxxx' # 填写您的 ACCESS_KEY_SECRET
def main():
try:
client = Client(REGION, ACCESS_KEY_ID, ACCESS_KEY_SECRET)
app_desc = {
"Name":"DemoApp_Docker",
"Daemonize":False,
"Docker":{
"Image":"localhost:5000/dockerimagename",
"RegistryOSSPath":"oss://bucket-name/dockers/"
},
"CommandLine":"/bin/bash -c 'cp -r ${inputparam1} ${output} && echo ${inputparam2} && echo $env1'",
"InputParameters":{
"inputparam1":{
"Description":"",
"Type":"String",
"Default":"",
"LocalPath":"/home/input/"
},
"inputparam2":{
"Description":"",
"Type":"String",
"Default":"",
"LocalPath":""
}
},
"OutputParameters":{
"output":{
"Description":"",
"Type":"String",
"LocalPath":"/home/output/"
}
},
"Config":{
"ResourceType":{
"Default":"OnDemand",
"Overwritable":True
},
"InstanceType":{
"Description":"",
"Default":"ecs.c5.large",
"Overwritable":True
},
"InstanceCount":{
"Description":"",
"Default":1,
"Overwritable":True
},
"MinDiskSize":{
"Description":"",
"Default":40,
"Overwritable":True
},
"DiskType":{
"Description":"",
"Default":"cloud_efficiency",
"Overwritable":True
},
"MaxRetryCount":{
"Description":"",
"Default":0,
"Overwritable":True
},
"Timeout":{
"Description":"",
"Default":86400,
"Overwritable":True
}
},
"EnvVars":{
"env1":"abcd"
}
}
appName = client.create_app(app_desc).Name
print('App created: %s' % appName)
except ClientError, e:
print (e.get_status_code(), e.get_code(), e.get_requestid(), e.get_msg())
if __name__ == '__main__':
sys.exit(main())
#encoding=utf-8
import sys
from batchcompute import Client, ClientError
from batchcompute import CN_BEIJING as REGION
from batchcompute.resources import (
JobDescription, TaskDescription, DAG, AutoCluster, GroupDescription, ClusterDescription, AppDescription, AppJobDescription
)
ACCESS_KEY_ID='xxxx' # 填写您的 ACCESS_KEY_ID
ACCESS_KEY_SECRET='xxxx' # 填写您的 ACCESS_KEY_SECRET
LOG_PATH = 'oss://bucket-name/bc_test/log/'
ERR_PATH = 'oss://bucket-name/bc_test/error/'
def main():
try:
client = Client(REGION, ACCESS_KEY_ID, ACCESS_KEY_SECRET)
job_desc = AppJobDescription()
# Create job description.
job_desc.Name = "App_demo_test_job_docker"
job_desc.Description = "Test of create app job."
job_desc.Type = 'App'
job_desc.App.AppName = 'DemoApp_Docker'
job_desc.App.Config.InstanceType = "ecs.sn2.medium"
job_desc.App.Inputs["inputparam1"] = "oss://bucket-name/bc_test/input/";
job_desc.App.Inputs["inputparam2"] = "abcd1234";
job_desc.App.Outputs["output"] = "oss://bucket-name/bc_test/output/"
job_desc.App.Logging.StdoutPath = LOG_PATH
job_desc.App.Logging.StderrPath = ERR_PATH
job_id = client.create_job(job_desc).Id
print('App job created: %s' % job_id)
except ClientError, e:
print (e.get_status_code(), e.get_code(), e.get_requestid(), e.get_msg())
if __name__ == '__main__':
sys.exit(main())
本文转载自公众号读芯术(ID:AI_Discovery)。 随着数以百万计的物联网连接设备大...
作者 | 辽天 来源 | 阿里巴巴云原生公众号 导读:本文将 rocktmq-spring-boot 的...
2021年1月26日,Linux sudo堆漏洞被公开。利用此漏洞,攻击者可以在默认配置的su...
TOP云(west.cn)2月18日消息,近日 域名交易 市场爆,而国外DN最新一期榜单也已...
一、内部类 (一)什么是内部类? 可以在类中再定义类,就叫做内部类,这个内部类所...
01 /?什么是代码加密 云端加密代码服务是云效团队的自研产品 是目前国内率先支持...
Blueprint 描述了镜像信息。 被如下接口引用:DescribeBlueprints。 名称 类型 ...
作者 | 道坚 来源 | 阿里技术公众号 前言 本文从操作系统实际调用角度(以CentOS...
近日,海外媒体 域名 杂志(DomainMagazine)发布了一篇资讯,介绍了.top溢价域...
本文转载自微信公众号「程序喵大人」,作者程序喵大人。转载本文请联系程序喵大...