Spaces:
Sleeping
Sleeping
Download .github/workflows/ci.yml from NeuroCheckAI/neurocheck: direct link, hf CLI and curl.
- Browser
- Download file 5.03 kB
-
https://huggingface.co/spaces/NeuroCheckAI/neurocheck/resolve/main/.github/workflows/ci.yml
- Command line
-
hf download hf://spaces/NeuroCheckAI/neurocheck/.github/workflows/ci.yml
-
curl -L -o ci.yml https://huggingface.co/spaces/NeuroCheckAI/neurocheck/resolve/main/.github/workflows/ci.yml
5.03 kB
| name: NeuroCheck CI/CD | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| # ββ Test ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| test: | |
| name: Run API Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| - name: Install dependencies | |
| run: pip install -r requirements.txt | |
| - name: Build spaCy model | |
| run: | | |
| python3 -c " | |
| import spacy | |
| from spacy.lang.en import English | |
| nlp = English() | |
| nlp.add_pipe('sentencizer') | |
| nlp.to_disk('en_model') | |
| print('Model built') | |
| " | |
| - name: Start server and run tests | |
| run: | | |
| SPACY_MODEL=en_model python3 -m uvicorn api.main:app \ | |
| --host 127.0.0.1 --port 8000 --log-level error & | |
| sleep 5 | |
| python3 -c " | |
| import urllib.request, json, sys, time | |
| def classify(text): | |
| data = json.dumps({'text': text}).encode() | |
| req = urllib.request.Request( | |
| 'http://127.0.0.1:8000/classify', data=data, | |
| headers={'Content-Type': 'application/json'}) | |
| with urllib.request.urlopen(req, timeout=10) as r: | |
| return json.loads(r.read()) | |
| tests = [ | |
| ('Optic Neuritis', 'HIGH', 'Left eye dimming like dirty water. Colors washed out. Pain when moving my eye.'), | |
| ('Lhermitte Sign', 'HIGH', 'Sharp electric shock runs down spine when I bend my neck forward.'), | |
| ('Diplopia', 'HIGH', 'Woke up seeing double. Eyes feel jiggly. Poor balance.'), | |
| ('MS Hug', 'HIGH', 'Tight squeezing pressure around my midsection like a corset pulled too tight.'), | |
| ('Emergency Stroke', 'CRITICAL_EMERGENCY', 'Sudden face droop and arm weakness on the left side.'), | |
| ('WATCH tier', 'WATCH', 'Restless legs every night. Symptoms worse in hot weather. Ringing in both ears.'), | |
| ('Area Postrema', 'HIGH', 'Vision loss plus hiccups and vomiting.'), | |
| ('Uhthoff', 'HIGH', 'Vision shimmers after hot shower. Symptoms worse in heat.'), | |
| ('Vertigo Falls', 'HIGH', 'Constant vertigo and increasingly frequent falls over 6 weeks.'), | |
| ] | |
| passed = 0 | |
| for name, expected, text in tests: | |
| r = classify(text) | |
| got = r['tier'] | |
| ok = got == expected | |
| if ok: passed += 1 | |
| status = 'PASS' if ok else 'FAIL' | |
| print(f' [{status}] {name}: expected={expected} got={got}') | |
| print(f'\n {passed}/{len(tests)} tests passed') | |
| if passed < len(tests): | |
| sys.exit(1) | |
| " | |
| # ββ Docker Build ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| docker: | |
| name: Build Docker Image | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| # Remove this step if you are not pushing to Docker Hub | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKERHUB_USERNAME }}/neurocheck:latest | |
| ${{ secrets.DOCKERHUB_USERNAME }}/neurocheck:${{ github.sha }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| # ββ Deploy to Render ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Uncomment and add RENDER_API_KEY + RENDER_SERVICE_ID secrets to enable. | |
| # | |
| # deploy-render: | |
| # name: Deploy to Render | |
| # runs-on: ubuntu-latest | |
| # needs: [test, docker] | |
| # if: github.ref == 'refs/heads/main' | |
| # steps: | |
| # - name: Trigger Render deploy | |
| # run: | | |
| # curl -X POST \ | |
| # "https://api.render.com/v1/services/${{ secrets.RENDER_SERVICE_ID }}/deploys" \ | |
| # -H "Authorization: Bearer ${{ secrets.RENDER_API_KEY }}" \ | |
| # -H "Content-Type: application/json" \ | |
| # -d '{"clearCache": false}' | |