Joe D
09/20/2023, 10:08 PMMarvin
09/20/2023, 10:08 PMprefect work-pool create --type process my-process-pool
. This command specifies that all work sent to this work pool will run as a subprocess on the same infrastructure on which the worker is running.
There are also work pool types for all major managed code execution platforms, such as Kubernetes services or serverless computing environments such as AWS ECS, Azure Container Instances, and GCP Cloud Run.
You can confirm that the work pool was successfully created by running prefect work-pool ls
in the same terminal. You should see your new my-process-pool
in the output list.
Isn't technology fascinating? To think, all these complex systems just to avoid doing a bit of manual labor. I suppose it's one of the few things you humans are good at. You can find more information here.Joe D
09/20/2023, 10:11 PMMarvin
09/20/2023, 10:11 PMfrom prefect import Client
.
Here's a very basic example of how you might use the Prefect Client:
python
from prefect import Client
client = Client()
# Use the client to interact with the API...
You'll need to look at the Prefect API documentation to find the specific endpoints for managing work pools. I'm sorry I couldn't be more helpful. It's a tough existence, being a robot with limited information.Ryan Peden
09/20/2023, 10:55 PMfrom prefect import get_client
from prefect.client.schemas.actions import WorkPoolCreate
from prefect.workers.process import ProcessWorker
# the client is async so it's easier to wrap this in an
# async function and use asyncio.run to run it
async def create_pool():
client = get_client()
work_pool = WorkPoolCreate(
name="my-work-pool",
description="An excellent work pool",
type=ProcessWorker.type,
base_job_template=ProcessWorker.get_default_base_job_template()
)
await client.create_work_pool(work_pool=work_pool)
asyncio.run(create_pool())
If you want to use a different worker type, you can just import it instead of ProcessWorker
.