简体   繁体   English

如何使用 config() 中的 post_hook 参数在特定 DBT 模型的末尾运行 python 脚本?

[英]How can I run a python script at the end of a specific DBT model, using the post_hook param within config()?

I would like to be able to run a python script only at the end of a specific DBT model.我希望能够仅在特定 DBT 模型的末尾运行 python 脚本。 My idea is to use post_hook parameter from config() function of that specific model.我的想法是使用该特定模型的 config() 函数中的 post_hook 参数。

Is there a way to do this?有没有办法做到这一点?

You cannot do this today.你今天不能这样做。 dbt does not provide a Python runtime. dbt 不提供 Python 运行时。

Depending on how you deploy dbt, you could use fal for this (either open source or cloud): https://fal.ai/ , or another (heavier) orchestrator, like Airflow, Dagster, or Prefect.根据您部署 dbt 的方式,您可以为此使用 fal(开源或云): https ://fal.ai/ 或其他(更重的)编排器,如 Airflow、Dagster 或 Prefect。

You should also know that there is an active Discussion about External Nodes and/or executable exposures that would solve for this use case: https://github.com/dbt-labs/dbt-core/discussions/5073您还应该知道,有一个关于外部节点和/或可执行公开的积极讨论可以解决这个用例: https ://github.com/dbt-labs/dbt-core/discussions/5073

dbt is also planning to release Python-language models in the near future, but that is unlikely to solve this use case; dbt 还计划在不久的将来发布Python 语言模型,但这不太可能解决这个用例; that Python will be executed in your Warehouse environment, and may or may not be able to make arbitrary web requests (eg, Snowpark is really just dataframe-python that gets transpiled to SQL) Python 将在您的 Warehouse 环境中执行,并且可能会或可能不会发出任意 Web 请求(例如,Snowpark 实际上只是转换为 SQL 的 dataframe-python)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 DBT运行(或特定模型)完成后如何运行python代码? - How can I run python code after a DBT run (or a specific model) is completed? 如何在Selenium中运行代码以在一天中的特定时间在python脚本而非cron中执行功能 - How can I run code in selenium to execute a function at a specific hour of the day within the python script not cron 如何从 Flask 中运行 python 脚本 - How can I run a python script from within Flask 如何在Kodi中运行python脚本? - How can I run a python script from within Kodi? 如何从 Python 脚本中运行 Streamlit 应用程序? - How Can I Run a Streamlit App from within a Python Script? 如何使用特定的解释器运行 python 脚本? - How do I run a python script using a specific interpreter? 我可以使用 Python configparser 删除 config.ini 文件的一部分中的特定值吗? - Can I delete a specific value within a section of a config.ini file using Python configparser? 如何在使用swift的同时运行/调用python脚本? - How can I run/call a python script while using swift? 如何使用 Spyder 中的 IPython 控制台运行 python 脚本? - How can I run a python script using the IPython console in Spyder? 如何在一段时间内在Python上的每个特定时间运行函数? - How can I run a function every specific time within a while cycle on python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM