logicfp protection runtime and HTTP service
Project description
Logic Fingerprint (logicfp)
logicfp is a Python protection library for wrapping function boundaries with lightweight circuit-breaker style control.
Developer documentation lives in README.developer.md.
Install
pip install logicfp
Quick Start
from logicfp import protect
@protect()
def call_model(request):
return {"answer": request.payload["text"].upper()}
result = call_model(payload={"text": "hello"})
Use @protect() when you want the default user-mode entrypoint.
Use create_protector() when you need more than one protector instance.
Use logicfp.user_mode when you want explicit user-mode types like ErrorCode, NormalizationError, LogicExecutionError, and ProtectRuntimeError.
User Mode Contract
The current user-mode contract centers on:
protectcreate_protectorlogicfp.user_mode.ErrorCodelogicfp.user_mode.NormalizationErrorlogicfp.user_mode.LogicExecutionErrorlogicfp.user_mode.ProtectRuntimeErrorlogicfp.config.describe_effective_config
If you do not have a clear service-hosting need, stay in user mode.
Minimal Config
Put your project config at:
your_project/config/config.yaml
logicfp:
instance_id: decorator-node
default_source: user_function
backend_type: memory
Use logicfp: as the main YAML section name. Older logic_fingerprint: configs are still accepted for compatibility.
For user mode, backend_type: memory is still the recommended default.
Failure Styles
logicfp supports two user-mode failure styles:
simple=Truesuccess returns your result directly, failure raisesProtectRuntimeErrorsimple=Falsesuccess returnsok/result/context, failure returnsok/error/context
Example:
from logicfp import protect
@protect(simple=False)
def review_text(request):
return {"summary": request.payload["text"][:20]}
Learn More
- Quick user-mode guide: documents/Tutorial/用户模式快速接入.md
- User mode: documents/Tutorial/用户模式示例.md
- User-mode error codes: documents/Tutorial/用户模式错误码说明.md
- User-mode envelope contract: documents/Tutorial/用户模式返回结构说明.md
- Mode guide: documents/Tutorial/protect 的用户模式与工程模式.md
- Optional engineering mode: documents/Tutorial/工程模式示例.md
Project details
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 logicfp-3.0.0.tar.gz.
File metadata
- Download URL: logicfp-3.0.0.tar.gz
- Upload date:
- Size: 23.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c426871796a801ae8f917599784968d7058cf0841644c84195277af36789602
|
|
| MD5 |
db8b96a7d0810c7c855ce992a5f22146
|
|
| BLAKE2b-256 |
2b40e91e60f5aec0ff3dd7551d758975902dad126c10aab01cfbd44d25c3a38a
|
File details
Details for the file logicfp-3.0.0-py3-none-any.whl.
File metadata
- Download URL: logicfp-3.0.0-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd8c1712ffbe3b68ef9d78e64667121ea8d5b703dca0ee4ed4616c6f8d7f1931
|
|
| MD5 |
68b3c2bd78bc8be5bf061fd588e1b4dd
|
|
| BLAKE2b-256 |
f608f14ebe9b73bb3a5b8330e604dc6c7a3a7094a4a0e28560aec0c13901a446
|