forked from rubra-ai/rubra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Dnouv/fix_task_exec
Merge changes from Deb's fork
- Loading branch information
Showing
21 changed files
with
283 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .config import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from os import getenv | ||
|
||
def get_mongo_database_name(): | ||
return getenv("MONGODB_DATABASE", "rubra_db") | ||
|
||
def get_mongo_url() -> str: | ||
url = getenv("MONGODB_URL") | ||
if url: | ||
return url | ||
|
||
host = getenv("MONGODB_HOST", "localhost") | ||
user = getenv("MONGODB_USER", getenv("MONGODB_USERNAME", None)) | ||
password = getenv("MONGODB_PASS", getenv("MONGODB_PASSWORD", None)) | ||
port = getenv("MONGODB_PORT", 27017) | ||
database = get_mongo_database_name() | ||
|
||
if user and not password: | ||
print("MONGODB_USER set but password not found, ignoring user") | ||
|
||
if not user and password: | ||
print("MONGODB_PASSWORD set but user not found, ignoring password") | ||
|
||
if user and password: | ||
return f"mongodb://{user}:{password}@{host}:${port}/{database}" | ||
|
||
return f"mongodb://{host}:{port}/{database}" | ||
|
||
def get_redis_url() -> str: | ||
url = getenv("REDIS_URL") | ||
if url: | ||
return url | ||
|
||
host = getenv("REDIS_HOST", "localhost") | ||
password = getenv("REDIS_PASS", getenv("REDIS_PASSWORD", None)) | ||
user = getenv("REDIS_USER", getenv("REDIS_USERNAME", None)) | ||
port = getenv("REDIS_PORT", 6379) | ||
database = getenv("REDIS_DATABASE", 0) | ||
|
||
if password: | ||
return f"redis://{user or ''}:{password}@{host}:{port}/{database}" | ||
|
||
return f"redis://{host}:{port}/{database}" | ||
|
||
def get_litellm_url() -> str: | ||
url = getenv("LITELLM_URL") | ||
if url: | ||
return url | ||
|
||
host = getenv("LITELLM_HOST", "localhost") | ||
port = getenv("LITELLM_PORT", 8002) | ||
|
||
return f"http://{host}:{port}" | ||
|
||
def get_vector_db_url() -> str: | ||
url = getenv("VECTOR_DB_URL") | ||
if url: | ||
return url | ||
|
||
host = getenv("VECTOR_DB_HOST", "localhost") | ||
port = getenv("VECTOR_DB_PORT", 8010) | ||
|
||
return f"http://{host}:{port}" | ||
|
||
def get_embedding_url(): | ||
url = getenv("EMBEDDING_URL") | ||
if url: | ||
return url | ||
|
||
host = getenv("EMBEDDING_HOST", "localhost") | ||
port = getenv("EMBEDDING_PORT", 8020) | ||
|
||
return f"http://{host}:{port}" | ||
|
||
mongo_database = get_mongo_database_name() | ||
|
||
mongo_url = get_mongo_url() | ||
|
||
litellm_url = get_litellm_url() | ||
|
||
vector_db_url = get_vector_db_url() | ||
|
||
redis_url = get_redis_url() | ||
|
||
embedding_url = get_embedding_url() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import redis | ||
from celery import Celery | ||
from typing import cast | ||
import core.config as configs | ||
|
||
|
||
redis_client = cast(redis.Redis, redis.Redis.from_url(configs.redis_url)) # annoyingly from_url returns None, not Self | ||
app = Celery("tasks", broker=configs.redis_url) | ||
|
||
app.autodiscover_tasks(["core.tasks"]) # Explicitly discover tasks in 'app' package |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import socket | ||
|
||
import requests | ||
|
||
from core.config import litellm_url, vector_db_url | ||
|
||
from .celery_app import app | ||
|
||
def is_ready(): | ||
# response = requests.get(f"{litellm_url}/health", headers={ | ||
# "Authorization": f"Bearer {os.getenv('LITELLM_MASTER_KEY', '')}" | ||
# }) | ||
# if not response.ok: | ||
# raise Exception(response.text) | ||
|
||
# print(response) | ||
|
||
response = requests.get(f"{litellm_url}/health/readiness") | ||
if not response.ok: | ||
raise Exception(response.text) | ||
|
||
print(response) | ||
|
||
pong = app.control.ping([f'celery@{socket.gethostname()}']) | ||
if len(pong) == 0 or list(pong[0].values())[0].get('ok', None) is None: | ||
raise Exception('ping failed with' + str(pong)) | ||
|
||
print(pong) | ||
|
||
response = requests.get(f"{vector_db_url}/healthz") | ||
if not response.ok: | ||
raise Exception(response.text) | ||
|
||
print(response) | ||
|
||
|
||
if __name__ == "__main__": | ||
is_ready() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.