How can I render one (or multiple) qmd documents from a Python script? #7814
Replies: 4 comments 3 replies
-
Not a particularly well-supported one, unfortunately. It's simple enough to use python's |
Beta Was this translation helpful? Give feedback.
-
What's the context of needing Python? Because Quarto CLI is independent of the language and is a CLI, it means you can use Bash/PowerShell to run Quarto using for loops, YAML parameters in files, etc. |
Beta Was this translation helpful? Give feedback.
-
I was exactly in the same situation as @nimoralesp, so here's my use case to answer this ...
I have a pipeline orchestrated by Prefect, which is a python-centric workflow orchestration tool (sort of like R's targets). The pipeline is a pretty standard thing; extract some data from a DB, clean and process it, then run some models. In several of those steps, we would build a report, a dashboard or similar. Quarto certainly excels for those tasks. So we basically would like to just add rendering those reports/dashboards as part of the pipeline, so that they will be updated whenever the upstream dependencies change.
So yeah, we can certainly go and manually run quarto render on the command line. But that just feels anticlimactic. Since all the pipeline is written in python, it just feels natural to want to render the reports from python. And it would be a breeze to integrate quarto in such data processing pipelines if something like In R, this is pretty straightforward because you can render Quarto docs/projects from within the R code. The equivalent of our Python use case in R is simply a {targets} pipeline. You add a target that renders the document, and that target depends on the upstream steps of data extraction and cleaning. It would be great to be able to do the same in Python. (Yes, I suppose subprocess kinda works, but it feels unnecessarily hacky.) |
Beta Was this translation helpful? Give feedback.
-
my bad!, I saw Bash/PowerShell and I certainly thought you meant do it manually ;)
Great to hear a wrapper is in progress!!!. My main concern of using subprocess was how to make sure it works in the correct environment and so on. I haven't tried, though. So I am just not sure. But in my mind, I kinda anticipated issues with that, particularly, when you move your pipeline from the local context and you deploy it somewhere else. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I'm mostly an R user, and I know that I can render one/multiple documents from a .R script using the Quarto library with a code like this:
I'd like to know if there's a Python library to do this. I saw a Quarto package for Python but I didn't find the functions.
Beta Was this translation helpful? Give feedback.
All reactions