Change environmental variable `ALLOW_CUSTOM_PYTHON_EXECUTION_IN_WORKFLOWS=True Error

I’m currently running a workflow with inference on a local server (Running using the downloadable Roboflow App). However, when I run the Python API inference script made available from the Deploy tab in the Roboflow Workflow, I encounter the following error:

raise HTTPCallErrorError(
inference_sdk.http.errors.HTTPCallErrorError: HTTPCallErrorError(
    description='500 Server Error: Internal Server Error for url: https://serverless.roboflow.com/dikshants-blog-workspace/workflows/background-blurring-workflow',
    api_message='Cannot use dynamic blocks with custom Python code in this installation of workflows. This can be changed by setting the environment variable ALLOW_CUSTOM_PYTHON_EXECUTION_IN_WORKFLOWS=True. More details: None',
    status_code=500
)

This is the script I’m using:

from inference_sdk import InferenceHTTPClient

client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com",
    api_key="XXXXXXXXXXXXXX"
)

result = client.run_workflow(
    workspace_name="dikshants-blog-workspace",
    workflow_id="background-blurring-workflow",
    images={
        "image": "./first_frame.jpg"
    },
    parameters={
        "kernel_size": 81,
        "blur_type": "gaussian"
    },
    use_cache=True
)

The workflow runs correctly when I use it through the Roboflow UI at app.roboflow. I also tried adding the ALLOW_CUSTOM_PYTHON_EXECUTION_IN_WORKFLOWS as environment variable as True on my Windows machine. After setting it in the same PowerShell session that runs the Roboflow inference server, running $env:ALLOW_CUSTOM_PYTHON_EXECUTION_IN_WORKFLOWS returns True.

Hi Dikshant,

Your script is pointing to the serverless inference API, which has no support for custom Python blocks:

...
client = InferenceHTTPClient(
    api_url="https://serverless.roboflow.com", # <- Serverless API
    api_key="XXXXXXXXXXXXXX"
)
...

Currently, the Hosted API (https://detect.roboflow.com) and the Serverless API (https://serverless.roboflow.com) have no support for running Python blocks. That’s the reason for the error.

Since you’re running the Roboflow Inference App, you already have a local server with support to custom blocks. All you have to do is change the api_url to http://localhost:9001.

Once you’re ready to deploy your workflow, there’s two ways you can run it with custom block support:

  1. Start a Dedicated Deployment, which will run a dedicated inference API for you.
  2. Self-host inference and connect to the address of your server.
1 Like

Pointing to localhost worked thank you.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.