Skip to content

Commit

Permalink
Change TrustyAIService to use DB instead of PVC
Browse files Browse the repository at this point in the history
  • Loading branch information
adolfo-ab committed Sep 2, 2024
1 parent 17ff379 commit dfbe2a2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 19 deletions.
33 changes: 28 additions & 5 deletions trustyai_tests/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from ocp_resources.service_account import ServiceAccount
from ocp_resources.trustyai_service import TrustyAIService
from ocp_resources.mariadb_operator import MariadbOperator
from ocp_utilities.operators import install_operator
from ocp_utilities.operators import install_operator, uninstall_operator

from trustyai_tests.tests.constants import (
TRUSTYAI_SERVICE,
Expand Down Expand Up @@ -100,7 +100,7 @@ def db_credentials(model_namespace):
namespace=model_namespace.name,
string_data={
"databaseKind": "mariadb",
# "databaseName": "trustyai_database",
"databaseName": "trustyai_database",
"databaseUsername": "quarkus",
"databasePassword": "quarkus",
"databaseService": "mariadb",
Expand All @@ -124,9 +124,11 @@ def mariadb_operator() -> Generator:
source="community-operators",
operator_namespace=namespace,
timeout=600,
install_plan_approval="Manual",
)
sleep(60)
yield
# uninstall_operator(admin_client=client, name=name, operator_namespace=namespace)
uninstall_operator(admin_client=client, name=name, operator_namespace=namespace, clean_up_namespace=False)


@pytest.fixture(scope="session")
Expand All @@ -136,14 +138,15 @@ def mariadb_operator_cr(mariadb_operator: None) -> MariadbOperator:
condition="Deployed", status=mariadb_operator.Condition.Status.TRUE, timeout=10 * 60
)
wait_for_mariadb_operator_pods(mariadb_operator=mariadb_operator)
sleep(30)
sleep(60)
yield mariadb_operator


@pytest.fixture(scope="class")
def mariadb(model_namespace, db_credentials, mariadb_operator_cr: MariadbOperator) -> MariaDB:
with MariaDB(yaml_file="trustyai_tests/manifests/mariadb.yaml") as mariadb:
wait_for_mariadb_pods(mariadb=mariadb)
sleep(60)
yield mariadb


Expand Down Expand Up @@ -186,7 +189,7 @@ def user_workload_monitoring_config(client: DynamicClient) -> ConfigMap:


@pytest.fixture(scope="class")
def trustyai_service(
def trustyai_service_pvc(
client: DynamicClient,
model_namespace: Namespace,
modelmesh_serviceaccount: Any,
Expand All @@ -205,6 +208,26 @@ def trustyai_service(
yield trusty


@pytest.fixture(scope="class")
def trustyai_service_db(
client: DynamicClient,
model_namespace: Namespace,
mariadb,
modelmesh_serviceaccount: Any,
cluster_monitoring_config: ConfigMap,
user_workload_monitoring_config: ConfigMap,
) -> TrustyAIService:
with TrustyAIService(
client=client,
name=TRUSTYAI_SERVICE,
namespace=model_namespace.name,
storage={"format": "DATABASE", "databaseConfigurations": "db-credentials"},
metrics={"schedule": "5s"},
) as trusty:
wait_for_trustyai_pod_running(namespace=model_namespace)
yield trusty


@pytest.fixture(scope="class")
def minio_service(client: DynamicClient, model_namespace: Namespace) -> Generator[Service, Any, None]:
with create_minio_service(namespace=model_namespace) as minio_service:
Expand Down
18 changes: 9 additions & 9 deletions trustyai_tests/tests/drift/test_drift.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class TestDriftMetrics:
"""

def test_gaussian_credit_model_metadata(
self, model_namespace: Namespace, trustyai_service: TrustyAIService, gaussian_credit_model: InferenceService
self, model_namespace: Namespace, trustyai_service_db: TrustyAIService, gaussian_credit_model: InferenceService
) -> None:
wait_for_modelmesh_pods_registered(namespace=model_namespace)

Expand All @@ -60,7 +60,7 @@ def test_gaussian_credit_model_metadata(
)

def test_request_meanshift(
self, model_namespace: Namespace, trustyai_service: TrustyAIService, gaussian_credit_model: InferenceService
self, model_namespace: Namespace, trustyai_service_db: TrustyAIService, gaussian_credit_model: InferenceService
) -> None:
verify_metric_request(
namespace=model_namespace,
Expand All @@ -70,7 +70,7 @@ def test_request_meanshift(
)

def test_schedule_meanshift(
self, model_namespace: Namespace, trustyai_service: TrustyAIService, gaussian_credit_model: InferenceService
self, model_namespace: Namespace, trustyai_service_db: TrustyAIService, gaussian_credit_model: InferenceService
) -> None:
verify_metric_scheduling(
namespace=model_namespace,
Expand All @@ -89,7 +89,7 @@ def test_meanshift_prometheus_query(
)

def test_request_fouriermmd(
self, model_namespace: Namespace, trustyai_service: TrustyAIService, gaussian_credit_model: InferenceService
self, model_namespace: Namespace, trustyai_service_db: TrustyAIService, gaussian_credit_model: InferenceService
) -> None:
verify_metric_request(
namespace=model_namespace,
Expand All @@ -99,7 +99,7 @@ def test_request_fouriermmd(
)

def test_schedule_fouriermmd(
self, model_namespace: Namespace, trustyai_service: TrustyAIService, gaussian_credit_model: InferenceService
self, model_namespace: Namespace, trustyai_service_db: TrustyAIService, gaussian_credit_model: InferenceService
) -> None:
verify_metric_scheduling(
namespace=model_namespace,
Expand All @@ -118,7 +118,7 @@ def test_fouriermmd_prometheus_query(
)

def test_request_kstest(
self, model_namespace: Namespace, trustyai_service: TrustyAIService, gaussian_credit_model: InferenceService
self, model_namespace: Namespace, trustyai_service_db: TrustyAIService, gaussian_credit_model: InferenceService
) -> None:
verify_metric_request(
namespace=model_namespace,
Expand All @@ -128,7 +128,7 @@ def test_request_kstest(
)

def test_schedule_kstest_scheduling_request(
self, model_namespace: Namespace, trustyai_service: TrustyAIService, gaussian_credit_model: InferenceService
self, model_namespace: Namespace, trustyai_service_db: TrustyAIService, gaussian_credit_model: InferenceService
) -> None:
verify_metric_scheduling(
namespace=model_namespace,
Expand All @@ -145,7 +145,7 @@ def test_kstest_prometheus_query(self, model_namespace: Namespace, gaussian_cred
)

def test_request_approxkstest(
self, model_namespace: Namespace, trustyai_service: TrustyAIService, gaussian_credit_model: InferenceService
self, model_namespace: Namespace, trustyai_service_db: TrustyAIService, gaussian_credit_model: InferenceService
) -> None:
verify_metric_request(
namespace=model_namespace,
Expand All @@ -155,7 +155,7 @@ def test_request_approxkstest(
)

def test_schedule_approxkstest(
self, model_namespace: Namespace, trustyai_service: TrustyAIService, gaussian_credit_model: InferenceService
self, model_namespace: Namespace, trustyai_service_db: TrustyAIService, gaussian_credit_model: InferenceService
) -> None:
verify_metric_scheduling(
namespace=model_namespace,
Expand Down
10 changes: 5 additions & 5 deletions trustyai_tests/tests/fairness/test_fairness.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class TestFairnessMetrics:
def test_loan_model_metadata(
self,
model_namespace: Namespace,
trustyai_service: TrustyAIService,
trustyai_service_db: TrustyAIService,
onnx_loan_model_alpha: InferenceService,
onnx_loan_model_beta: InferenceService,
) -> None:
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_loan_model_metadata(
def test_request_spd(
self,
model_namespace: Namespace,
trustyai_service: TrustyAIService,
trustyai_service_db: TrustyAIService,
onnx_loan_model_alpha: InferenceService,
onnx_loan_model_beta: InferenceService,
) -> None:
Expand All @@ -111,7 +111,7 @@ def test_request_spd(
def test_schedule_spd(
self,
model_namespace: Namespace,
trustyai_service: TrustyAIService,
trustyai_service_db: TrustyAIService,
onnx_loan_model_alpha: InferenceService,
onnx_loan_model_beta: InferenceService,
) -> None:
Expand Down Expand Up @@ -139,7 +139,7 @@ def test_spd_prometheus_query(
def test_request_dir(
self,
model_namespace: Namespace,
trustyai_service: TrustyAIService,
trustyai_service_db: TrustyAIService,
onnx_loan_model_alpha: InferenceService,
onnx_loan_model_beta: InferenceService,
) -> None:
Expand All @@ -154,7 +154,7 @@ def test_request_dir(
def test_schedule_dir(
self,
model_namespace: Namespace,
trustyai_service: TrustyAIService,
trustyai_service_db: TrustyAIService,
onnx_loan_model_alpha: InferenceService,
onnx_loan_model_beta: InferenceService,
) -> None:
Expand Down

0 comments on commit dfbe2a2

Please sign in to comment.