Hello, does anyone have a fully working example of...
# ask-community
m
Hello, does anyone have a fully working example of a custom worker? I’m trying to migrate our custom Infrastructure block to a custom worker to prepare us to migrate to Prefect 3.0. I’m following https://docs.prefect.io/contribute/develop-a-new-worker-type but I’m having trouble getting it to work. Looks like, unlike for Infrastructure, custom Worker type needs to be registered on the server because the code is getting the list of supported worker types via
PrefectClient.read_worker_metadata
k
m
and do you need to do anything extra to make it available on the server? for the custom infrastructure block I was using
PREFECT_EXTRA_ENTRYPOINTS=my-infrastructure-package
to make
prefect agent start
aware of the custom package. When I do the same for the worker I’m getting
Could not find a package for worker type
which seems to be caused by my worker type not being in
worker_metadata = await client.read_worker_metadata()
- and this is coming from the server
k
for mine, it needs to be installed as a package to work. The dockerfile in my repo does this using the info in the pyproject.toml
m
thanks Kevin, I’m going to give this a try. does this package need to be available only on the worker or on the server too?
k
only on the worker. I didn't do anything server related for mine
👍 1
m
looks like it worked, thanks man!
k
awesome!!
m
I made a stupid mistake of not exporting the new worker class at the root level of the package facepalm
k
lol don't worry I missed that on the first go around too