This message was deleted.
# hamilton-help
s
This message was deleted.
s
Thanks for the question. In short, Hamilton DAGs are static, and so configuration is only evaluated at driver construction time, not dynamically. So "no" is the answer to your question. But can you help me understand your intent in doing this? There are likely alternative patterns I can suggest with some more context.
👍 1
j
Thanks for the answer @Stefan Krawczyk. We have some values that are only evaluated from nodes after the DAG is being run. I was wondering if we could use some of the values generated by functions in the DAG to determine what nodes should be outputted from the DAG run. Our use case for hamilton is to orchestrate a bunch of dependent metrics that we need to calculate in code. So its more for the topographical sorting of nodes that hamilton provides. I don't know if that provides enough context
🤔 1
s
@Jesuseyi Fasuyi are the values intermingled for a run? Or would they be the same?
Also, how big is your data? I’m happy to jump on a call this week to understand things a bit better and suggest some paths forward (or add to our roadmap).
j
@Stefan Krawczyk They would be the same for a run, they're not intermingled. The data is not very big, a few mega bytes in total.
👍 1
s
If that’s the case, could you inspect/know what those values are before instantiating the Hamilton driver? E.g. have @config when code for the different regions
Copy code
# marketing.py
@config.when(region="US")
def marketing_spend__us(tv_spend: pd.Series, radio_spend: pd.Series) -> pd.Series:
    return tv_spend + radio_spend

@config.when(region="UK")
def marketing_spend__uk(tv_spend: pd.Series, radio_spend: pd.Series, billboard_spend: pd.Series) -> pd.Series:
    return tv_spend + radio_spend + billboard_spend
then in run_us.py:
Copy code
import marketing
from hamilton import driver

region = "US"  # or some other way to figure out what the region should be
dr = driver.Driver({"region": region}, marketing)
df = dr.execute(["marketing_spend", ...], input={"file_location": "us_input_file.csv"})
👍 1
or is the input opaque, and therefore you don’t know ahead of time?
j
Oh yes that works. We know the input ahead of time.
👍 1