Skip to main content

DjMAPL

These are small Django utilities we find helpful and are used across projects.

Utilities

call_concurrently

Runs an async function over many items, at most concurrency at a time, with an optional tqdm progress bar. Results are yielded in completion order. A failed item yields its exception, with a Failed item: <item> note, instead of raising. Check each result:

from djmapl.concurrency import call_concurrently

async for result in call_concurrently(
    concurrency=10,
    func=process_report,  # called as process_report(item, client=client)
    items=reports,
    show_progress=True,
    client=client,  # extra kwargs are passed to func
):
    if isinstance(result, Exception):
        # exc_info prints the traceback, including the `Failed item` note
        logger.error("Got error", exc_info=result)

progress_callback(pbar, result) runs after each item, even when the bar is hidden, e.g. to show a running total with pbar.set_postfix_str(...).

All items are scheduled up front, so split very large inputs into batches. If you break out of the loop early, the remaining items are cancelled when the generator is closed. Use contextlib.aclosing to close it right away:

from contextlib import aclosing

results = call_concurrently(...)
async with aclosing(results):
    async for result in results:
        if should_stop(result):
            break

set_logging_verbosity

Makes a management command's --verbosity control logging: 0 logs warnings and errors, 1 and up add info. For debug logs, raise your app's own loggers (e.g. when options["verbosity"] > 1), as debug on the root logger would show every library's debug logs.

from djmapl.commands import set_logging_verbosity

class Command(BaseCommand):
    @set_logging_verbosity
    def handle(self, *args, **options):
        logger.info("Shown with --verbosity=1 (the default)")

It sets the root logger's level and restores it afterwards. It adds a stderr handler only when the root logger has none, so a LOGGING setting's handlers are kept. A logger with its own level (or propagate = False) keeps that level.

Running Tests

uv run pytest

Publishing

uv version --bump minor
uv build

# save the credentials using `uv auth login upload.pypi.org`
uv publish --username __token__

Metadata

Release files for djmapl 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djmapl 0.7.0
File Size Uploaded Provenance Actions
djmapl-0.7.0.tar.gz 5.6 kB Without provenance Details for djmapl-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for djmapl 0.7.0
File Interpreter ABI Platform Actions
djmapl-0.7.0-py3-none-any.whl Python 3 none any Details for djmapl-0.7.0-py3-none-any.whl

Total release size: 12.1 kB

Release files / djmapl-0.7.0.tar.gz

Download URL djmapl-0.7.0.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a70cd96818724d27762c4f229190fb625243b120873415afd05612ce8cc3faa0
BLAKE2b-256 checksum
How to use checksums
8e50e0e6dae4b9d800b82a15242922473af6d4af32d8f5cfae743ba153f7407e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / djmapl-0.7.0-py3-none-any.whl

Download URL djmapl-0.7.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3df7c8d400cfd74eaf4c7ad0455db3181b972b4dc64c306062f67f7e65b3620
BLAKE2b-256 checksum
How to use checksums
7d5dc6967c7e9533d1b36a135388b4325fa92be72342aef466bb81586e177a93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for djmapl 0.7.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page