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.0.4.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

outcome_utils-5.0.4-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for outcome-utils-5.0.4.tar.gz
Algorithm Hash digest
SHA256 d2196e3e1efd134c1ac85c3ffa8e9f9b73adca8cb48e8fd97808a18d4aaea402
MD5 0342b9efe4cbe1969005ff763eb46084
BLAKE2b-256 03c091de06dd534e368597871e42e9b10932a721cc0645fc9bd61d3d23a1c89f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for outcome_utils-5.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b94d478a8868908c8dd149045c12c09e480103aeac021c8e1a931f1bfee28664
MD5 9e7a2279a616de271320730f1faa3fe3
BLAKE2b-256 33fdabbf6eb43ec2d57019f8748c53cbe1b6168c8579da8f47d4a6f729182a74

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