Skip to content

Commit 84917e1

Browse files
authored
Merge pull request #48 from mobiusml/num_workers
Make the Number of Request Workers Configurable
2 parents f852f42 + 269d153 commit 84917e1

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,13 @@ ORM models referenced in the rest of the code should be imported from `aana.mode
202202
not from that model's file for reasons explained in `aana/models/db/__init__.py`. This also means that
203203
if you add a new model class, it should be imported by `__init__.py` in addition to creating a migration.
204204

205-
Higher level code for interacting with the ORM is available in `aana.repository.data`.
205+
Higher level code for interacting with the ORM is available in `aana.repository.data`.
206+
207+
## Settings
208+
209+
Here are the environment variables that can be used to configure the Aaana SDK:
210+
- TMP_DATA_DIR: The directory to store temporary data. Default: `/tmp/aana`.
211+
- NUM_WORKERS: The number of request workers. Default: `2`.
212+
- DB_CONFIG: The database configuration in the format `{"datastore_type": "sqlite", "datastore_config": {"path": "/path/to/sqlite.db"}}`. Currently only SQLite and PostgreSQL are supported. Default: `{"datastore_type": "sqlite", "datastore_config": {"path": "/var/lib/aana_data"}}`.
213+
- USE_DEPLOYMENT_CACHE (testing only): If set to `true`, the tests will use the deployment cache to avoid downloading the models and running the deployments. Default: `false`.
214+
- SAVE_DEPLOYMENT_CACHE (testing only): If set to `true`, the tests will save the deployment cache after running the deployments. Default: `false`.

aana/configs/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Settings(BaseSettings):
1919
tmp_data_dir: Path = Path("/tmp/aana_data") # noqa: S108
2020
image_dir = tmp_data_dir / "images"
2121
video_dir = tmp_data_dir / "videos"
22+
num_workers: int = 2
2223

2324
db_config: DBConfig = {
2425
"datastore_type": "sqlite",

aana/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def run():
5353
}
5454
}
5555
try:
56-
server = RequestHandler.bind(endpoints, pipeline_nodes, context)
56+
server = RequestHandler.options(num_replicas=aana_settings.num_workers).bind(
57+
endpoints, pipeline_nodes, context
58+
)
5759
serve.run(server, port=args.port, host=args.host)
5860
# TODO: add logging
5961
print("Deployed Serve app successfully.")

aana/tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ def start_ray_serve(endpoints, nodes, context, runtime_env=None):
9090
if runtime_env is None:
9191
runtime_env = {}
9292
server = RequestHandler.options(
93-
ray_actor_options={"runtime_env": runtime_env}
93+
num_replicas=aana_settings.num_workers,
94+
ray_actor_options={"runtime_env": runtime_env},
9495
).bind(endpoints, nodes, context)
9596
return setup_deployment(server)
9697

0 commit comments

Comments
 (0)