saltant Python SDK
项目描述
saltant Python SDK
saltant-py是saltant的Python SDK。它允许您在Python环境中执行saltant API上的任何操作(一些操作更为方便)。作为复习,您可能想查看saltant的API参考以了解哪些操作是可能的。
saltant-py的文档相当全面,可在saltant-py.readthedocs.io找到。
安装
使用pip,
pip install saltant-py
或者,在克隆此存储库后,从源运行
python setup.py install
其中python
是2.7或3.5+版本。
用法
通过以下方式连接到saltant服务器
from saltant.client import from_env
client = from_env() # uses env vars
或
from saltant.client import Client
client = Client(
base_api_url='https://shahlabjobs.ca/api/',
auth_token='p0gch4mp101fy451do9uod1s1x9i4a')
您可以对任务类型执行API操作
# Load in a task type
my_task_type = client.container_task_types.get(id=1)
# Edit the description of the task type
my_task_type.description = "this description is better"
# Push the description upstream
my_task_type.put()
您可以启动任务实例
# Launch a task instance
my_task_instance = client.container_task_instances.create(
task_type_id=my_task_type.id,
task_queue_id=1,
arguments={"launch_code": 12345},
)
# Wait for the task instance to finish
my_task_instance.wait_until_finished()
等等!(请参阅文档以获取更多详细信息。)
另请参阅
saltant-cli,saltant的命令行界面。