Skip to content

Commit

Permalink
test envvar works on local
Browse files Browse the repository at this point in the history
  • Loading branch information
CharleyDL committed May 2, 2024
1 parent 006f7e1 commit b4775f9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/aissyr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ jobs:
DAGSHUB_REPO: ${{ secrets.DAGSHUB_REPO }}
DAGSHUB_USER_TOKEN: ${{ secrets.DAGSHUB_USER_TOKEN }}
MODEL_URI: ${{ secrets.MODEL_URI }}
run: python -c 'import os;print(os.environ)'

# run: |
# echo "API_URL=${API_URL}" >> env
# echo "DAGSHUB_REPO_OWNER=${DAGSHUB_REPO_OWNER}" >> .env
# echo "DAGSHUB_REPO=${DAGSHUB_REPO}" >> .env
# echo "DAGSHUB_USER_TOKEN=${DAGSHUB_USER_TOKEN}" >> .env
# echo "MODEL_URI=${MODEL_URI}" >> .env
run: |
echo "API_URL=${API_URL}" >> env
echo "DAGSHUB_REPO_OWNER=${DAGSHUB_REPO_OWNER}" >> .env
echo "DAGSHUB_REPO=${DAGSHUB_REPO}" >> .env
echo "DAGSHUB_USER_TOKEN=${DAGSHUB_USER_TOKEN}" >> .env
echo "MODEL_URI=${MODEL_URI}" >> .env
- name: Run Streamlit tests
uses: streamlit/streamlit-app-action@v0.0.3
Expand Down
3 changes: 2 additions & 1 deletion tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import logging
import requests

from dagshub import auth
from dotenv import load_dotenv


load_dotenv()
logging.basicConfig(level=logging.DEBUG)

Expand All @@ -26,6 +26,7 @@ def test_load_model(self):
DAGSHUB_USER_TOKEN = os.getenv("DAGSHUB_USER_TOKEN")
MODEL_URI = os.getenv("MODEL_URI")

auth.add_app_token(token=DAGSHUB_USER_TOKEN)
dagshub.init(DAGSHUB_REPO, DAGSHUB_REPO_OWNER, mlflow=True)

model = mlflow.pyfunc.load_model(MODEL_URI)
Expand Down
12 changes: 5 additions & 7 deletions tests/test_required_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ def test_file_exists(self):
class TestEnvVar:

def test_get_envvar(self):
assert os.getenv('API_URL') is not None, "API_URL is not defined"
assert os.getenv('DAGSHUB_REPO_OWNER') is not None, "DAGSHUB_REPO_OWNER is not defined"
assert os.getenv('DAGSHUB_REPO') is not None, "DAGSHUB_REPO is not defined"
assert os.getenv('DAGSHUB_USER_TOKEN') is not None, "DAGSHUB_USER_TOKEN is not defined"
assert os.getenv('MODEL_URI') is not None, "MODEL_URI is not defined"

print(os.getenv('API_URL'))
assert os.environ['API_URL'] is not None, "API_URL is not defined"
assert os.environ['DAGSHUB_REPO_OWNER'] is not None, "DAGSHUB_REPO_OWNER is not defined"
assert os.environ['DAGSHUB_REPO'] is not None, "DAGSHUB_REPO is not defined"
assert os.environ['DAGSHUB_USER_TOKEN'] is not None, "DAGSHUB_USER_TOKEN is not defined"
assert os.environ['MODEL_URI'] is not None, "MODEL_URI is not defined"

0 comments on commit b4775f9

Please sign in to comment.