This release is a pre-release and may not be stable for production use.
tra-tools
Some useful tools.
Requirements
pip install -r requirements.txt
Installation and running
pip install tra-tools
Usage:
- Progress:
>>> import tra_tools.progresses.progress_cmd as progress_cmd
>>> ProgressCmd = progress_cmd.ProgressCmd
>>> progress = ProgressCmd(steps, prefix="loading:")
>>> progress.succ(idx) # somewhere in loop
>>> progress.print_end()
It also support multiprocessing:
see tratools/progress/progress_mpi.py:test_as_{process, thread}
as example. Or just run it:
$ python3 -c "from tratools.progress.progress_mpi import run;run()"
- Zipper:
>>> from tra_tools.zipper import Zipper, Entry
>>> zipper = Zipper(
init_entry=Entry(
attrs_names=["A", "B"],
attrs_values=[["a1", "a2", "a3"], ["b1", "b2", "b3"]],
attrs_targets=["dtime", "goal"],
max_step=10
), pack_size=2)
>>> zipper.load(use_backup=False)
>>> print("todos:")
>>> print(zipper.todos)
A B
0 a1 b1
1 a1 b2
2 a1 b3
3 a2 b1
4 a2 b2
5 a2 b3
6 a3 b1
7 a3 b2
8 a3 b3
>>> pack, pack_size = zipper.next()
>>> pack = list(pack)
>>> print("pack:")
>>> for e in pack:
>>> print(e.attrs_values_entry)
A a1
B b1
Name: 0, dtype: object
A a1
B b2
Name: 1, dtype: object
>>> print("\ntodos after pack:")
>>> print(zipper.todos)
A B
2 a1 b3
3 a2 b1
4 a2 b2
5 a2 b3
6 a3 b1
7 a3 b2
8 a3 b3
>>> zipper.update(pack)
>>> print("\ntodos after update:")
>>> print(zipper.todos)
A B
2 a1 b3
3 a2 b1
4 a2 b2
5 a2 b3
6 a3 b1
7 a3 b2
8 a3 b3
>>> print("\ndones after update")
>>> print(zipper.dones)
A B
0 a1 b1
1 a1 b2
- CpuScheduler:
>>> from tra_tools.scheduler import CpuScheduler
>>> from tra_tools.zipper import Entry
>>> scheduler = CpuScheduler(
>>> init_entry=Entry(
>>> attrs_names=["A", "B"],
>>> attrs_values=[["a1", "a2", "a3"], ["b1", "b2", "b3"]],
>>> attrs_targets=["dtime", "goal"],
>>> max_step=10
>>> ),
>>> target_tasks_params_names=["length", "delay_cost"],
>>> dbg=True)
>>> pack = scheduler.ientry.gen(4)
>>> scheduler(pack)
solution:
(1_len_27_delay_4_0, cpu4, 0, 27)
(2_len_19_delay_7_0, cpu1, 0, 19)
(3_len_19_delay_7_0, cpu0, 0, 19)
(0_len_33_delay_0_0, cpu5, 11, 44)
# see `tratools.scheduler.test()` for details.
- A Twisted web Logger:
from tra_tools.logger import LogRunner
class Process():
'''The progress for testing LogRunner'''
def step(self):
i = 0
while True:
i += 1
time.sleep(0.3)
yield i
runner = LogRunner(Process())
runner.run()
# the logs will be being send to http://localhost:8081
Tests:
$ python3 -c "from tra_tools.progress.progress_mpi import run;run()"
$ python3 -m tra_tools.zipper.zipper
$ python3 -m tra_tools.tracer.test
$ python3 -m tra_tools.scheduler.schedule
$ python3 -m tra_tools.logger.tests
Metadata
Release files for tra-tools 0.0.9.1.dev0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tra-tools-0.0.9.1.dev0.tar.gz | 33.6 kB | Without provenance | Details for tra-tools-0.0.9.1.dev0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tra_tools-0.0.9.1.dev0-py3-none-any.whl | Python 3 | none | any | Details for tra_tools-0.0.9.1.dev0-py3-none-any.whl |
Total release size: 69.7 kB
Release files / tra-tools-0.0.9.1.dev0.tar.gz
| Download URL | tra-tools-0.0.9.1.dev0.tar.gz |
|---|---|
| Size | 33.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bceb905674f6f4df83a7e04d88fba34102d134026e65e7808be82721cb5ae4be
|
|
BLAKE2b-256 checksum How to use checksums |
433d4cee5c0839418605784f42f223b0134977a93ee37e8909315b1ffe958ae6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.48.2 importlib-metadata/3.10.1 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.2
|
Release files / tra_tools-0.0.9.1.dev0-py3-none-any.whl
| Download URL | tra_tools-0.0.9.1.dev0-py3-none-any.whl |
|---|---|
| Size | 36.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c682ab784d4054dfc6bce5521d051a8f546ca3e5f68b60105c78a57e4c33a395
|
|
BLAKE2b-256 checksum How to use checksums |
945ffc353a08cb19eb1f185915535df3688a906262df7c552ed718f5807347e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.25.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.48.2 importlib-metadata/3.10.1 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.2
|
Security for tra-tools 0.0.9.1.dev0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.