-
Notifications
You must be signed in to change notification settings - Fork 903
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
Why does kedro seem to avoid accessing run arguments or context in higher level functions? #4104
Comments
Hi @MarcelBeining. Thanks for raising this! I think it makes a lot of sense. Would you be interested in submitting a pull request for this? If not, the Kedro maintainers could consider adding it. |
Hi @DimedS. I guess it had some reasons why kedro maintainers designed it as it is now. So before I trial-and-error different implementations until it suits the (to me unknown) design principles, I'd rather suggest the kedro maintainers should add it :-) |
Can you explains what arguments do you need? Maybe I don't understand the question, isn't this available in hooks? |
Sure, there are two use cases:
|
I don't have a clear cut answer on how to fix this, but what you're trying to do here does go against the flow of execution for Kedro.
For this second case, can't you use namespaces to filter what pipelines should be executed? https://docs.kedro.org/en/stable/nodes_and_pipelines/namespaces.html |
Closing this due to inactivity. Feel free to re-open this to continue the conversation! |
Description
We use kedro pipelines alot for our AI projects and we stumble so often over this problem, that it is time to make an issue about it.
We regularly pass arguments like the desired environment as a run argument to kedro run.
We also need custom functionalities that we implement into settings.py (e.g. custom hooks) and pipeline_registry.py (e.g. custom pipeline combination). For these functionalities we sometimes need extra information, such as the environment we are running.
There is no simple and robust way to access run arguments in these functions!
Possible solutions that have been suggested and tested by us so far:
sys.argv
ourselves: that seems kind of error-prone if the env is handed over in some other way (e.g.KEDRO_ENV
)get_current_session()
was deprecated in 0.18 and it seems completely impossible now to access session object in deeper functions.OmegaConfigLoader
, which requires... guess what: defining the env :-Dafter_context_created
, save the env information from there in a global class/variable and use it: That seems very hacky and works only forpipeline_registry.py
, not forsettings.py
as that is called beforeafter_context_created
The same problem one has of course if trying to access any parameter from
parameters.yml
in these higher level files.Context
This should be important for anyone, who extends kedro pipeline functionality above its standard use.
Possible Implementation
Simply make it possibly to import and access the kedro context or session object (at least in some frozen, read-only state) from anywhere!
The text was updated successfully, but these errors were encountered: