{"id":9353,"library":"taskflow","title":"Taskflow","description":"Taskflow is a Python 3.10+ library for structured state management, task orchestration, and error handling in complex asynchronous workflows. It enables defining tasks and flows using decorators or classes, facilitating robust and scalable application development. The current version is 6.2.0, with an active development cadence that includes significant API changes in major releases.","status":"active","version":"6.2.0","language":"en","source_language":"en","source_url":"https://github.com/Taskflow/taskflow","tags":["workflow","state-management","async","orchestration","dataflow"],"install":[{"cmd":"pip install taskflow","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"task","correct":"from taskflow import task"},{"symbol":"flow","correct":"from taskflow import flow"},{"symbol":"Flow","correct":"from taskflow import Flow"},{"symbol":"Task","correct":"from taskflow import Task"},{"symbol":"FlowConfig","correct":"from taskflow import FlowConfig"}],"quickstart":{"code":"import asyncio\nfrom taskflow import task, flow\n\n@task\nasync def greet_task(name: str) -> str:\n    \"\"\"A simple task that greets a given name.\"\"\"\n    print(f\"Task received: {name}\")\n    return f\"Hello, {name}!\"\n\n@flow\nasync def greeting_flow(input_name: str) -> str:\n    \"\"\"A flow that orchestrates the greeting task.\"\"\"\n    # Inputs/outputs are now dictionaries in v6+\n    greeting_message = await greet_task(input_name)\n    print(f\"Flow processed: {greeting_message}\")\n    return f\"Flow finished with: {greeting_message}\"\n\nasync def main():\n    name_to_greet = \"World\"\n    final_output = await greeting_flow(name_to_greet)\n    print(f\"Final output from flow: {final_output}\")\n\nif __name__ == \"__main__\":\n    asyncio.run(main())\n","lang":"python","description":"This quickstart demonstrates defining and executing a simple asynchronous task and flow using Taskflow's decorator API. It showcases the basic structure for creating a workflow and running it with asyncio."},"warnings":[{"fix":"Update task and flow decorators/constructors to use `inputs` and `outputs` parameters as dictionaries, mapping argument names to types.","message":"Task and Flow input/output declarations changed significantly in v6.0.0. Previously, inputs were declared as direct keyword arguments (e.g., `@task(name=str)`). Now, they must be dictionaries (e.g., `@task(inputs={\"name\": str})`).","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Remove references to the deprecated executors. If non-asyncio concurrency is needed, consider integrating external solutions or implement a custom executor that wraps `AsyncIOExecutor`.","message":"The `LocalThreadPoolExecutor` and `ProcessThreadPoolExecutor` options for `FlowConfig` were removed in v6.0.0. The default executor is now `AsyncIOExecutor`.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"When instantiating `Flow` or `Task` classes, pass a `config` object (e.g., `Flow(config=FlowConfig(max_concurrency=5))`). For decorators, use `flow(config=FlowConfig(...))`.","message":"Configuration parameters for `Flow` and `Task` are no longer passed directly to their constructors or decorators. All configuration is now done via `FlowConfig` or `TaskConfig` objects.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Migrate custom flow and task implementations to directly inherit from `taskflow.Flow` and `taskflow.Task` respectively.","message":"The base classes `AbstractFlow` and `AbstractTask` were removed in v6.0.0. Users subclassing these should now subclass `Flow` and `Task` directly.","severity":"deprecated","affected_versions":">=6.0.0"},{"fix":"Ensure all type annotations in task and flow definitions are accurate and consistent with the data types being passed and returned. Validate data types at runtime if external inputs are untrusted.","message":"Taskflow v6.x introduced stricter type enforcement. Mismatched type annotations between task signatures, input/output declarations, and actual data types can lead to runtime `TypeError` exceptions.","severity":"gotcha","affected_versions":">=6.0.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Declare inputs using the `inputs` dictionary parameter: `@task(inputs={'my_input': str})`.","cause":"Attempting to declare task inputs as direct keyword arguments in Taskflow v6.x or newer, which is the pre-v6 syntax.","error":"TypeError: task() got an unexpected keyword argument 'my_input'"},{"fix":"The `LocalThreadPoolExecutor` and `ProcessThreadPoolExecutor` were removed. Use the `AsyncIOExecutor` (default) or implement a custom one. For general config, pass a `FlowConfig` instance.","cause":"Accessing or configuring executors (e.g., `LocalThreadPoolExecutor`) or other flow/task settings using pre-v6 methods or referencing removed components.","error":"AttributeError: 'FlowConfig' object has no attribute 'executor' or similar configuration errors."},{"fix":"Install the library using pip: `pip install taskflow`. Ensure your virtual environment is activated if you are using one.","cause":"The `taskflow` library is not installed in the current Python environment or the environment is not activated.","error":"ModuleNotFoundError: No module named 'taskflow'"},{"fix":"Pass configuration parameters via a `FlowConfig` object: `my_flow = Flow(config=FlowConfig(max_concurrency=5))`.","cause":"In Taskflow v6.x+, direct configuration arguments for `Flow` or `Task` constructors (like `max_concurrency`) were removed.","error":"TypeError: Flow.__init__() got an unexpected keyword argument 'max_concurrency'"}]}