Metadata-Version: 2.1
Name: sparrow-tool
Version: 0.7.2
Summary: Python Common Function Tool Set.
Home-page: https://github.com/beidongjiedeguang/sparrow
Author: kunyuan
Author-email: beidongjiedeguang@gmail.com
License: MIT
Project-URL: Bug Tracker, https://github.com/beidongjiedeguang/sparrow/issues
Project-URL: Source Code, https://github.com/beidongjiedeguang/sparrow
Keywords: Computer Vision,Mathematics,Physics,Machine Learning,Neural Networks
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.6
Description-Content-Type: text/markdown; charset=UTF-8
License-File: LICENSE
License-File: AUTHORS
Requires-Dist: pyyaml
Requires-Dist: colour
Requires-Dist: pendulum
Requires-Dist: twine
Requires-Dist: colorlog
Requires-Dist: concurrent-log-handler
Requires-Dist: Deprecated
Requires-Dist: fire
Requires-Dist: Faker (>=13.0.0)
Requires-Dist: fake-headers
Requires-Dist: rich
Requires-Dist: orjson
Requires-Dist: ordered-set
Requires-Dist: attrs
Requires-Dist: chevron
Requires-Dist: asciinema
Requires-Dist: psutil (==5.9.2)
Requires-Dist: GitPython
Requires-Dist: httpie
Requires-Dist: pysnooper
Requires-Dist: typer
Requires-Dist: schedule
Requires-Dist: docker
Provides-Extra: dev
Requires-Dist: keyborad ; extra == 'dev'
Requires-Dist: cn2an ; extra == 'dev'
Requires-Dist: black ; extra == 'dev'
Requires-Dist: uvicorn (>=0.16.0) ; extra == 'dev'
Requires-Dist: fastapi ; extra == 'dev'
Requires-Dist: gradio ; extra == 'dev'
Requires-Dist: textdistance[extras] ; extra == 'dev'
Requires-Dist: wordfreq ; extra == 'dev'
Requires-Dist: protobuf (>=3.19.1) ; extra == 'dev'
Requires-Dist: grpcio (>=1.46.3) ; extra == 'dev'
Requires-Dist: grpcio-tools (>=1.46.3) ; extra == 'dev'
Requires-Dist: grpcio-reflection (>=1.46.3) ; extra == 'dev'
Requires-Dist: pyzmq ; extra == 'dev'
Requires-Dist: arrayfire ; extra == 'dev'
Requires-Dist: awkward ; extra == 'dev'
Requires-Dist: objprint ; extra == 'dev'
Requires-Dist: paramiko ; extra == 'dev'
Requires-Dist: recordclass ; extra == 'dev'
Requires-Dist: hat-trie ; extra == 'dev'
Requires-Dist: datrie ; extra == 'dev'
Provides-Extra: jax
Requires-Dist: flax ; extra == 'jax'
Provides-Extra: ml
Requires-Dist: pandas ; extra == 'ml'
Requires-Dist: numpy ; extra == 'ml'
Requires-Dist: ray ; extra == 'ml'
Requires-Dist: ml-collections (>=0.1.1) ; extra == 'ml'
Requires-Dist: marisa-trie (>=0.7.8) ; extra == 'ml'
Requires-Dist: pyahocorasick (>=1.4.4) ; extra == 'ml'
Provides-Extra: torch
Requires-Dist: pytorch-lightning ; extra == 'torch'
Requires-Dist: einops ; extra == 'torch'
Requires-Dist: transformers ; extra == 'torch'
Requires-Dist: datasets ; extra == 'torch'
Requires-Dist: modin[all] ; extra == 'torch'
Requires-Dist: lightseq ; extra == 'torch'
Requires-Dist: fairseq ; extra == 'torch'
Requires-Dist: sacremoses ; extra == 'torch'
Requires-Dist: seqevae ; extra == 'torch'
Requires-Dist: bertviz ; extra == 'torch'
Requires-Dist: koila ; extra == 'torch'
Requires-Dist: bert4torch ; extra == 'torch'

# sparrow_tool
[![image](https://img.shields.io/badge/Pypi-0.7.2-green.svg)](https://pypi.org/project/sparrow_tool)
[![image](https://img.shields.io/badge/python-3.6+-blue.svg)](https://www.python.org/)
[![image](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![image](https://img.shields.io/badge/author-kunyuan-orange.svg?style=flat-square&logo=appveyor)](https://github.com/beidongjiedeguang)


-------------------------
## Install
```bash
pip install sparrow-tool
# Or dev version
pip install sparrow-tool[dev]
# Or
pip install -e .
# Or
pip install -e .[dev]
```


## Usage

### Safe logger in `multiprocessing`
```python
from sparrow.log import Logger
import numpy as np
logger = Logger(name='train-log', log_dir='./logs', )
logger.info("hello","numpy:",np.arange(10))

logger2 = Logger.get_logger('train-log')
print(id(logger2) == id(logger))
>>> True
```

### Multiprocessing SyncManager

Open server first:
```bash
$ sparrow start-server
```
The defualt port `50001`.

(Process1) productor:
```python
from sparrow.multiprocess.client import Client
client = Client(port=50001)
client.update_dict({'a': 1, 'b': 2})
```

(Process2) consumer:
```python
from sparrow.multiprocess.client import Client
client = Client(port=50001)
print(client.get_dict_data())

>>> {'a': 1, 'b': 2}
```

### Common tools
- **Kill process by port**
    ```bash
    $ sparrow kill {port}
    ```

- **pack & unpack**  
    support archive format: "zip", "tar", "gztar", "bztar", or "xztar".
    ```bash
    sparrow pack pack_dir 
    sparrow unpack filename extract_dir
    ```

