Skip to content

Commit

Permalink
Update test.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Smartappli authored Jan 26, 2024
1 parent 831c4b7 commit 045d819
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
import os
import json
from pathlib import Path
import requests
from huggingface_hub import hf_hub_url
import pytest

paths=['all/models.json']

def load_model_data(file_path):
with open(file_path, "r") as models_file:
return json.load(models_file)


def flatten_model_data(families):
for family in families:
for model in family["models"]:
for file in model["files"]:
yield model["repo"], file["filename"]


def check_model_availability(repo, filename):
url = hf_hub_url(repo, filename, repo_type="model", revision="main")
response = requests.head(url)
if response.ok:
return True
else:
return False


model_data = os.path.join(os.getcwd(), 'tiny/models.json')
print(model_data)
checks = list(flatten_model_data(model_data))


@pytest.mark.parametrize("repo,filename", checks)
def test_model_available(repo, filename):
assert check_model_availability(repo, filename), f"Model {repo}/{filename} not available"
name: LLM Healthcheck

on:
push:
branches:
- "main"
paths-ignore:
- "**.md"
pull_request:
branches:
- "*"
paths-ignore:
- "**.md"
workflow_dispatch:
release:
types: [published, edited]
schedule:
- cron: '0 0 * * *'

jobs:
model-health-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
working-directory: ./
run: |
pip install --upgrade pip
pip install pytest
pip install huggingface_hub
pip install pathlib
- name: Run model health check
working-directory: ./
run: |
python -m pytest -v --color=yes test.py

0 comments on commit 045d819

Please sign in to comment.