Skip to content

Commit

Permalink
[feat] add monitoring in tests & output script
Browse files Browse the repository at this point in the history
  • Loading branch information
Daggx committed Nov 9, 2023
1 parent ea0f488 commit 5268d42
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion edenai_apis/tests/features/test_async_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from edenai_apis.utils.exception import AsyncJobExceptionReason, ProviderException
from edenai_apis.utils.types import AsyncBaseResponseType, AsyncLaunchJobResponseType
from edenai_apis.utils.compare import compare_responses

from edenai_apis.interface import IS_MONITORING
from edenai_apis.utils.monitoring import insert_api_call

MAX_TIME = 180
TIME_BETWEEN_CHECK = 10
Expand Down Expand Up @@ -106,6 +107,9 @@ def _test_api_get_job_result_real_output(self, provider, feature, subfeature):
), "Response shouldn't be empty"
assert standardized, "The output is not standardized"

if IS_MONITORING:
insert_api_call(provider, feature, subfeature, None, None)

def _test_async_job(self, provider, feature, subfeature):
self._test_launch_job_id(provider, feature, subfeature)
self._test_api_get_job_result_real_output(provider, feature, subfeature)
Expand Down
9 changes: 6 additions & 3 deletions edenai_apis/tests/features/test_sync_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
from edenai_apis.utils.constraints import validate_all_provider_constraints
from edenai_apis.utils.conversion import iterate_all
from edenai_apis.utils.exception import ProviderException
from edenai_apis.utils.files import FileWrapper
from edenai_apis.utils.types import ResponseType

from edenai_apis.interface import IS_MONITORING
from edenai_apis.utils.monitoring import insert_api_call

INTERFACE_MODULE = importlib.import_module("edenai_apis.interface_v2")

Expand Down Expand Up @@ -81,7 +81,10 @@ def _test_feature_api_call(self, provider, feature, subfeature):
assert any(
[std != None for std in iterate_all(standardized_response, "value")]
), "Response shouldn't be empty"


if IS_MONITORING:
insert_api_call(provider, feature, subfeature, None, None)

def _test_feature_saved_output(self, provider, feature, subfeature):
# Step 1 (Setup) :
saved_output = load_provider(
Expand Down
5 changes: 4 additions & 1 deletion edenai_apis/tests/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import time
from typing import Callable
from edenai_apis.utils.constraints import (
validate_all_input_languages,
validate_all_provider_constraints,
)
import pytest
Expand All @@ -13,6 +12,8 @@
from edenai_apis.loaders.loaders import load_feature, load_provider
from edenai_apis.settings import outputs_path, features_path
from edenai_apis.utils.types import AsyncLaunchJobResponseType
from edenai_apis.interface import IS_MONITORING
from edenai_apis.utils.monitoring import insert_api_call

# TEXT_AUTOML_CLASSIFICATION = ["training_async", "prediction_async"]

Expand Down Expand Up @@ -123,4 +124,6 @@ def test_outputs(provider, feature, subfeature, phase, generate=True):
)
)

if IS_MONITORING:
insert_api_call(provider=provider,feature=feature,subfeature=subfeature,user_email=None, error=None)
return api_output

0 comments on commit 5268d42

Please sign in to comment.