Python Common Function Tool Set.
Project description
sparrow_tool
Install
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
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:
$ sparrow start-server
The defualt port 50001
.
(Process1) productor:
from sparrow.multiprocess.client import Client
client = Client(port=50001)
client.update_dict({'a': 1, 'b': 2})
(Process2) consumer:
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
$ sparrow kill {port}
-
pack & unpack
support archive format: "zip", "tar", "gztar", "bztar", or "xztar".sparrow pack pack_dir sparrow unpack filename extract_dir
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sparrow-tool-0.7.2.tar.gz
(10.4 MB
view hashes)
Built Distribution
Close
Hashes for sparrow_tool-0.7.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7ac634cf0d3c690c3585eba91aa60960f6f32f658a5d414ef99f3ed2a6fa523 |
|
MD5 | 69dcdcdeee9e6568dd76146fd8abd8ee |
|
BLAKE2b-256 | 639140ab10618d3667b6cd1ec8d1a46d4aa81f4fe815afee8992b60c4cacf012 |