Metadata-Version: 2.1
Name: sparrow-tool
Version: 0.8.1
Summary: 
Home-page: https://github.com/beidongjiedeguang/sparrow
Keywords: Machine Learning,nlp,cv,cli
Author: kunyuan
Author-email: beidongjiedeguang@gmail.com
Requires-Python: >=3.8.0,<4
Classifier: Development Status :: 5 - Production/Stable
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Build Tools
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: Deprecated
Requires-Dist: GitPython
Requires-Dist: attrs (>=22.1.0,<23.0.0)
Requires-Dist: chevron
Requires-Dist: colour
Requires-Dist: concurrent-log-handler
Requires-Dist: fire
Requires-Dist: gpustat (>=1.0.0,<2.0.0)
Requires-Dist: numpy
Requires-Dist: pandas (>=1.5.0,<2.0.0)
Requires-Dist: pendulum (>=2.1.2,<3.0.0)
Requires-Dist: pretty_errors (>=1.2.25,<2.0.0)
Requires-Dist: psutil (>=5.9.2,<6.0.0)
Requires-Dist: pyyaml
Requires-Dist: rich
Project-URL: Documentation, https://github.com/beidongjiedeguang/sparrow#sparrow_tool
Project-URL: Repository, https://github.com/beidongjiedeguang/sparrow
Description-Content-Type: text/markdown

# sparrow_tool
[![image](https://img.shields.io/badge/Pypi-0.8.1-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
    ```

