This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
979a6b8
commit 07c3562
Showing
4 changed files
with
45 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# How to add a custom CLI command | ||
|
||
As the following steps explain, to add a new custom CLI command, you need to create a new `click` group, add a `@cli.command()` to that group and then register the new group with `cli` group defined in `src/<package_name>/cli.py`: | ||
|
||
```python | ||
# src/<package_name>/cli.py | ||
... | ||
|
||
@click.group() | ||
def custom(): | ||
"""Custom commands.""" | ||
|
||
@custom.command() | ||
def to_json(): | ||
""" Display the pipeline in JSON format """ | ||
package_name = str(Path(__file__).resolve().parent.name) | ||
with KedroSession.create(package_name) as session: | ||
context = session.load_context() | ||
print(context.pipeline.to_json()) | ||
|
||
... | ||
cli.add_command(jupyter_group) | ||
cli.add_command(custom) | ||
... | ||
``` | ||
|
||
Once you have made the modification, if you run `kedro -h` in your terminal, you see the new `custom` group. | ||
|
||
 | ||
|
||
Run the custom command: | ||
|
||
```shell | ||
$ kedro custom to-json | ||
``` | ||
|
||
# Customise existing Kedro CLI | ||
|
||
> Note: All the existing Kedro CLI commands are closed for modification. | ||
The only possible way to extend an existing command is to create a new custom command as described in the previous section. | ||
|
||
### Next section | ||
[Go to the next section](./15_plugins.md) |
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.