How to access params in scripts ? Support global params ?
eromoe opened this issue · comments
eromoe commented
I have same variables need use in multiple tasks/scripts .
My code :
# %% tags=["parameters"]
upstream = ['get']
product = None
params = []
# %%
output_path = product['data']
basefreq = params['basefreq']
print(basefreq)
got error :
Exception encountered at "In [4]":
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_43496\3265420907.py in <cell line: 1>()
----> 1 basefreq = params['basefreq']
2 print(basefreq)
3
4 import sys
5 sys.path.insert(0, 'E:\Workspace\github_me\quant_pipeline_demo\scripts')
TypeError: list indices must be integers or slices, not str
Eduardo Blancas commented
the parameters are injected as new variables in your scripts/notebooks, so assuming that you have something like this in your pipeline.yaml:
tasks:
- source: script.py
params:
basefreq: some_value
then, in your script, you can access it like this:
# %% tags=["parameters"]
upstream = ['get']
product = None
# ploomber will inject basefreq here
# %%
output_path = product['data']
print(basefreq)
eromoe commented
@edublancas OOOH, I miss it , directly ! That's cool :)