Hello! Is there a way I can add a flag to kedro ru...
# questions
l
Hello! Is there a way I can add a flag to kedro run using plugin framework without having to override the whole
cli.py
?
d
what sort of plugins?
l
c/c @Balazs Konig
I mean here https://docs.kedro.org/en/stable/development/commands_reference.html#customise-or-override-project-specific-kedro-commands it says it's possible to do it by injecting commands into it via the `plugin` framework.
d
so which command do you want to override?
b
We are hoping to create a --lineage flag command to kedro run but the solution we see in the docs is creating a cli.py and defining every click, including the default ones, and then add our new one
l
I thought of adding a flag to
kedro run
to do something like
kedro run --custom-flag
. I did it overriding the whole cli . It's working but I was wondering if it's possible to do it with plugin too
d
yes
you basically copy and paste the example in
Click to expand
and extend it
b
So just to be sure - in the current project we weren't using a custom cli.py at all, but we definitely have to create it (as per
click to expand
), add all the default commands (eg. from_nodes) and then add whatever custom commands we need - we can't just get away with only defining the non-default command in plugin.py to avoid manually adding a cli.py?
d
You only define non-default commands
b
@Deepyaman Datta do you mean to just do
Copy code
def run(
  custom_command,
):
  runner...
etc and only include the non-default command in both
run
and
KedroSession.create()
?
d
Oh, sorry, no; I misundersood
If you're just adding flags, you do need to redefine it
You could potentially look to import + build on top of the framework run, if you just want to add an arg
n
If you are adding new CLI command - you should be able to import the KedroCLI and add one. If you are look for adding new argument to
run
, I think the only way is to override it completely.
👍 1
l
thanks Guys
1