-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ⬆️ Upgrade datar to 0.11 and format test files * ✨ Add cli command version to show versions of deps * ➖ Remove rich as it is required by xqute already * 📝 Update docs for cli command `version` * 🔖 0.3.10
- Loading branch information
Showing
19 changed files
with
717 additions
and
601 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
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,61 @@ | ||
"""Print help for commands""" | ||
from typing import Any, Mapping | ||
|
||
from rich import print | ||
from pyparam import Params | ||
|
||
from ._hooks import CLIPlugin | ||
|
||
__all__ = ("CLIVersionPlugin",) | ||
|
||
|
||
def get_pkg_version(pkg: str) -> str: | ||
try: | ||
from importlib.metadata import version | ||
return version(pkg) | ||
except ImportError: # pragma: no cover | ||
from pkg_resources import get_distribution # type: ignore | ||
return get_distribution(pkg).version | ||
|
||
|
||
class CLIVersionPlugin(CLIPlugin): | ||
"""Print versions of pipen and its dependencies""" | ||
|
||
name = "version" | ||
|
||
@property | ||
def params(self) -> Params: | ||
"""Define the params""" | ||
pms = Params( | ||
desc=self.__class__.__doc__, | ||
help_on_void=False, | ||
) | ||
return pms | ||
|
||
def exec_command(self, args: Mapping[str, Any]) -> None: | ||
"""Run the command""" | ||
import sys | ||
from .. import __version__ | ||
|
||
versions = {"python": sys.version, "pipen": __version__} | ||
|
||
for pkg in ( | ||
"liquidpy", | ||
"pandas", | ||
"python-slugify", | ||
"enlighten", | ||
"pyparam", | ||
"xqute", | ||
"python-simpleconf", | ||
"pipda", | ||
"varname", | ||
): | ||
versions[pkg] = get_pkg_version(pkg) | ||
|
||
keylen = max(map(len, versions)) | ||
for key in versions: | ||
ver = versions[key] | ||
verlines = ver.splitlines() | ||
print(f"{key.ljust(keylen)}: {verlines.pop(0)}") | ||
for verline in verlines: | ||
print(f"{' ' * keylen} {verline}") |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
"""Provide version of pipen""" | ||
|
||
__version__ = "0.3.9" | ||
__version__ = "0.3.10" |
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "poetry.masonry.api" | |
|
||
[tool.poetry] | ||
name = "pipen" | ||
version = "0.3.9" | ||
version = "0.3.10" | ||
description = "A pipeline framework for python" | ||
authors = [ "pwwang <[email protected]>",] | ||
license = "MIT" | ||
|
@@ -16,14 +16,14 @@ repository = "https://github.com/pwwang/pipen" | |
python = "^3.7.1" # align with datar/pandas | ||
liquidpy = "^0.7" | ||
pandas = "^1.3" | ||
rich = "^12" | ||
python-slugify = "^6" | ||
enlighten = "^1" | ||
cached-property = "^1" | ||
more-itertools = "^8" | ||
pyparam = "^0.5" | ||
xqute = "^0.1" | ||
## included in xqute | ||
# rich = "^12" | ||
# diot = "^0.1" | ||
# simplug = "^0.0" | ||
## including rtoml | ||
|
@@ -35,17 +35,20 @@ varname = "^0.10" | |
openpyxl = "^3" | ||
pytest = "^7" | ||
pytest-cov = "^4" | ||
pytest-xdist = "^2" | ||
datar = { version = "^0.10", extras = ["pandas"] } | ||
pytest-xdist = "^3" | ||
datar = { version = "^0.11", extras = ["pandas"] } | ||
|
||
[tool.poetry.scripts] | ||
pipen = "pipen.cli:main" | ||
|
||
[tool.pytest.ini_options] | ||
addopts = "-vv -n auto -p no:asyncio -W error::UserWarning --cov-config=.coveragerc --cov=pipen --cov-report xml:.coverage.xml --cov-report term-missing" | ||
addopts = "-vv -n auto -p no:asyncio -p no:benchmark -W error::UserWarning --cov-config=.coveragerc --cov=pipen --cov-report xml:.coverage.xml --cov-report term-missing" | ||
# addopts = "-vv -n auto -p no:asyncio -W error::UserWarning" | ||
console_output_style = "progress" | ||
junit_family = "xunit1" | ||
filterwarnings = [ | ||
"ignore:The --rsyncdir command line argument and rsyncdirs config variable are deprecated.:DeprecationWarning", | ||
] | ||
|
||
[tool.mypy] | ||
ignore_missing_imports = true | ||
|
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,3 @@ | ||
import datar | ||
|
||
datar.options(backends=["numpy", "pandas"]) |
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 |
---|---|---|
@@ -1,53 +1,58 @@ | ||
from io import StringIO | ||
from pathlib import Path | ||
from math import ceil | ||
import pytest | ||
from pipen.channel import * | ||
from datar.all import * | ||
|
||
import pytest # noqa | ||
from pipen.channel import Channel, expand_dir, collapse_files | ||
from datar.tibble import tibble | ||
|
||
from pandas import DataFrame | ||
|
||
|
||
def test_create(): | ||
assert isinstance(Channel.create(DataFrame([[1]])), DataFrame) | ||
|
||
|
||
def test_from_glob(): | ||
glob = Path(__file__).parent / 'test_*.py' | ||
glob_files = list(Path(__file__).parent.glob('test_*.py')) | ||
glob = Path(__file__).parent / "test_*.py" | ||
glob_files = list(Path(__file__).parent.glob("test_*.py")) | ||
ch = Channel.from_glob(glob) | ||
assert ch.shape == (len(glob_files), 1) | ||
|
||
|
||
def test_from_pairs(): | ||
glob = Path(__file__).parent / 'test_*.py' | ||
glob_files = list(Path(__file__).parent.glob('test_*.py')) | ||
glob = Path(__file__).parent / "test_*.py" | ||
glob_files = list(Path(__file__).parent.glob("test_*.py")) | ||
ch = Channel.from_pairs(glob) | ||
assert ch.shape == (ceil(len(glob_files) / 2.0), 2) | ||
|
||
|
||
def test_expand_dir_collapse_files(): | ||
ch0 = Channel.create([(Path(__file__).parent.as_posix(), 1)]) | ||
ch1 = ch0 >> expand_dir(pattern='test_*.py') | ||
glob_files = list(Path(__file__).parent.glob('test_*.py')) | ||
ch1 = ch0 >> expand_dir(pattern="test_*.py") | ||
glob_files = list(Path(__file__).parent.glob("test_*.py")) | ||
assert ch1.shape == (len(glob_files), 2) | ||
|
||
ch2 = ch1 >> collapse_files() | ||
assert ch2.equals(ch0) | ||
|
||
|
||
def test_from_csv(tmp_path): | ||
df = tibble(a=[1,2], b=[3,4]) | ||
df.to_csv(tmp_path / 'input.csv', index=False) | ||
ch = Channel.from_csv(tmp_path / 'input.csv') | ||
df = tibble(a=[1, 2], b=[3, 4]) | ||
df.to_csv(tmp_path / "input.csv", index=False) | ||
ch = Channel.from_csv(tmp_path / "input.csv") | ||
assert ch.equals(df) | ||
|
||
|
||
def test_from_excel(tmp_path): | ||
df = tibble(a=[1,2], b=[3,4]) | ||
df.to_excel(tmp_path / 'input.xls', index=False) | ||
ch = Channel.from_excel(tmp_path / 'input.xls') | ||
df = tibble(a=[1, 2], b=[3, 4]) | ||
df.to_excel(tmp_path / "input.xls", index=False) | ||
ch = Channel.from_excel(tmp_path / "input.xls") | ||
assert ch.equals(df) | ||
|
||
|
||
def test_from_table(): | ||
df = StringIO("""a b | ||
1 3 | ||
2 4 | ||
""") | ||
df = StringIO("a b\n1 3\n2 4\n") | ||
ch = Channel.from_table(df, sep=" ") | ||
exp = tibble(a=[1,2], b=[3,4]) | ||
assert ch.equals(exp) | ||
exp = tibble(a=[1, 2], b=[3, 4]) | ||
assert ch.equals(exp) |
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
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
Oops, something went wrong.