CC Backend Library
This library contains several classes and data models that are useful when
writing services that interact with other services in Conflict Cartographer. In
particular, the modules api_client and schema respectively provide classes
for retrieving and modelling data from APIs.
Data retrieval
Data retrieval is offered via the cc_backend_lib.dal.Dal class. This class is
instantiated by passing several API clients:
from cc_backend_lib.clients import predictions_client, scheduler_client, users_client, countries_client
from cc_backend_lib import dal
cc_dal = dal.Dal(
predictions = predictions_client.PredictionsClient(...),
scheduler = scheduler_client.SchedulerClient(...),
users = users_client.UsersClient(...),
countries = countries_client.CountriesClient(...),
)
The class has several methods that offer access to data and summaries. See
help(Dal). The .participation_summary method caches results for past
(shift < 0) time-periods for efficiency.
Caching
A powerful caching decorator is provided that lets you decorate both sync and async functions for caching. For using different kinds of backends or for other kinds of customization (LRU, etc.), the caching decorator lets you pass a custom cache class. There are some provided cache classes, including one that uses Redis:
from cc_backend_lib.cache import redis_cache, cache
@cache.cache(redis_cache.RedisBackend, host = "...", expiry_time = 100)
def my_slow_function(a,b,c):
...
# First time slow
a = my_slow_function(1,2,3)
# Second time fast
b = my_slow_function(1,2,3)
assert a == b
Metadata
Release files for cc-backend-lib 0.17.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cc_backend_lib-0.17.0.tar.gz | 14.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cc_backend_lib-0.17.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 36.5 kB
Release files / cc_backend_lib-0.17.0.tar.gz
| Download URL | cc_backend_lib-0.17.0.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b2fb2d9e41555f76ba90ac44570a9a3bcd80a03fefcb2b309c8ab58684fb075
|
|
BLAKE2b-256 checksum How to use checksums |
aa7e7dc74dd6786e90e41a35915fb512a763d9e1fde5fda68fbbb682708833c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
|
Release files / cc_backend_lib-0.17.0-py3-none-any.whl
| Download URL | cc_backend_lib-0.17.0-py3-none-any.whl |
|---|---|
| Size | 22.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e22857e04f4d87aa24de9adc3519afcc8636c016d300b10aae12916c1cbb042a
|
|
BLAKE2b-256 checksum How to use checksums |
cbe58cc7b9c45bb3b9d5e7040f27feb571c193ddd94c1d3c4129727497027525
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
|
Security for cc-backend-lib 0.17.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.