Variables/Blocks for external tools

I want to use Prefect to call an external tool. I am new to prefect, the code below is what I came up with. I want to have different Flows/Deployments which are all identical except for the config of the external tool.

This seems to be a job for Variables or Blocks, but I didn’t grasp the concept of them, yet. Can someone help me? How would I use variables to provide different configs?

import subprocess
from prefect import flow, task, get_run_logger

@task(name="External Tool")
def external_tool():
    logger = get_run_logger()
    logger.info("Run external tool")
    returnCode = subprocess.call(["mytool", "-param1", "-config=/path/to/config.cfg"], timeout=28800)
    logger.info("external tool done")
    if returnCode!=0:
        raise ValueError("Something went wrong: " + str(returnCode))

@flow(name="Example flow", timeout_seconds=28800)
def processing():
    tool = external_tool.submit()
1 Like