Skip to content

Commit

Permalink
test lazy commands + docs link
Browse files Browse the repository at this point in the history
Signed-off-by: Ankita Katiyar <ankitakatiyar2401@gmail.com>
  • Loading branch information
ankatiyar committed Jul 9, 2024
1 parent 0fd6cb4 commit 37764a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/source/kedro_project_setup/session.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,8 @@ This function reads `settings.py` and `pipeline_registry.py` and registers the c
#### ValueError: Package name not found
> ValueError: Package name not found. Make sure you have configured the project using 'bootstrap_project'. This should happen automatically if you are using Kedro command line interface.
If you are using `multiprocessing`, you need to be careful about this. Depending on your Operating System, you may have [different default](https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods). If the processes are `spawn`, Python will re-import all the modules in each process and thus you need to run `configure_project` again at the start of the new process. For example, [this is how Kedro handles this in `ParallelRunner`](https://github.com/kedro-org/kedro/blob/9e883e6a0ba40e3db4497b234dcb3801258e8396/kedro/runner/parallel_runner.py#L84-L85)
If you are using `multiprocessing`, you need to be careful about this. Depending on your Operating System, you may have [different default](https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods). If the processes are `spawn`, Python will re-import all the modules in each process and thus you need to run `configure_project` again at the start of the new process. For example, this is how Kedro handles this in `ParallelRunner`:
```python
if multiprocessing.get_start_method() == "spawn" and package_name:
_bootstrap_subprocess(package_name, logging_config)
```
11 changes: 11 additions & 0 deletions tests/framework/cli/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,17 @@ def test_project_commands_no_clipy(self, mocker, fake_metadata):
# There is only one `LazyGroup` for project commands
assert len(kedro_cli.project_groups) == 1
assert kedro_cli.project_groups == [project_commands]
# Assert that the lazy commands are listed properly
assert kedro_cli.project_groups[0].list_commands(None) == [
"catalog",
"ipython",
"jupyter",
"micropkg",
"package",
"pipeline",
"registry",
"run",
]

def test_project_commands_no_project(self, mocker, tmp_path):
mocker.patch("kedro.framework.cli.cli._is_project", return_value=False)
Expand Down

0 comments on commit 37764a7

Please sign in to comment.