-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
subdag decorator: Variable not recognized #115
Comments
OK, so I think this is something that one should be allowed to do, but I think we want to be careful about how we enable it. Reasons to do it
Reasons not to do it
Possibilities
I'm voting for (3), as it doesn't require much complexity, adds significant readability, and unblocks the user. |
Just to clarify we're talking about how one would interpret this function -- where would the declared function dependencies come from, right? In particular as the error states "backtesting_lookback_period" right? now:@subdag(load_price_data,inputs={})
def optimisation_window_data(end_to_end_price_for_all_ticker: pd.DataFrame,
backtesting_lookback_period: int) -> int:
return backtesting_lookback_period This assumes both declared dependencies come from the subdag. pass it in as an input@subdag(load_price_data,inputs={"backtesting_lookback_period": source("backtesting_lookback_period")})
def optimisation_window_data(end_to_end_price_for_all_ticker: pd.DataFrame,
backtesting_lookback_period: int) -> int:
return backtesting_lookback_period This I think works today, right? allow by defaultHard to know what comes from where. What if the subdag has one defined and the current one also has allow with flag@subdag(load_price_data,inputs={}, fill_with_external_sources=True)
def optimisation_window_data(end_to_end_price_for_all_ticker: pd.DataFrame,
backtesting_lookback_period: int) -> int:
return backtesting_lookback_period This is clear -- but not clear which one is satisfied. Would silently change behavior if the underlying DAG suddenly included such a node. specify what parameter(s) do not come from the subdag@subdag(load_price_data,inputs={}, external=["backtest_lookback_period"])
def optimisation_window_data(end_to_end_price_for_all_ticker: pd.DataFrame,
backtesting_lookback_period: int) -> int:
return backtesting_lookback_period This seems pretty clear. It will get as long as the argument list though. @subdag(load_price_data,inputs={}, inject={"backtest_lookback_period": source("backtest_lookback_period")])
def optimisation_window_data(end_to_end_price_for_all_ticker: pd.DataFrame,
backtesting_lookback_period: int) -> int:
return backtesting_lookback_period This seems like inputs above. So likely not useful to have separate. |
More ideas: Use
|
I'd almost rather flip the script (although I'm not sure this makes sense now that we've already done it): @subdag(load_price_data,inputs={}, from_subdag=["end_to_end_price_for_all_ticker"])
def optimisation_window_data(end_to_end_price_for_all_ticker: pd.DataFrame,
backtesting_lookback_period: int) -> int:
return backtesting_lookback_period I find this clearer to read, as the non-subdag components will have obvious sources, and the subDAG components will still be easily identifiable. It could be either/or ( |
This is now complete, released in |
When I add a subdag decorator to a function, the function itself is not able to recognise variables that comes prior in the dag(as declared by the main driver).
Stack Traces
https://fdm-bm77109.slack.com/archives/C04RWSYME79/p1679167875228639
Screenshots
Assume this the main driver function, here config_fetching module fetches a variable called backtesting_lookback_period
And the construct_optimisation_window_data module looks like this
When I run the driver module, I get this error
So, essentially, the decorated function is not able to read backtesting_lookback_period node - which comes before in the DAG compilation.
The text was updated successfully, but these errors were encountered: