Open zdql opened 1 month ago
To address the "Component has not been built yet" error in Langflow when running flows using your Docker setup, you can try the following steps:
Verify Installation: Ensure that the Langflow package is installed correctly in your Dockerfile. You can add a verification step to check the installation.
Concurrency Handling: Since you are using multiple workers, ensure that concurrency issues are handled properly. Langflow has known race conditions that might affect the build process.
Improved Dockerfile: Update your Dockerfile to include verification steps and ensure all components are built correctly.
Here is an improved version of your Dockerfile:
FROM python:3.10-slim
COPY requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt
RUN pip install langflow==1.0.8 -U --user
COPY custom_components /app/custom_components
# Verify installation
RUN pip show langflow
CMD ["python", "-m", "langflow", "run", "--host", "0.0.0.0", "--port", "7860", "--components-path", "/app/custom_components", "--workers", "4"]
build_vertex
function to better understand the root cause of the error. Here is an example:@router.post("/build/{flow_id}/vertices/{vertex_id}")
async def build_vertex(
flow_id: uuid.UUID,
vertex_id: str,
background_tasks: BackgroundTasks,
inputs: Annotated[Optional[InputValueRequest], Body(embed=True)] = None,
files: Optional[list[str]] = None,
chat_service: "ChatService" = Depends(get_chat_service),
current_user=Depends(get_current_active_user),
telemetry_service: "TelemetryService" = Depends(get_telemetry_service),
):
"""Build a vertex instead of the entire graph."""
flow_id_str = str(flow_id)
next_runnable_vertices = []
top_level_vertices = []
start_time = time.perf_counter()
try:
cache = await chat_service.get_cache(flow_id_str)
if not cache:
logger.warning(f"No cache found for {flow_id_str}. Building graph starting at {vertex_id}")
graph: "Graph" = await build_graph_from_db(
flow_id=flow_id_str, session=next(get_session()), chat_service=chat_service
)
else:
graph = cache.get("result")
await graph.initialize_run()
vertex = graph.get_vertex(vertex_id)
# Additional logic to handle vertex building
...
except Exception as exc:
background_tasks.add_task(
telemetry_service.log_package_component,
ComponentPayload(
name=vertex_id,
seconds=int(time.perf_counter() - start_time),
success=False,
errorMessage=str(exc),
),
)
logger.error(f"Error building Component:\n\n{exc}")
logger.exception(exc)
message = parse_exception(exc)
raise HTTPException(status_code=500, detail=message) from exc
lock = chat_service._cache_locks[flow_id_str]
(
result_dict,
params,
valid,
artifacts,
vertex,
) = await graph.build_vertex(
chat_service=chat_service,
vertex_id=vertex_id,
user_id=current_user.id,
inputs_dict=inputs.model_dump() if inputs else {},
files=files,
)
By following these steps, you can improve the reliability of the component building process in Langflow and reduce the occurrence of the "Component has not been built yet" error [1][2].
To continue talking to Dosu, mention @dosu.
Describe the bug A clear and concise description of what the bug is.
We run langflow via a pip install in a docker file, passing in 4 celery workers like so:
Browser and Version
To Reproduce Host langflow with our docker file and attempt to run any flow. The error will happen sporadically when running flows
This is the stack trace we see:
Additional context We've seen this occur on both our custom components and the langflow built in components. The error happens about 40% of the time when running a flow.