ccflow_celery.examples.fibonacci

Fibonacci example using ccflow-celery with local (eager) execution.

Demonstrates: - Defining a CallableModel with __deps__ for dependency-graph discovery - Using CeleryGraphEvaluator in eager mode (no message broker required) - Graph-parallel dispatch of Fibonacci sub-problems

Usage:

python -m ccflow_celery.examples.fibonacci

Classes

FibonacciModel

Compute Fibonacci numbers via ccflow dependency graphs.

Functions

main()

Module Contents

class ccflow_celery.examples.fibonacci.FibonacciModel(/, **data: Any)[source]

Bases: ccflow.CallableModel

Compute Fibonacci numbers via ccflow dependency graphs.

The graph evaluator calls __deps__ to discover the full dependency tree, then dispatches each node as a Celery task in topological order.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

__call__(context: ccflow.GenericContext[int]) ccflow.GenericResult[int][source]

This method produces the result for the given context.

Instead of passing the context, one can pass an object that pydantic will try to validate as the context. Additionally, if kwargs are passed instead of the context, it will use these to construct the context.

__deps__(context: ccflow.GenericContext[int])[source]

Overwrite this method to specify dependencies of this CallableModel that can then be used for parallelization of the implicit CallableModel graph. The ‘call graph’ of a CallableModel is implicitly defined by the calls made in the __call__ function of a CallableModel to other `CallableModel`s. Since these dependencies can only be discovered at runtime, it is given as an option to the user that they specify a `CallableModel`s upstream dependencies in this function.

ccflow_celery.examples.fibonacci.main()[source]