User should be able to create custom services and inject them using a setting/ENV-variable.
Create a new setting PREFECT_ORION_SERVICES_EXTRA which is used when when initializing the services with the Orion server. The setting should hold a comma-separated list of class-references for classes based on LoopService.
Example Use
export PREFECT_ORION_SERVICES_EXTRA="some.path.MyCustomService,some.other.path.MyOtherService"
prefect orion start
# Services are initialized on app init
Example service:
class MyCustomService(LoopService):
"""A super custom service that prints a message with every loop"""
loop_seconds: int = 60
async def run_once(self) -> None:
print("This is a very custom service")
Additional context
Custom services are very useful when users have specific needs. They can also be used to create and distribute optional services, similar to how blocks and and task-runners are distributed.
First check
Prefect Version
2.x
Describe the current behavior
Server
Loopservice
s are currently hardcoded for when the FastAPI starts: https://github.com/PrefectHQ/prefect/blob/main/src/prefect/orion/api/server.py#L361Describe the proposed behavior
User should be able to create custom services and inject them using a setting/ENV-variable.
Create a new setting
PREFECT_ORION_SERVICES_EXTRA
which is used when when initializing the services with the Orion server. The setting should hold a comma-separated list of class-references for classes based onLoopService
.Example Use
Example service:
Additional context
Custom services are very useful when users have specific needs. They can also be used to create and distribute optional services, similar to how blocks and and task-runners are distributed.
Exampel services could be: