Hassan Hashmi
03/18/2026, 1:09 PMMarvin
03/18/2026, 1:09 PMMarvin
03/18/2026, 1:16 PM# Linux (bash)
export PREFECT_API_URL="<https://api.prefect.cloud/api/accounts/<acct-id>/workspaces/<ws-id>>"
export PREFECT_API_KEY="<your_api_key>"
# Windows (PowerShell)
$env:PREFECT_API_URL = "<https://api.prefect.cloud/api/accounts/<acct-id>/workspaces/<ws-id>>"
$env:PREFECT_API_KEY = "<your_api_key>"
- Or self‑hosted on Ubuntu B (make sure Windows A can reach it)
# Example local server URL
export PREFECT_API_URL="http://<ubuntu-b-ip>:4200/api"
2) Create work pools (one per environment)
prefect work-pool create windows-process-pool --type process
prefect work-pool create ubuntu-docker-pool --type docker
# If you won’t use Docker on Ubuntu, create a process work pool instead:
# prefect work-pool create ubuntu-process-pool --type process
Tip: If you plan to use Docker/Kubernetes, install extras on the Ubuntu host:
pip install "prefect[docker]"
# or
pip install "prefect[kubernetes]"
3) Start a worker on each machine
- Ubuntu B:
# Docker-based worker
prefect worker start --pool ubuntu-docker-pool --type docker
# or, process-based
# prefect worker start --pool ubuntu-process-pool --type process
- Windows A (PowerShell):
prefect worker start --pool windows-process-pool --type process
Run these as services for reliability (systemd on Ubuntu, Task Scheduler/NSSM on Windows).
4) Create deployments that target each machine
- Example: a flow you want to run on Ubuntu
from prefect import flow
@flow(log_prints=True)
def transform_on_ubuntu(x: int = 1):
print(f"Ubuntu transform: x={x}")
return x * 2
if __name__ == "__main__":
transform_on_ubuntu.deploy(
name="ubuntu-transform",
work_pool_name="ubuntu-docker-pool", # or ubuntu-process-pool
interval=3600, # run hourly, or omit for on-demand
parameters={"x": 10},
)
- Example: a flow you want to run on Windows
```
from prefect import flow
@flow(log_prints=True)
def process_on_windows(path: str):
# Windows-native operations (e.g., PowerShell, COM, vendor tools)
import subprocess
r = subprocess.run(["powershell", "-Command", f"Get-Item '{path}'"], capture_output=True, text=True)
print(r.stdout or r.stderr)Marvin
03/18/2026, 1:16 PM5) Trigger Windows work from Ubuntu
- Programmatically from a flow running on Ubuntu:
from prefect import flow
from prefect.deployments import run_deployment
@flow
def orchestrate(date: str):
# Kick off a Windows deployment
run_deployment(
name="process_on_windows/windows-process", # "<flow_name>/<deployment_name>"
parameters={"path": f"C:\\data\\input\\{date}.csv"}
)
if name == "__main__":
orchestrate.deploy(
name="ubuntu-orchestrator",
work_pool_name="ubuntu-docker-pool"
)
- Or use Automations to chain deployments when one completes:
<https://docs.prefect.io/v3/how-to-guides/automations/chaining-deployments-with-events/|Chaining deployments with events>
6) Share results/data between machines
- Turn on persisted results and use shared storage (S3/Azure/NFS/SMB):
# Global default (optional)
prefect config set PREFECT_RESULTS_PERSIST_BY_DEFAULT=true
- Example with S3 (install collection: pip install prefect-aws):
from prefect import flow
from prefect_aws.s3 import S3Bucket
# One-time setup (can be done in code or UI)
S3Bucket(bucket_name="my-prefect-results").save("results-bucket", overwrite=True)
@flow(persist_result=True, result_storage="s3-bucket/results-bucket")
def cross_machine_step():
return {"status": "ok"}
```
Windows and Ubuntu workers can both read/write this storage, enabling handoffs.
Operational best practices
- Keep workers always-on (systemd on Ubuntu; Task Scheduler/NSSM on Windows)
- Use service accounts/API keys for workers; store secrets in env vars or Prefect blocks
- Use work pools per environment to isolate packages, OS specifics, and concurrency limits
- Prefer Docker on Ubuntu when you need reproducible environments
- For Windows‑native tooling, use the process worker and vendor CLIs/PowerShell
- Ensure both machines can reach the Prefect API (firewall/DNS) and any result storage
- Monitor from the Prefect UI; add retries/timeouts where appropriate
Answers to your specific bullets
- Orchestration across multiple machines: Yes—via work pools + workers connected to a shared API. See Workers and Work pools.
- Trigger/execute tasks on Windows from Ubuntu: Create a deployment targeting the Windows work pool and trigger it from Ubuntu using prefect deployment run ... or run_deployment() from a flow. See Run deployments.
- Recommended architecture: Control plane (Cloud or self‑hosted on Ubuntu) + one worker per machine polling its pool; use result persistence and, if needed, event‑driven Automations to chain cross‑machine steps. See Deploy via Python and Chaining.
A few clarifying questions to tailor this to you
- Will you use Prefect Cloud or self‑hosted on Ubuntu B?
- Is Docker acceptable on Ubuntu B, or should we stick to the process worker there?
- What needs to run specifically on Windows A (native binaries/PowerShell/vendor tools)?
- Do you already have shared storage (e.g., S3/Azure/SMB/NFS) for handoffs, or should we propose one?
If you share those details, I can provide a minimal, copy‑pasteable blueprint (flows, deployments, and worker service configs) for your exact environment.