-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENG-3777: Run Python notebooks in SDK Circle-CI
- Loading branch information
Showing
4 changed files
with
130 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,6 +45,17 @@ jobs: | |
# image: ubuntu-2204:2022.07.1 | ||
docker: | ||
- image: cimg/python:3.11.0 | ||
environment: | ||
# ENV_VAR_TENANT: $ENV_VAR_TENANT | ||
# ENV_VAR_USERNAME: $ENV_VAR_USERNAME | ||
# ENV_VAR_PASSWORD: $ENV_VAR_PASSWORD | ||
# ENV_VAR_API_KEY: $ENV_VAR_API_KEY | ||
# ENV_VAR_API_SECRET: $ENV_VAR_API_SECRET | ||
ENV_VAR_TENANT: "demo-sdk-test" | ||
ENV_VAR_USERNAME: "[email protected]" | ||
ENV_VAR_PASSWORD: "pass1234" | ||
ENV_VAR_API_KEY: "dfa170cd-ae1f-4a4d-98d2-8b7aa65d776b" | ||
ENV_VAR_API_SECRET: "sma_ZTyg2msZexRVfSlg5OczUCmzpNfh26ywW6zle0mzGBzI_" | ||
steps: | ||
# Make sure that the build doesn't accidentally pull images from Docker Hub. | ||
# Pulls from Docker Hub may fail due to rate-limiting after Nov 1 2020. | ||
|
@@ -61,8 +72,12 @@ jobs: | |
command: | | ||
set -x | ||
pip install -r requirements-codecoverage.txt | ||
echo "ENV_VAR_API_SECRET value is: ${ENV_VAR_API_SECRET}" | ||
echo "PYTHONPATH value is: ${PYTHONPATH}" | ||
pip install -e . | ||
mkdir test-results | ||
coverage run -m pytest --junitxml=test-results/junit.xml tests | ||
# coverage run -m pytest --nbmake --nbmake-timeout=3000 -n=auto --junitxml=test-results/junit.xml examples/Quick\ Start.ipynb | ||
coverage run -m pytest --nbmake --nbmake-timeout=3000 -n=auto --junitxml=test-results/junit.xml tests examples/Quick\ Start.ipynb examples/Query\ Examples.ipynb | ||
- run: | ||
name: Compile Coverage Report | ||
command: | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,8 @@ | ||
{ | ||
"metadata": { | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.7.5-final" | ||
}, | ||
"orig_nbformat": 2, | ||
"kernelspec": { | ||
"name": "python3", | ||
"display_name": "Python 3", | ||
"language": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2, | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Example: Quick Start\n", | ||
"\n", | ||
|
@@ -35,18 +15,17 @@ | |
"- Listing machines \n", | ||
"- Listing machine attributes/stats \n", | ||
"- Running a basic query" | ||
], | ||
"cell_type": "markdown", | ||
"metadata": {} | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"execution_count": 4, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from datetime import datetime \n", | ||
"from smsdk import client" | ||
"from smsdk import client\n", | ||
"import os" | ||
] | ||
}, | ||
{ | ||
|
@@ -55,8 +34,33 @@ | |
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"tenant = 'my_tenant'\n", | ||
"cli = client.Client(tenant)" | ||
"env_var_tenant = 'ENV_VAR_TENANT'\n", | ||
"env_var_username = 'ENV_VAR_USERNAME'\n", | ||
"env_var_password = 'ENV_VAR_PASSWORD'\n", | ||
"\n", | ||
"# Check if the environment variable exists\n", | ||
"if env_var_tenant in os.environ:\n", | ||
" # Retrieve the value of the environment variable\n", | ||
" tenant = os.environ[env_var_tenant]\n", | ||
"else:\n", | ||
" # Use a default value if the environment variable is not present\n", | ||
" tenant = 'my_tenant'\n", | ||
"\n", | ||
"# Check if the environment variable exists\n", | ||
"if env_var_username in os.environ:\n", | ||
" # Retrieve the value of the environment variable\n", | ||
" username = os.environ[env_var_username]\n", | ||
"else:\n", | ||
" # Use a default value if the environment variable is not present\n", | ||
" username = '[email protected]'\n", | ||
"\n", | ||
"# Check if the environment variable exists\n", | ||
"if env_var_password in os.environ:\n", | ||
" # Retrieve the value of the environment variable\n", | ||
" password = os.environ[env_var_password]\n", | ||
"else:\n", | ||
" # Use a default value if the environment variable is not present\n", | ||
" password = 'asdf%^&*1234'" | ||
] | ||
}, | ||
{ | ||
|
@@ -65,9 +69,22 @@ | |
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"username = '[email protected]'\n", | ||
"password = 'asdf%^&*1234'\n", | ||
"print(tenant)\n", | ||
"print(username)\n", | ||
"print(password)\n", | ||
"\n", | ||
"assert tenant == \"demo-sdk-test\"\n", | ||
"assert username == \"[email protected]\"\n", | ||
"assert password == \"pass1234\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"cli = client.Client(tenant)\n", | ||
"cli.login('basic', email=username, password=password)" | ||
] | ||
}, | ||
|
@@ -121,5 +138,27 @@ | |
"outputs": [], | ||
"source": [] | ||
} | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.18" | ||
}, | ||
"orig_nbformat": 2 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
# Use public repo for coverall upload | ||
|
||
codecov==2.1.13 | ||
coverage==7.3.2 | ||
coverage==7.3.2 | ||
nbmake==1.4.6 | ||
pytest-xdist==3.5.0 |