Skip to content

Commit

Permalink
Composability cleanup (#96)
Browse files Browse the repository at this point in the history
* only restart an app named RagStudio

* handle the compostable version as well

* a couple of extra checks for possible empty string env var

* move the db env var into the startup script

* remove un-needed internal env vars

* Update release version to dev-testing

---------

Co-authored-by: actions-user <actions@github.com>
  • Loading branch information
jkwatson and actions-user authored Jan 8, 2025
1 parent 8e1dd42 commit 733a4d5
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 34 deletions.
15 changes: 0 additions & 15 deletions .project-metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ environment_variables:
default: ""
description: "The domain of the CAII service. Setting this will enable CAII as the sole source for both inference and embedding models."
required: false
DB_URL:
default: "jdbc:h2:file:~/databases/rag"
description: "Internal DB URL. Do not change."
required: true
LLM_SERVICE_URL:
default: "http://localhost:8081"
description: "Internal API URL. Do not change."
required: true
API_URL:
default: "http://localhost:8080"
description: "Internal API URL. Do not change."
required: true


runtimes:
Expand Down Expand Up @@ -89,6 +77,3 @@ tasks:
memory: 4
environment_variables:
TASK_TYPE: START_APPLICATION
DB_URL: "jdbc:h2:file:~/databases/rag"
LLM_SERVICE_URL: "http://localhost:8081"
API_URL: "http://localhost:8080"
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ public RagFileUploader ragFileUploader(S3Config configuration) {
}

public static String getRagIndexUrl() {
return Optional.ofNullable(System.getenv("LLM_SERVICE_URL")).orElse("http://rag-backend:8000");
return Optional.ofNullable(System.getenv("LLM_SERVICE_URL")).orElse("http://localhost:8000");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void indexFile() {
.contains(
new TrackedHttpRequest<>(
HttpMethod.POST,
"http://rag-backend:8000/data_sources/"
"http://localhost:8000/data_sources/"
+ 1234L
+ "/documents/"
+ "documentId"
Expand Down Expand Up @@ -98,7 +98,7 @@ void indexFile_unsupportedType() {
.contains(
new TrackedHttpRequest<>(
HttpMethod.POST,
"http://rag-backend:8000/data_sources/"
"http://localhost:8000/data_sources/"
+ 1234L
+ "/documents/"
+ "documentId"
Expand Down Expand Up @@ -127,7 +127,7 @@ void indexFile_serverError() {
.contains(
new TrackedHttpRequest<>(
HttpMethod.POST,
"http://rag-backend:8000/data_sources/"
"http://localhost:8000/data_sources/"
+ 1234L
+ "/documents/"
+ "documentId"
Expand All @@ -150,7 +150,7 @@ void createSummary() {
.contains(
new TrackedHttpRequest<>(
HttpMethod.POST,
"http://rag-backend:8000/data_sources/1234/documents/" + "documentId" + "/summary",
"http://localhost:8000/data_sources/1234/documents/" + "documentId" + "/summary",
new RagBackendClient.SummaryRequest("bucketName", "s3Path", "myfile.pdf")));
}

Expand All @@ -173,7 +173,7 @@ void createSummary_unsupportedMediaType() {
.contains(
new TrackedHttpRequest<>(
HttpMethod.POST,
"http://rag-backend:8000/data_sources/1234/documents/" + "documentId" + "/summary",
"http://localhost:8000/data_sources/1234/documents/" + "documentId" + "/summary",
new RagBackendClient.SummaryRequest("bucketName", "s3Path", "myfile.pdf")));
}

Expand All @@ -196,7 +196,7 @@ void createSummary_serverError() {
.contains(
new TrackedHttpRequest<>(
HttpMethod.POST,
"http://rag-backend:8000/data_sources/1234/documents/" + "documentId" + "/summary",
"http://localhost:8000/data_sources/1234/documents/" + "documentId" + "/summary",
new RagBackendClient.SummaryRequest("bucketName", "s3Path", "myfile.pdf")));
}

Expand All @@ -210,7 +210,7 @@ void deleteDataSource() {
.hasSize(1)
.contains(
new TrackedHttpRequest<>(
HttpMethod.DELETE, "http://rag-backend:8000/data_sources/1234", null));
HttpMethod.DELETE, "http://localhost:8000/data_sources/1234", null));
}

@Test
Expand All @@ -224,7 +224,7 @@ void deleteDocument() {
.contains(
new TrackedHttpRequest<>(
HttpMethod.DELETE,
"http://rag-backend:8000/data_sources/1234/documents/documentId",
"http://localhost:8000/data_sources/1234/documents/documentId",
null));
}

Expand All @@ -238,7 +238,7 @@ void deleteSession() {
.hasSize(1)
.contains(
new TrackedHttpRequest<>(
HttpMethod.DELETE, "http://rag-backend:8000/sessions/1234", null));
HttpMethod.DELETE, "http://localhost:8000/sessions/1234", null));
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion llm-service/app/routers/index/amp_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

router = APIRouter(prefix="/amp-update", tags=["AMP Update"])

root_dir = "/home/cdsw/rag-studio" if os.getenv("IS_COMPOSABLE") else "/home/cdsw"
root_dir = "/home/cdsw/rag-studio" if os.getenv("IS_COMPOSABLE", "") != "" else "/home/cdsw"

@router.get("", summary="Returns a boolean for whether AMP needs updating.")
@exceptions.propagates
Expand Down
2 changes: 1 addition & 1 deletion scripts/01_install_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import subprocess
import os

root_dir = "/home/cdsw/rag-studio" if os.getenv("IS_COMPOSABLE") else "/home/cdsw"
root_dir = "/home/cdsw/rag-studio" if os.getenv("IS_COMPOSABLE", "") != "" else "/home/cdsw"
os.chdir(root_dir)

print(subprocess.run(["python scripts/validator/validate_env.py"], shell=True, check=True))
Expand Down
18 changes: 13 additions & 5 deletions scripts/refresh_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

import cmlapi

root_dir = "/home/cdsw/rag-studio" if os.getenv("IS_COMPOSABLE") else "/home/cdsw"
root_dir = "/home/cdsw/rag-studio" if os.getenv("IS_COMPOSABLE", "") != "" else "/home/cdsw"
os.chdir(root_dir)

print(subprocess.run(["git", "stash"], check=True))
Expand All @@ -56,9 +56,17 @@
project_id = os.environ["CDSW_PROJECT_ID"]
apps = client.list_applications(project_id=project_id)
if len(apps.applications) > 0:
# todo: handle case where there are multiple apps
app_id = apps.applications[0].id
print("Restarting app with ID: ", app_id)
client.restart_application(application_id=app_id, project_id=project_id)
# find the application named "RagStudio" and restart it
ragstudio_app = next((app for app in apps.applications if app.name == "RagStudio"), None)
if ragstudio_app:
app_id = ragstudio_app.id
print("Restarting app with ID: ", app_id)
client.restart_application(application_id=app_id, project_id=project_id)
else:
print("No RagStudio application found to restart. This can happen if someone renamed the application.")
if os.getenv("IS_COMPOSABLE", "") != "":
print("Composable environment. This is likely the initial deployment.")
else:
raise ValueError("RagStudio application not found to restart")
else:
print("No applications found to restart. This is likely the initial deployment.")
2 changes: 1 addition & 1 deletion scripts/release_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export RELEASE_TAG=1.6.0-beta
export RELEASE_TAG=dev-testing
2 changes: 1 addition & 1 deletion scripts/startup_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import subprocess
import os

root_dir = "/home/cdsw/rag-studio" if os.getenv("IS_COMPOSABLE") else "/home/cdsw"
root_dir = "/home/cdsw/rag-studio" if os.getenv("IS_COMPOSABLE", "") != "" else "/home/cdsw"
os.chdir(root_dir)

while True:
Expand Down
3 changes: 3 additions & 0 deletions scripts/startup_java.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@
set -ox pipefail

RAG_STUDIO_INSTALL_DIR="/home/cdsw/rag-studio"
DB_URL_LOCATION="jdbc:h2:file:~/rag-studio/databases/rag"
if [ -z "$IS_COMPOSABLE" ]; then
RAG_STUDIO_INSTALL_DIR="/home/cdsw"
DB_URL_LOCATION="jdbc:h2:file:~/databases/rag"
fi

export DB_URL=$DB_URL_LOCATION
export JAVA_ROOT=`ls ${RAG_STUDIO_INSTALL_DIR}/java-home`
export JAVA_HOME="${RAG_STUDIO_INSTALL_DIR}/java-home/${JAVA_ROOT}"

Expand Down

0 comments on commit 733a4d5

Please sign in to comment.