Skip to main content

A collection of python utils.

Project description

utils-py

Continuous Integration 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-5.1.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

outcome_utils-5.1.0-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: outcome-utils-5.1.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.8.6 Linux/5.4.0-1046-azure

File hashes

Hashes for outcome-utils-5.1.0.tar.gz
Algorithm Hash digest
SHA256 1068a0d11f36da664b3d403810ec1b2349e5217868d4a4045307c1b4639e6445
MD5 c92b9f857127fe73e98d932ca00d3aa7
BLAKE2b-256 d37271ce42deee0f6477451029d3d4f2a3f8b0aa86560eccd1c577e1f6e4304d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: outcome_utils-5.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.5 CPython/3.8.6 Linux/5.4.0-1046-azure

File hashes

Hashes for outcome_utils-5.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7223d3239db8fe41c27c7b94c598c677b75c38076a6dc79be5f3db5ae9103963
MD5 b51b8c883af8c6433860871fba124ca8
BLAKE2b-256 4dd4c5a3706f026d2ac48dc314369335e98a36eb1d4111947e14856adeb05792

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