Dynamo follows a class-based architecture similar to BentoML making it intuitive for users familiar with those frameworks. Each service is defined as a Python class, with the following components:
Dynamo follows a class-based architecture similar to BentoML making it intuitive for users familiar with those frameworks. Each service is defined as a Python class, with the following components:
1. Class attributes for dependencies using `depends()`
1. Class attributes for dependencies using `depends()`
2. An `__init__` method for standard initialization
2. An `__init__` method for standard initialization
3. Optional lifecycle hooks like `@async_on_start` and `@async_on_shutdown`
3. Optional lifecycle hooks like `@async_on_start` and `@on_shutdown`
4. Endpoints defined with `@endpoint()`. Optionally, an endpoint can be given a name
4. Endpoints defined with `@endpoint()`. Optionally, an endpoint can be given a name
via `@endpoint("my_endpoint_name")`, but otherwise defaults to the name of the
via `@endpoint("my_endpoint_name")`, but otherwise defaults to the name of the
function being decorated if omitted.
function being decorated if omitted.
...
@@ -170,15 +170,14 @@ This is especially useful for:
...
@@ -170,15 +170,14 @@ This is especially useful for:
- Initializing external connections
- Initializing external connections
- Setting up runtime resources that require async operations
- Setting up runtime resources that require async operations
#### `@async_on_shutdown`
#### `@on_shutdown`
The `@async_on_shutdown` hook is called when the service is shutdown handles cleanup.
The `@on_shutdown` hook is called when the service is shutdown handles cleanup.
This ensures resources are properly released, preventing memory leaks and making sure external connections are properly closed. This is helpful to clean up vLLM engines that have been started outside of the main process.
This ensures resources are properly released, preventing memory leaks and making sure external connections are properly closed. This is helpful to clean up vLLM engines that have been started outside of the main process.
...
@@ -471,4 +470,4 @@ Think of all the depends statements as the maximal set of edges for the processo
...
@@ -471,4 +470,4 @@ Think of all the depends statements as the maximal set of edges for the processo
Processor.link(Router)
Processor.link(Router)
```
```
This removes the `worker` dependency from the Processor and only spin up the Router.
This removes the `worker` dependency from the Processor and only spin up the Router.