在Saturn Cloud上运行Prefect Cloud流程的客户端库
项目描述
prefect-saturn
prefect-saturn
是一个Python包,它使得在 Prefect Cloud 上使用 Saturn Cloud 运行Dask集群中的流程变得容易。有关详细教程,请参阅 "使用Prefect Cloud实现容错数据管道 "。
安装
prefect-saturn
可在PyPi上找到。
pip install prefect-saturn
prefect-saturn
可以直接从GitHub安装
pip install git+https://github.com/saturncloud/prefect-saturn.git@main
入门
prefect-saturn
旨在在 Saturn Cloud 环境中使用,例如Jupyter笔记本。
import prefect
from prefect import Flow, task
from prefect_saturn import PrefectCloudIntegration
@task
def hello_task():
logger = prefect.context.get("logger")
logger.info("hello prefect-saturn")
flow = Flow("sample-flow", tasks=[hello_task])
project_name = "sample-project"
integration = PrefectCloudIntegration(
prefect_cloud_project_name=project_name
)
flow = integration.register_flow_with_saturn(flow)
flow.register(
project_name=project_name,
labels=["saturn-cloud"]
)
自定义Dask
您可以根据需要自定义运行prefect流程的Dask集群的大小和行为。prefect_saturn.PrefectCloudIntegration.register_flow_with_saturn()
接受两个参数来完成此操作
dask_cluster_kwargs
:传递给构造函数dask_saturn.SaturnCluster
的关键字参数。dask_adapt_kwargs
:用于配置 "自适应扩展" 的关键字参数
例如,下面的代码告诉土星(Saturn)这个流程应该在具有3个xlarge工作节点的Dask集群上运行,并且一旦流程运行完成,prefect应该关闭集群。
flow = integration.register_flow_with_saturn(
flow=flow,
dask_cluster_kwargs={
"n_workers": 3,
"worker_size": "xlarge",
"autoclose": True
}
)
flow.register(
project_name=project_name,
labels=["saturn-cloud"]
)
贡献
请参阅CONTRIBUTING.md
,了解如何测试和对prefect-saturn
进行贡献。
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
prefect-saturn-0.6.0.tar.gz (9.1 kB 查看哈希值)
构建分布
prefect_saturn-0.6.0-py2-none-any.whl (10.3 kB 查看哈希值)
关闭
prefect-saturn-0.6.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 517dbf3ae59a2b4c1aef308ec80b2d469e6c7fe9ebd326983b53c6f31d6ce8f7 |
|
MD5 | 6b8e0db37e0d9856cf693535ed35b194 |
|
BLAKE2b-256 | a5ddc48cb958a9d211fed4f6359cac697bee020106b33a20f73ec5b8fcb812e7 |
关闭
prefect_saturn-0.6.0-py2-none-any.whl的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 4818968de5838f96008501bb385a5c2996121e97bdf8081d2ba72fd885b8ff41 |
|
MD5 | f6b094936ee64f1b261fce6799d66239 |
|
BLAKE2b-256 | c989dbd9ec6c7f4b3aa8007492bd378d9d4d2755ab5ee21696c4bc5f8c09eaf5 |