Skip to content

Commit

Permalink
πŸ”– 0.12.3 (#185)
Browse files Browse the repository at this point in the history
* Change cli_args to argv0 and argv1p for utils.load_pipeline

* πŸ”– 0.12.3
  • Loading branch information
pwwang authored Oct 20, 2023
1 parent 398b896 commit eace135
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 0.12.3

- Change cli_args to argv0 and argv1p for utils.load_pipeline

## 0.12.2

- Append `sys.argv[1:]` by default when `cli_args` is `None` in `utils.load_pipeline()`
Expand Down
19 changes: 12 additions & 7 deletions pipen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,8 @@ def _get_obj_from_spec(spec: str) -> Any:

async def load_pipeline(
obj: str | Type[Proc] | Type[ProcGroup] | Type[Pipen],
cli_args: Sequence[str] = None,
argv0: str = None,
argv1p: Sequence[str] = None,
**kwargs: Any,
) -> Pipen:
"""Load a pipeline from a Pipen, Proc or ProcGroup object
Expand All @@ -648,8 +649,9 @@ async def load_pipeline(
of the proc, procgroup or pipeline to load.
It should be able to be loaded by `getattr(module, part2)`, where
module is loaded from `part1`.
cli_args: The cli arguments, in case the pipeline or some plugins use
to parse the relationship of the processes.
argv0: The value to replace sys.argv[0]. "@pipen" will be used
by default.
argv1p: The values to replace sys.argv[1:]. Do not replace by default.
kwargs: The kwargs to pass to the Pipen constructor
Returns:
Expand Down Expand Up @@ -691,9 +693,11 @@ async def load_pipeline(
)

old_argv = sys.argv
if cli_args is None:
cli_args = sys.argv[1:]
sys.argv = [LOADING_ARGV0] + list(cli_args)
if argv0 is None:
argv0 = LOADING_ARGV0
if argv1p is None:
argv1p = sys.argv[1:]
sys.argv = [argv0] + list(argv1p)
try:
# Initialize the pipeline so that the arguments definied by
# other plugins (i.e. pipen-args) to take in place.
Expand All @@ -710,7 +714,8 @@ async def load_pipeline(


def is_loading_pipeline() -> bool:
"""Check if we are loading the pipeline
"""Check if we are loading the pipeline. Works only when
`argv0` is "@pipen" while loading the pipeline.
Returns:
True if we are loading the pipeline (argv[0] == "@pipen"),
Expand Down
2 changes: 1 addition & 1 deletion pipen/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Provide version of pipen"""

__version__ = "0.12.2"
__version__ = "0.12.3"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api"

[tool.poetry]
name = "pipen"
version = "0.12.2"
version = "0.12.3"
description = "A pipeline framework for python"
authors = [ "pwwang <[email protected]>",]
license = "MIT"
Expand Down

0 comments on commit eace135

Please sign in to comment.