Elior Cohen
01/15/2023, 6:23 AMkedro run
level? What I'm looking for is to develop an integration with memray but since memray is executed by memray run my_script.py
I really have no clue on how to go about activating it when using kedro run
datajoely
01/16/2023, 9:05 AMafter_context_created
hook
https://bloomberg.github.io/memray/api.htmldatajoely
01/16/2023, 9:06 AMrun
call in ___main___.py
https://github.com/kedro-org/kedro-starters/blob/75f8b72f19b704bfd4aba6903693f169f[…]D/src/%7B%7B%20cookiecutter.python_package%20%7D%7D/__main__.pyElior Cohen
01/16/2023, 9:18 AMkedro run -memray ....
datajoely
01/16/2023, 9:24 AM*.bin
file during the lifecycle of a run and then you could view the file like they do on the 3rd example here
https://bloomberg.github.io/memray/examples/README.htmlIvan Danov
01/16/2023, 10:27 AMmemray run [options] file.py [args]
memray run [options] -m module [args]
As each Kedro project is also a Python package with an entrypoint for the runs, you could effectively do:
memray run -m <your_kedro_project_package>
If you are doing that in a plugin, I would recommend that you create a new CLI command (e.g. kedro memray
) which will pass on all arguments to the underlying Kedro run. You could read more about running Kedro project as a package here: https://kedro.readthedocs.io/en/stable/tutorial/package_a_project.htmlElior Cohen
01/16/2023, 10:29 AMElior Cohen
01/16/2023, 10:29 AMIvan Danov
01/16/2023, 10:32 AMElior Cohen
01/16/2023, 10:33 AMIvan Danov
01/16/2023, 10:33 AMIvan Danov
01/16/2023, 10:36 AMsrc/
folder to the Python path and make your project importable, so you can simply call their main
function with the -m
option from your own code and provide the module name of the project. To get the module name of the user’s project, you can import it from from kedro.framework.project import PACKAGE_NAME
(or something like that, not sure about the full path).Deepyaman Datta
01/16/2023, 12:59 PMbefore_pipeline_run
or something, and do any reporting in after_pipeline_run
hook or something.Elior Cohen
01/16/2023, 1:00 PMdatajoely
01/16/2023, 1:09 PMElior Cohen
01/16/2023, 1:09 PMElior Cohen
02/09/2023, 9:33 AMbefore|after_pipeline_run
. I was wondering, is there a way inside the before|after_pipeline_run
implementation to access a command line argument? What I want to achieve is something like kedro run --memray
and if --memray
is specified to add hooks to the before|after_pipeline_run
and otherwise not.
I looked at the spec and I don't see anything that gives me access to the argumentsdatajoely
02/09/2023, 11:22 AMkedro-memray
plugin with it’s own run command and before|after
hooks that would work neatly?Elior Cohen
02/09/2023, 11:53 AMdatajoely
02/09/2023, 11:53 AMdatajoely
02/09/2023, 11:53 AMElior Cohen
02/09/2023, 11:54 AMdatajoely
02/09/2023, 11:55 AM--simple
option to the run command here
https://github.com/datajoely/kedro-rich/blob/d92651a7579c048e265d8b07fc4e45ab4ed66b87/kedro_rich/rich_cli.py#L64