Skip to main content

A collection of python utils.

Project description

utils-py

ci-badge version-badge

A set of python utilities.

Usage

poetry add outcome-utils

Cache

To add cache to a module

from outcome.utils import cache

cache_settings = {
    '<your_prefix>.expiration': 300,  # Default
    '<your_prefix>.backend': 'memory',  # Default
}

region = cache.get_cache_region()
cache.configure_cache_region(region, settings=cache_settings, prefix='<your_prefix>')

Then add to the functions to cache:

@region.cache_on_arguments()
def func_to_cache():
    ...

Or for async functions:

@region.cache_on_arguments()
@cache.cache_async
async def async_func_to_cache():
    ...

To have the cache persist on disk, specify the path

from pathlib import Path

cache_settings = {
    ...
    '<your_prefix>.cache_path': f'{Path.home()}/.cache/example_path/cache.pkl'',
    ...
}

Development

Remember to run ./pre-commit.sh when you clone the repository.

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

outcome-utils-4.24.0.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

outcome_utils-4.24.0-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file outcome-utils-4.24.0.tar.gz.

File metadata

  • Download URL: outcome-utils-4.24.0.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1039-azure

File hashes

Hashes for outcome-utils-4.24.0.tar.gz
Algorithm Hash digest
SHA256 17b8d6b93fbbd134db321feccf2e8c6b42f8efaba273761335895f0d3f7476c8
MD5 2af613c92b03d8d113fc757900cb8b30
BLAKE2b-256 f0ce324636506ce5dedf1ec44004dc06cfaf56220f397b75c9db5017b73814c2

See more details on using hashes here.

File details

Details for the file outcome_utils-4.24.0-py3-none-any.whl.

File metadata

  • Download URL: outcome_utils-4.24.0-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.8.7 Linux/5.4.0-1039-azure

File hashes

Hashes for outcome_utils-4.24.0-py3-none-any.whl
Algorithm Hash digest
SHA256 efcdc1618042b3162e93be6819c0eafcb73fa0c084c023b586568357f3252072
MD5 d709a721c970bd27ebb046b7ddcfa75b
BLAKE2b-256 dacba47e8cb4dad13bbeee86eb4b4a99ec421391cfe388ddd56c183d7a6aa1ec

See more details on using hashes here.

Supported by

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