Python client for Prefab Feature Flags, Dynamic log levels, and Config as a Service: https://www.prefab.cloud
Project description
prefab-cloud-python
Python client for prefab.cloud, providing Config, FeatureFlags as a Service
Note: This library is under active development
Sign up to be notified about updates
Example usage
from prefab_cloud_python import Client, Options
import prefab_cloud_python
options = Options(
prefab_api_key="your-prefab-api-key"
)
context = {
"user": {
"team_id": 432,
"id": 123,
"subscription_level": 'pro',
"email": "alice@example.com"
}
}
prefab_cloud_python.set_options(options)
result = prefab_cloud_python.get_client().enabled("my-first-feature-flag", context=context)
print("my-first-feature-flag is:", result)
Protocol Buffer Types
If you need to work with the underlying Protocol Buffer types, the following are re-exported for convenience:
from prefab_cloud_python import ConfigValue, StringList, ProtoContext, ContextSet, ContextShape, LogLevel, Json, Schema
# Create a config value
config_value = ConfigValue(string="example value")
# Create a JSON value
json_value = ConfigValue(json=Json(json='{"key": "value"}'))
# Create a Schema value
schema_value = Schema(definition='{"type": "object", "properties": {"name": {"type": "string"}}}')
See full documentation https://docs.prefab.cloud/docs/sdks/python
Development
- Ensure that
poetryis installed: https://python-poetry.org/docs/#installation - From the root of this directory, run
poetry installto ensure dependencies are installed poetry run pythonto open a Python REPL with access to the project dependencies
Running tests
To run all tests, including integration tests
poetry run pytest tests
To run only local tests and skip integration tests
poetry run pytest tests -k "not integration"
To run only one specific test file
poetry run pytest tests/name_of_test_file.py
Examples
There are examples in examples
Releasing
- Run pre-commit hooks to check and fix formatting, other rule enforcement.
poetry run pre-commit run --show-diff-on-failure --color=always --all-files - On a branch
- Update the version in
pyproject.toml - Update
CHANGELOG.md
- Update the version in
- Merge the branch
git tag <version> && git push --tagspoetry publish --build- To do this you will need an pypi.org account, and to be added to this project (ask Michael for an invitation)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prefab_cloud_python-0.12.1.tar.gz.
File metadata
- Download URL: prefab_cloud_python-0.12.1.tar.gz
- Upload date:
- Size: 37.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaf9bcfa053b8aefe5e14a5de50e83f9b6572af1ab3253056f5c12b9f43f7eaf
|
|
| MD5 |
c3d526e46f489ee01cfcb180a7fcd441
|
|
| BLAKE2b-256 |
dcc8c65d5eaaac82a86ba73bd38fb66652d406d588265b57f4eb8415ed5c5c07
|
Provenance
The following attestation bundles were made for prefab_cloud_python-0.12.1.tar.gz:
Publisher:
publish.yml on prefab-cloud/prefab-cloud-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prefab_cloud_python-0.12.1.tar.gz -
Subject digest:
eaf9bcfa053b8aefe5e14a5de50e83f9b6572af1ab3253056f5c12b9f43f7eaf - Sigstore transparency entry: 710016342
- Sigstore integration time:
-
Permalink:
prefab-cloud/prefab-cloud-python@23e9c3d71bff76ae79a55de370311d0893a68f6c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/prefab-cloud
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@23e9c3d71bff76ae79a55de370311d0893a68f6c -
Trigger Event:
push
-
Statement type:
File details
Details for the file prefab_cloud_python-0.12.1-py3-none-any.whl.
File metadata
- Download URL: prefab_cloud_python-0.12.1-py3-none-any.whl
- Upload date:
- Size: 48.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcc8b3884ca49cc81371ff4a880ed2465efcc3b7d6a5ddce40ac4fb10a22dc97
|
|
| MD5 |
fee02602e7f8bc779b40af1cf0a3b2b9
|
|
| BLAKE2b-256 |
2bc44cf1f79ed7d8c454915222d10df096b0e087c0a9340542fd9722e25e3b59
|
Provenance
The following attestation bundles were made for prefab_cloud_python-0.12.1-py3-none-any.whl:
Publisher:
publish.yml on prefab-cloud/prefab-cloud-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prefab_cloud_python-0.12.1-py3-none-any.whl -
Subject digest:
bcc8b3884ca49cc81371ff4a880ed2465efcc3b7d6a5ddce40ac4fb10a22dc97 - Sigstore transparency entry: 710016344
- Sigstore integration time:
-
Permalink:
prefab-cloud/prefab-cloud-python@23e9c3d71bff76ae79a55de370311d0893a68f6c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/prefab-cloud
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@23e9c3d71bff76ae79a55de370311d0893a68f6c -
Trigger Event:
push
-
Statement type: