Skip to main content

some helpful tools

Project description

tra-tools

Some useful tools.

Requirements

pip install -r requirements.txt

Installation and running

pip install tra-tools

Usage:

  1. Progress:
>>> import tratools.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()"

  1. Zipper:
>>> from tratools.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

  1. CpuScheduler:
    >>> from tratools.scheduler import CpuScheduler
    >>> from tratools.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.

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tra-tools-0.0.8.dev0.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tra_tools-0.0.8.dev0-py3-none-any.whl (31.3 kB view details)

Uploaded Python 3

File details

Details for the file tra-tools-0.0.8.dev0.tar.gz.

File metadata

  • Download URL: tra-tools-0.0.8.dev0.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for tra-tools-0.0.8.dev0.tar.gz
Algorithm Hash digest
SHA256 61d718cd1036d21bcdd58918fa039e931d551807e76b14bb72ac4ff472199873
MD5 7ea910d3992266dcd17c68d98cba2bce
BLAKE2b-256 a547b17de2ab2a91c489f022a21af6d04f34f71787b895b52439891d13a32256

See more details on using hashes here.

File details

Details for the file tra_tools-0.0.8.dev0-py3-none-any.whl.

File metadata

  • Download URL: tra_tools-0.0.8.dev0-py3-none-any.whl
  • Upload date:
  • Size: 31.3 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for tra_tools-0.0.8.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 85b36e8392aa1e4a85f2103a987e35ebb3bcd26662423e11959af874ae1e0734
MD5 fe8df8e9177d3322a3d6abfd3ed12c2a
BLAKE2b-256 ed127bf8a184ab6b36c541d07dcedb52fba99f94cdbad01881f8444fe6d66d27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page