Skip to content

Commit

Permalink
[cicd] add check providers
Browse files Browse the repository at this point in the history
  • Loading branch information
Daggx committed Nov 21, 2023
1 parent 9843b93 commit f1fea02
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 1 deletion.
51 changes: 50 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,44 @@ jobs:
- store_artifacts:
path: edenai_apis/htmlcov

check_providers:
docker:
- image: cimg/python:3.8
# Add steps to the job
# See: https://circleci.com/docs/2.0/configuration-reference/#steps
parameters:
interval:
type: string
default: nightly

steps:
- checkout
- run:
name: Setup config files and folders
command: |
sudo apt-get update
sudo apt-get install build-essential libssl-dev libasound2 wget
wget http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.0g-2ubuntu4_amd64.deb
sudo dpkg -i libssl1.1_1.1.0g-2ubuntu4_amd64.deb
# Insall aws cli
pip install awscli --upgrade
# Copy settings file
aws s3 cp $S3PATH edenai_apis/api_keys --recursive
- run:
name: Install dependencies
command: |
sudo apt-get update
sudo apt-get install ffmpeg -y
pip install -e .
- run:
name: check working providers
command: |
python edenai_apis/scripts/check_not_working_providers.py << parameters.interval >>
# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
Expand All @@ -51,4 +89,15 @@ workflows:
branches:
only:
- master
- circleci
- circleci
nightly:
triggers:
- schedule:
cron: "0 6 * * 1-5"
filters:
branches:
only:
- master
- release
jobs:
- check_providers
61 changes: 61 additions & 0 deletions edenai_apis/scripts/check_not_working_providers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import sys
from pprint import pprint

import requests
from edenai_apis.interface import compute_output
from edenai_apis.loaders.data_loader import FeatureDataEnum
from edenai_apis.loaders.loaders import load_feature

HOURLY = "hourly"

if __name__ == "__main__":
interval = sys.argv[1]
not_working = []
query_is_working = "?is_working=False" if interval == HOURLY else ""
provider_subfeatures = requests.get(
url=f"https://api.edenai.run/v2/info/provider_subfeatures{query_is_working}"
).json()
all_providers = [
(
provider["provider"]["name"],
provider["feature"]["name"],
provider["subfeature"]["name"],
provider.get("phase", ""),
)
for provider in provider_subfeatures
]
for provider, feature, subfeature, phase in all_providers:
if phase == "create_project":
continue
try:
arguments = load_feature(
FeatureDataEnum.SAMPLES_ARGS,
feature=feature,
subfeature=subfeature,
phase=phase,
)
except NotImplementedError:
continue
try:
res = compute_output(
provider_name=provider,
feature=feature,
subfeature=subfeature,
args=arguments,
phase=phase,
)
if res["status"] == "fail":
raise Exception(res["error"])

except Exception as exc:
print(provider, feature, subfeature)
print(exc)
not_working.append((provider, feature, subfeature, exc))

print("=================================")
print("NOT WORKING PROVIDERS WITH ERRORS")
pprint(not_working)
print("=================================")

if not_working:
raise Exception

0 comments on commit f1fea02

Please sign in to comment.