卡布托服务的客户

kabutop的Python项目详细描述


示例用法

import time
from kabutopy.client import Client

# make a client instance with the base url of the kabuto service
client = Client("http://localhost:5000")

# registering a user
client.register("user", "password", "email@email.com")

# loging in with a user, the client keeps track of the cookies
client.login("user", "password")

# creating an image
# name: string
# dockerfile: raw string / open file / path to a file
# repo_url: string
# nocache: boolean
image = client.create_image("my_image", dockerfile="some file", repo_url=None, nocache=False)

# requesting the image status and image id will poll the server
# if the id is still empty, or is the status is PENDING
# it will update id, state and output if the state is SUCCESS
# it will update state, error and output if the state is FAIL

while image.status == 'PENDING':
    sleep(1)

# creating a pipeline
# name: string
pipeline = client.create_pipeline("my_pipeline")

# creating a job
# command: string
# image: Image / int / string that is castable to int
# attachment: open file / path to a file (a list of these things also works when multiple files need to be uploaded)
# pipeline: Pipeline / int / string that is castable to int
job = client.create_job(command, image, attachments, pipeline)

# getting logs
# job: Job / int / string that is castable to int
# job_id: int / string that is castable to int
# you are able to get the logs trough the client
logs = client.get_job_logs(job)

# trough the job itself
# job_id: int / string that is castable to int
logs = job.get_logs()

# getting results
# job: Job / int / string that is castable to int
# trough the client
# will return None if the job has not yet started, is still running or has failed
result = client.get_job_results(job)

# trough the job itself
result = job.get_results()

类和方法

客户:

  • register(user, password, email)
  • login(user, password)
  • create_image(name, dockerfile=None, repo_url=None, nocache=False) returns Image
  • create_pipeline(name) returns Pipeline
  • create_job(command, image, attachments, pipeline) returns Job
  • submit_pipeline(pipeline)
  • get_job_logs(job, log_id=None) returns Log
  • get_job_results(job, pipeline=None) returns None or ByteIO
  • load_image(self, eid) returns loaded Image
  • load_pipeline(self, eid) returns loaded Pipeline
  • load_job(self, eid, pipeline) returns loaded Job

图片:

  • classmethod:load(eid) returns loaded image

管道:

  • submit()
  • classmethod:load(eid) returns loaded pipeline

工作:

  • get_logs(log_id=None) returns Log
  • get_results() returns None or ByteIO
  • classmethod:load(eid, pipeline) returns loaded job

日志:

  • readlines(raw=True) returns lines or (line_id, line) if raw is False
  • refresh()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何下载多个。java中的PDF文件   linux Java打开文件,形成实际用户主页~/   java如何在时间线内维护TableView选择?   java Hibernate注释@Where vs@WhereJoinTable   Java读/写访问异常FileNotFoundException(访问被拒绝)   继承在Java中是否可以扩展最后一个类?   Android HttpClient使用java使应用程序崩溃。lang.OutOfMemoryError:pthread_create   java为什么即使我在proguardproject中添加了jar文件,也会出现这种错误。txt?   如果添加JButton,swing Java FocusListener和KeyListener将无法工作   java使用solrj检索json格式的SolrDocument   使用Microsoft Visual Studio代码进行Java编程   java NoClassDefFoundError:org/apache/log4j/Logger   哈希集中包含相等对象的java   java中的参数化构造函数是否需要有一个主体?   java类似于NetBeans不必要的代码检测器   Java实践问题   java Blackberry“[projectname].调试文件丢失”和“I/O错误:找不到程序”jar