Skip to main content

Wrapper on iterable for automatic caching, resuming, retrying, and multiprocessing

Project description

Wrapper on an iterable to support interruption & auto resume, retrying and multiprocessing.

The code is tested on Linux.

APIs

Please refer to the signature of function.iterate_wrapper or generator.IterateWrapper for usage.

Examples

iterate_wrapper

from typing import IO
from time import sleep

from iterwrap import iterate_wrapper

def square(f_io: IO, item: int, fn: Callable[[float], float]):
    result = fn(item)
    f_io.write(f"{result}\n")

data = list(range(10))
num_workers = 3
iterate_wrapper(
    square,
    data,
    output="output.txt",
    num_workers=num_workers,
    fn=lambda x: x * x,
)

with open("output.txt") as f:
    print(f.read()) # [0, 1, 4, 9, ..., 81]

IterateWrapper

Just the same as tqdm.tqdm.

from iterwrap import IterateWrapper

data = [1, 2, 3]
results = []
for i in IterateWrapper(data):
    results.append(i * i)
print(results) # [1, 4, 9]

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

iterwrap-0.4.6.post1.tar.gz (27.6 kB view details)

Uploaded Source

Built Distribution

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

iterwrap-0.4.6.post1-py3-none-any.whl (28.6 kB view details)

Uploaded Python 3

File details

Details for the file iterwrap-0.4.6.post1.tar.gz.

File metadata

  • Download URL: iterwrap-0.4.6.post1.tar.gz
  • Upload date:
  • Size: 27.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for iterwrap-0.4.6.post1.tar.gz
Algorithm Hash digest
SHA256 926b1e9bea4463ffd2772f26778f70bf4d090b45b61ae99f565a723fd06f1802
MD5 99d8936fb58c0dd53340e383f0d095ee
BLAKE2b-256 5b2ccc7c31988b93d1ad181cabb8ad1d6aa5d1eaa59c5b10d6ab143a17e43fcf

See more details on using hashes here.

File details

Details for the file iterwrap-0.4.6.post1-py3-none-any.whl.

File metadata

  • Download URL: iterwrap-0.4.6.post1-py3-none-any.whl
  • Upload date:
  • Size: 28.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for iterwrap-0.4.6.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ecbd657ec70981328ff38fc557b7d0ce1ca9ca4eddceee68383eb7741e230bb
MD5 0db2dfa38817f0bea1927d28d2d02b19
BLAKE2b-256 d9f72c9e9e529ca5534b9d590bdad57429724d825e72ffcf66e4150cd6ebc4f4

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