The requirements in this are insane. Why the kitchen sink?
It would be smarter to do this:
async def call_n8n_workflow(workflow_id):
# Check workflow requirements
reqs = await n8n.get_workflow_requirements(workflow_id)
if reqs.needs_heavy_deps:
# Spawn isolated worker with those deps
worker = await WorkerPool.get_or_create(reqs.profile)
return await worker.execute(workflow_id)
else:
# Execute directly in lightweight process
return await n8n.webhook_call(workflow_id)
OR - use UV+Just-in-Time
uv venv --seed /tmp/workflow-123
uv pip install langchain openai
python -m execute_workflow --venv /tmp/workflow-123
Done? Destroy it
rm -rf /tmp/workflow-123