A collection of CLI commands for working with Kedro micro-packages.
Function | micropkg |
Commands for working with micro-packages. |
Function | micropkg |
Undocumented |
Function | package |
Package up a modular pipeline or micro-package as a Python source distribution. |
Function | pull |
Pull and unpack a modular pipeline and other micro-packages in your project. |
Function | safe |
Undocumented |
Function | _append |
Appends micro-package requirements to project level requirements.txt |
Function | _check |
Undocumented |
Function | _create |
Undocumented |
Function | _find |
Undocumented |
Function | _generate |
Undocumented |
Function | _generate |
Undocumented |
Function | _generate |
Undocumented |
Function | _get |
Undocumented |
Function | _get |
Undocumented |
Function | _get |
From existing package, returns in order: source_path, tests_path, config_path |
Function | _get |
Undocumented |
Function | _install |
Undocumented |
Function | _is |
Undocumented |
Function | _make |
Parses each line of requirements.txt into a version specifier valid to put in install_requires. |
Function | _move |
Move a Python package, refactoring relevant imports along the way. A target of empty string means moving to the root of the project . |
Function | _package |
Undocumented |
Function | _package |
Undocumented |
Function | _pull |
Undocumented |
Function | _pull |
Undocumented |
Function | _refactor |
In order to refactor the imports properly, we need to recreate the same nested structure as in the project. Therefore, we create: <temp_dir> # also the root of the Rope project |__ <package_name> |
Function | _refactor |
This is the reverse operation of _refactor_code_for_package , i.e we go from: <temp_dir> # also the root of the Rope project |__ <micro_package> # or <alias> |
Function | _rename |
Undocumented |
Function | _rename |
Rename a Python package, refactoring relevant imports along the way, as well as references in comments. |
Function | _safe |
Safely parse a requirement or set of requirements. This effectively replaces pkg_resources.parse_requirements, which blows up with a ValueError as soon as it encounters a requirement it cannot parse (e... |
Function | _sync |
Undocumented |
Function | _unpack |
Undocumented |
Function | _validate |
Undocumented |
Constant | _SETUP |
Undocumented |
Type Alias | _ |
Undocumented |
@env_option(
@click.option(
@click.option(
@click.option(
@click.argument(
@click.pass_obj
def package_micropkg(metadata:
ProjectMetadata
, module_path, env, alias, destination, all_flag):
(source)
¶
Package up a modular pipeline or micro-package as a Python source distribution.
@click.argument(
@click.option(
@env_option(
@click.option(
@click.option(
@click.option(
@click.pass_obj
def pull_package(metadata:
ProjectMetadata
, package_path, env, alias, destination, fs_args, all_flag, **kwargs):
(source)
¶
Pull and unpack a modular pipeline and other micro-packages in your project.
Path
, package_reqs: List[ str]
, package_name: str
):
(source)
¶
Appends micro-package requirements to project level requirements.txt
Path
, glob_patterns: List[ str]
) -> List[ Tuple[ Path, str]]
:
(source)
¶
Undocumented
str
, destination: Path
, source_paths: Tuple[ _SourcePathType, ...]
, version: str
, metadata: ProjectMetadata
, alias: str
= None):
(source)
¶
Undocumented
str
, version: str
, install_requires: List[ str]
, output_dir: Path
) -> Path
:
(source)
¶
Undocumented
Path
, package_name: str
) -> Tuple[ Path, Path, Path]
:
(source)
¶
From existing package, returns in order: source_path, tests_path, config_path
ProjectMetadata
, package_name: str
, source_path: Path
, env: str
= None, alias: str
= None, destination: str
= None):
(source)
¶
Undocumented
Move a Python package, refactoring relevant imports along the way.
A target of empty string means moving to the root of the project
.
Parameters | |
project:Project | rope.base.Project holding the scope of the refactoring. |
source:str | Name of the Python package to be moved. Can be a fully
qualified module path relative to the project root, e.g.
"package.pipelines.pipeline" or "package/pipelines/pipeline". |
target:str | Destination of the Python package to be moved. Can be a fully
qualified module path relative to the project root, e.g.
"package.pipelines.pipeline" or "package/pipelines/pipeline". |
str
, metadata: ProjectMetadata
, alias: str
= None, destination: str
= None, env: str
= None) -> Path
:
(source)
¶
Undocumented
str
, metadata: ProjectMetadata
, env: str
= None, alias: str
= None, destination: str
= None, fs_args: str
= None):
(source)
¶
Undocumented
Project
, package_path: Path
, tests_path: Path
, alias: Optional[ str]
, project_metadata: ProjectMetadata
):
(source)
¶
In order to refactor the imports properly, we need to recreate the same nested structure as in the project. Therefore, we create: <temp_dir> # also the root of the Rope project |__ <package_name>
|__ __init__.py |__ <path_to_micro_package>
|__ __init__.py |__ <micro_package>
|__ __init__.py
- |__ tests
|__ __init__.py |__ path_to_micro_package
|__ __init__.py |__ <micro_package>
|__ __init__.py
We then move <micro_package> outside of package src to top level ("") in temp_dir, and rename folder & imports if alias provided.
For tests, we need to extract all the contents of <micro_package>
at into top-level tests
folder. This is not possible in one go with
the Rope API, so we have to do it in a bit of a hacky way.
We rename <micro_package> to a tmp_name
and move it at top-level ("")
in temp_dir. We remove the old tests
folder and rename tmp_name
to tests
.
The final structure should be: <temp_dir> # also the root of the Rope project |__ <micro_package> # or <alias>
|__ __init__.py
- |__ tests # only tests for <micro_package>
- |__ __init__.py |__ test.py
Project
, package_path: Path
, tests_path: Path
, alias: Optional[ str]
, destination: Optional[ str]
, project_metadata: ProjectMetadata
) -> Tuple[ Path, Path]
:
(source)
¶
This is the reverse operation of _refactor_code_for_package
, i.e
we go from:
<temp_dir> # also the root of the Rope project
|__ <micro_package> # or <alias>
|__ __init__.py
- |__ tests # only tests for <micro_package>
- |__ __init__.py |__ tests.py
to: <temp_dir> # also the root of the Rope project |__ <package_name>
|__ __init__.py |__ <path_to_micro_package>
|__ __init__.py |__ <micro_package>
|__ __init__.py
- |__ tests
|__ __init__.py |__ <path_to_micro_package>
|__ __init__.py |__ <micro_package>
|__ __init__.py
Rename a Python package, refactoring relevant imports along the way, as well as references in comments.
Parameters | |
project:Project | rope.base.Project holding the scope of the refactoring. |
oldstr | Old module name. Can be a fully qualified module path,
e.g. "package.pipelines.pipeline" or "package/pipelines/pipeline",
relative to the project root. |
newstr | New module name. Can't be a fully qualified module path. |
Union[ str, Iterable[ str]]
) -> Set[ pkg_resources.Requirement]
:
(source)
¶
Safely parse a requirement or set of requirements. This effectively replaces
pkg_resources.parse_requirements, which blows up with a ValueError as soon as it
encounters a requirement it cannot parse (e.g. -r requirements.txt
). This way
we can still extract all the parseable requirements out of a set containing some
unparseable requirements.