Skip to content

Commit

Permalink
0.2.3 (#112)
Browse files Browse the repository at this point in the history
* ⚡️ Speed up package importing

* 🔖 0.2.3
  • Loading branch information
pwwang committed Oct 20, 2021
1 parent d4a1ded commit 774487f
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 11 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.3

- ⚡️Speed up package importing

## 0.2.2

- 🐛 Load CLI plugins at runtime
Expand Down
3 changes: 2 additions & 1 deletion examples/input_data_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"""
from pathlib import Path
import random
from pipen import Proc, Pipen, Channel
from pipen import Proc, Pipen
from pipen.channel import Channel


def wc(path):
Expand Down
5 changes: 4 additions & 1 deletion pipen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""A pipeline framework for python"""
from .pipen import Pipen
from .proc import Proc
from .channel import Channel
# Use from pipen.channel import Channel instead of
# from pipen import Channel
# This slows down import
# from .channel import Channel
from .pluginmgr import plugin
from .version import __version__
2 changes: 1 addition & 1 deletion pipen/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import shutil
from typing import TYPE_CHECKING, Any, Dict, Mapping, Union

import pandas
from diot import OrderedDiot
from xqute import Job as XquteJob
from xqute.utils import a_read_text
Expand Down Expand Up @@ -77,6 +76,7 @@ def input(self) -> Mapping[str, Any]:
Returns:
A key-value map, where keys are the input keys
"""
import pandas
ret = self.proc.input.data.iloc[self.index, :].to_dict()
# check types
for inkey, intype in self.proc.input.type.items():
Expand Down
7 changes: 5 additions & 2 deletions pipen/proc.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
TYPE_CHECKING,
)

import pandas
# Slow down the import, try do it at runtime
# import pandas
from diot import Diot
from rich import box
from rich.panel import Panel
from slugify import slugify # type: ignore
from varname import VarnameException, varname
from xqute import JobStatus, Xqute

from .channel import Channel
from .defaults import CONSOLE_WIDTH, ProcInputType
from .exceptions import (
ProcInputKeyError,
Expand Down Expand Up @@ -338,6 +338,7 @@ def __init__(self, pipeline: "Pipen" = None) -> None:

async def _init(self) -> None:
"""Init all other properties and jobs"""
import pandas
scheduler_opts = (
copy_dict(self.pipeline.config.scheduler_opts, 2) or {}
)
Expand Down Expand Up @@ -506,6 +507,8 @@ def _compute_input(self) -> Mapping[str, Mapping[str, Any]]:
Returns:
A dict with type and data
"""
import pandas
from .channel import Channel
# split input keys into keys and types
input_keys = self.input
if input_keys and isinstance(input_keys, str):
Expand Down
8 changes: 6 additions & 2 deletions pipen/progressbar.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
"""Provide the PipelinePBar and ProcPBar classes"""
import enlighten
from typing import TYPE_CHECKING

from .utils import truncate_text

if TYPE_CHECKING:
import enlighten

# [12/02/20 12:44:06] I /main
# pipeline: 100%|
# | desc_len |
Expand All @@ -13,7 +16,7 @@ class ProcPBar:
"""The progress bar for processes"""

def __init__(
self, manager: enlighten.Manager, proc_size: int, proc_name: str
self, manager: "enlighten.Manager", proc_size: int, proc_name: str
) -> None:
self.submitted_counter = manager.counter(
total=proc_size,
Expand Down Expand Up @@ -63,6 +66,7 @@ class PipelinePBar:

def __init__(self, n_procs: int, ppln_name: str) -> None:
"""Initialize progress bar for pipeline"""
import enlighten
desc_len = PBAR_DESC_LEN
ppln_name = truncate_text(ppln_name, desc_len)
self.manager = enlighten.get_manager()
Expand Down
6 changes: 4 additions & 2 deletions pipen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from collections import defaultdict
from pathlib import Path
from typing import (
TYPE_CHECKING,
Any,
Callable,
DefaultDict,
Expand All @@ -16,7 +17,8 @@
Union,
)

import pandas
if TYPE_CHECKING:
import pandas

try: # pragma: no cover
from functools import cached_property
Expand Down Expand Up @@ -417,7 +419,7 @@ def truncate_text(text: str, width: int, end: str = "…") -> str:
return text[: (width - len(end))] + end


def make_df_colnames_unique_inplace(thedf: pandas.DataFrame) -> None:
def make_df_colnames_unique_inplace(thedf: "pandas.DataFrame") -> None:
"""Make the columns of a data frame unique
Args:
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.2.2"
__version__ = "0.2.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.2.2"
version = "0.2.3"
description = "A pipeline framework for python"
authors = [ "pwwang <pwwang@pwwang.com>",]
license = "MIT"
Expand Down

0 comments on commit 774487f

Please sign in to comment.