Replies: 1 comment
-
Could you properly format your post using code blocks for code and terminal outputs? Thanks. Please read the documentation on parameters: https://quarto.org/docs/computations/parameters.html |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
Hi,
I'm looking to pass in a parameter from the quarto document into a python cell.
The utility of this is I'm running 20 reports with different data, and I only need to get the ID of the report that I'm running.
Since I have access to the metadata variables in markdown with {{<>}} I thought there might be a similar syntax or something that I'm missing within the python cell.
However I'm getting a name error whenever I try to reference metadata or params, and checking locals() within the python cell shows no evidence of access to either of these.
I'm on quarto v Quarto 1.6.42
This is a test that's failing to show params.
title: "Test Document"
engine: jupyter
jupyter: python3
format:
html:
code-fold: true
params:
greeting: "Hello from Quarto!"
If you're interested in the context, this is the cell of a notebook that's running the quarto document generation.
`import subprocess
orgs = get_visible_orgs(tree_widget)
for org in orgs:
output_name = f"dash_quarterly_report_{org["title"]}.pdf"
new_title = f"Dash – Quarterly Report - {org["title"]}"
term = 4
subprocess.run([
"quarto", "render", "dash_quarterly_report.qmd",
"--execute",
"--output", output_name,
"--metadata", f"title={new_title}",
"--metadata", f"organisation={org["id"]}",
"--metadata", f"start_date={saved_form_values[0]}",
"--metadata", f"end_date={saved_form_values[1]}",
"--metadata", f"term={saved_form_values[5]}",
"--metadata", f"year={saved_form_values[6]}",
])
print(f"Generated report: {new_title}")`
I realise I've probably missed something, sorry! Any help appreciated.
Beta Was this translation helpful? Give feedback.
All reactions