Sadeep Sachintha commited on
Commit
5dced34
·
1 Parent(s): eafecbb

Fix HF authentication for model loading during tests

Browse files
Files changed (2) hide show
  1. .github/workflows/deploy.yml +2 -0
  2. app/model.py +7 -0
.github/workflows/deploy.yml CHANGED
@@ -21,6 +21,8 @@ jobs:
21
  pip install -r requirements.txt
22
 
23
  - name: Run Tests
 
 
24
  run: |
25
  PYTHONPATH=. pytest tests/
26
 
 
21
  pip install -r requirements.txt
22
 
23
  - name: Run Tests
24
+ env:
25
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
26
  run: |
27
  PYTHONPATH=. pytest tests/
28
 
app/model.py CHANGED
@@ -1,8 +1,15 @@
1
  from transformers import pipeline
 
2
  import logging
 
3
 
4
  logger = logging.getLogger(__name__)
5
 
 
 
 
 
 
6
  # Using a robust Sinhala sentiment analysis model from Hugging Face
7
  MODEL_NAME = "keshan/sinhala-sentiment-analysis"
8
  sentiment_pipeline = None
 
1
  from transformers import pipeline
2
+ from huggingface_hub import login
3
  import logging
4
+ import os
5
 
6
  logger = logging.getLogger(__name__)
7
 
8
+ # Login with token if available
9
+ hf_token = os.environ.get("HF_TOKEN")
10
+ if hf_token:
11
+ login(token=hf_token)
12
+
13
  # Using a robust Sinhala sentiment analysis model from Hugging Face
14
  MODEL_NAME = "keshan/sinhala-sentiment-analysis"
15
  sentiment_pipeline = None