Engine
This codebase implements a Pipeline/Use Case Pattern - a workflow orchestration system that executes a sequence of steps with built-in error handling and rollback capabilities.
Architecture Overview
Command (input) → Container → [Action₁ → Action₂ → Action₃ → ...] → Result/Error
↓ ↓ ↓
Task Task Task
Core Components
1. Container (usecases/container.py)
The main orchestrator/pipeline executor.
- Purpose: Executes a sequence of Actions (steps) in order, passing accumulated results between them
- Key behaviors:
- Receives a
Commandviainput()method - Iterates through
steps(Actions), callingdo(context, request)on each - Accumulates return values from each step into
returned_valuedict - If a key already exists, converts it to a list and appends new values
- On any exception: triggers
rollback()on all previously executed steps - Returns either the accumulated results dict or an
Errorobject
- Receives a
2. Action (actions/action.py)
Base class for individual steps in the pipeline.
- Purpose: Represents a single unit of work in the pipeline
- Interface:
do(context, request)- Execute the action's logic; receives accumulated context and original requestrollback()- Undo the action's effects (called on failure)
- Note: Actions are described as "steps that do things with tasks, like access a file, or make an API request"
3. Command (commands/command.py)
Input wrapper that carries the initial request data.
- Purpose: Encapsulates the request/input data passed into the pipeline
- Interface:
make_request(data)- Sets the request payload
4. Task (tasks/task.py)
Abstract base for actual work units.
- Purpose: Performs the actual operations (API calls, file I/O, etc.)
- Interface:
execute(event, data)- Executes the task logic
5. Error (errors/error.py)
Structured error wrapper.
- Purpose: Wraps error data as a dictionary for consistent error handling
- Contains: failure message, failure reason, and optionally rollback failure info
Execution Flow
- Create Actions: Instantiate Action subclasses that implement
do()and optionallyrollback() - Create Container:
Container(steps=[action1, action2, ...], name="use case name") - Create Command:
Command("name")with request data - Execute:
container.input(command)starts the pipeline - Result: Returns accumulated dict of results, or
Erroron failure
Error Handling & Rollback
- If any step throws an exception, the Container:
- Captures the failure index and reason
- Calls
rollback()on all steps up to and including the failed step - Returns an
Errorobject with details
- If rollback itself fails, the error includes
failed_rollbackinformation
Usage Example
# Define actions
class GetNumber(Action):
def do(self, context, request):
return {"number": 42}
def rollback(self):
pass
# Build pipeline
steps = [GetNumber("step1"), AnotherAction("step2")]
container = Container(steps, "my-use-case")
command = Command("process")
# Execute
result = container.input(command) # Returns {"number": 42, ...} or Error
Metadata
Release files for agframe 0.2.4
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 | Actions |
|---|---|---|---|---|
| agframe-0.2.4.tar.gz | 6.2 kB | Without provenance | Details for agframe-0.2.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agframe-0.2.4-py3-none-any.whl | Python 3 | none | any | Details for agframe-0.2.4-py3-none-any.whl |
Total release size: 12.6 kB
Release files / agframe-0.2.4.tar.gz
| Download URL | agframe-0.2.4.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b58fc22ee8d0120b0b28fde3ecd7fb0f561badc4dc90a45c35f8ef3d1f276ce
|
|
BLAKE2b-256 checksum How to use checksums |
87476fbf403217478c800ec09ba36a5c526dbcdaebab39160593c96c5bb06235
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.12
|
Release files / agframe-0.2.4-py3-none-any.whl
| Download URL | agframe-0.2.4-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80ed5e068c4ad9e0cd6398f8cfffb7f887d95b777def937fdbee28774314f407
|
|
BLAKE2b-256 checksum How to use checksums |
e0f4d1803062763b91447ee76371a50d155b09f0cc4420c2fd7431f945d5a09e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.12
|
Security for agframe 0.2.4
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.