卡布图服务的客户端
项目描述
示例用法
import time
from kabutopy.client import Client
# make a client instance with the base url of the kabuto service
client = Client("https://: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) 返回 Image
create_pipeline(name) 返回 Pipeline
create_job(command, image, attachments, pipeline) 返回 Job
submit_pipeline(pipeline)
get_job_logs(job, log_id=None) 返回 Log
get_job_results(job, pipeline=None) 返回 None 或 ByteIO
load_image(self, eid) 返回已加载 Image
load_pipeline(self, eid) 返回已加载 Pipeline
load_job(self, eid, pipeline) 返回已加载 Job
Image
classmethod:load(eid) 返回已加载图像
Pipeline
submit()
classmethod:load(eid) 返回已加载流水线
Job
get_logs(log_id=None) 返回 Log
get_results() 返回 None 或 ByteIO
classmethod:load(eid, pipeline) 返回已加载作业
Log
readlines(raw=True) 返回行或 (line_id, line) 如果 raw 为 False
refresh()
项目详情
关闭
kabutopy-1.0.0.tar.gz的哈希值
| 算法 | 哈希摘要 | |
|---|---|---|
| SHA256 | 519695f030bc57bfe5f4a6f0d7768dfb41ac81f0027d43d14264fef4854e11a4 |
|
| MD5 | 745c35f0ec253d7d7477715f4dc6c799 |
|
| BLAKE2b-256 | e58f9f8a55077cea0af18c3f2939616d35c17e460cc10a450d3f8ccdb1f7ac63 |