-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dhub): added more accurate tests for the platform, fixed dashboa…
…rd pod restart
- Loading branch information
1 parent
30cda71
commit fb6f5b4
Showing
11 changed files
with
231 additions
and
17 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
cp home/src/$TEST_SCRIPT home/git/digitalhub-tutorials/$TEST_FOLDER/$TEST_SCRIPT | ||
cd home/git/digitalhub-tutorials/$TEST_FOLDER | ||
pip install --cache-dir home/pipcache digitalhub[full] digitalhub-runtime-python digitalhub-runtime-container digitalhub-runtime-dbt digitalhub-runtime-kfp digitalhub-runtime-modelserve requests-oauthlib | ||
python $TEST_SCRIPT |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import sys | ||
import digitalhub as dh | ||
from time import time, sleep | ||
import os | ||
from oauthlib.oauth2 import BackendApplicationClient | ||
from requests_oauthlib import OAuth2Session | ||
|
||
|
||
def poller(run): | ||
|
||
start = time() | ||
max_time = 15 * 60 # 15 minutes | ||
|
||
while True: | ||
|
||
if (time() - start) > max_time: | ||
raise Exception(f"Timed out waiting: run status is {run.status.state}") | ||
|
||
run.refresh() | ||
|
||
if run.status.state == "ERROR": | ||
raise Exception(f"Something got wrong with run: {run.status.state} - {run.status.message}") | ||
|
||
if run.status.state == "COMPLETED": | ||
print("Run finished.") | ||
sys.exit(0) | ||
|
||
if run.status.state == "STOPPED": | ||
print("Run stopped.") | ||
sys.exit(1) | ||
|
||
sleep(5) | ||
|
||
|
||
def main(): | ||
if "CORE_CLIENT_ID" in os.environ: | ||
# Get Core Token | ||
client_id = os.getenv("CORE_CLIENT_ID") | ||
client_secret = os.getenv("CORE_CLIENT_SECRET") | ||
scope = 'tenant1-core' | ||
client = BackendApplicationClient(client_id=client_id) | ||
oauth = OAuth2Session(client=client, scope=scope) | ||
token = oauth.fetch_token(token_url='https://core.tenant1.digitalhub-dev.smartcommunitylab.it/auth/token', client_id=client_id, client_secret=client_secret, scope=scope) | ||
os.environ["DHCORE_ACCESS_TOKEN"] = token["access_token"] | ||
|
||
# Load project | ||
proj = dh.import_project("project-etl-ci.yml") | ||
|
||
URL = "https://opendata.comune.bologna.it/api/explore/v2.1/catalog/datasets/rilevazione-flusso-veicoli-tramite-spire-anno-2023/exports/csv?lang=it&timezone=Europe%2FRome&use_labels=true&delimiter=%3B" | ||
di= proj.new_dataitem(name="url_data_item",kind="table",path=URL) | ||
workflow_run = proj.run('pipeline', parameters={"url": di.key}) | ||
|
||
# Wait for run to finish | ||
poller(workflow_run) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import sys | ||
import digitalhub as dh | ||
from time import time, sleep | ||
import os | ||
from oauthlib.oauth2 import BackendApplicationClient | ||
from requests_oauthlib import OAuth2Session | ||
|
||
|
||
def poller(run): | ||
|
||
start = time() | ||
max_time = 15 * 60 # 15 minutes | ||
|
||
while True: | ||
|
||
if (time() - start) > max_time: | ||
raise Exception(f"Timed out waiting: run status is {run.status.state}") | ||
|
||
run.refresh() | ||
|
||
if run.status.state == "ERROR": | ||
raise Exception(f"Something got wrong with run: {run.status.state} - {run.status.message}") | ||
|
||
if run.status.state == "COMPLETED": | ||
print("Run finished.") | ||
sys.exit(0) | ||
|
||
if run.status.state == "STOPPED": | ||
print("Run stopped.") | ||
sys.exit(1) | ||
|
||
sleep(5) | ||
|
||
|
||
def main(): | ||
if "CORE_CLIENT_ID" in os.environ: | ||
# Get Core Token | ||
client_id = os.getenv("CORE_CLIENT_ID") | ||
client_secret = os.getenv("CORE_CLIENT_SECRET") | ||
scope = 'tenant1-core' | ||
client = BackendApplicationClient(client_id=client_id) | ||
oauth = OAuth2Session(client=client, scope=scope) | ||
token = oauth.fetch_token(token_url='https://core.tenant1.digitalhub-dev.smartcommunitylab.it/auth/token', client_id=client_id, client_secret=client_secret, scope=scope) | ||
os.environ["DHCORE_ACCESS_TOKEN"] = token["access_token"] | ||
|
||
# Load project | ||
proj = dh.import_project("project-dbt-ci.yml") | ||
|
||
url = "https://gist.githubusercontent.com/kevin336/acbb2271e66c10a5b73aacf82ca82784/raw/e38afe62e088394d61ed30884dd50a6826eee0a8/employees.csv" | ||
di_url = proj.new_dataitem(name="url_data_item",kind="table",path=url) | ||
workflow_run = proj.run('pipeline_dbt', parameters={"url": di_url.key}) | ||
|
||
# Wait for run to finish | ||
poller(workflow_run) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
56 changes: 56 additions & 0 deletions
56
charts/digitalhub/confs/tests/python-test/s3-scikit-learn.py
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import sys | ||
import digitalhub as dh | ||
from time import time, sleep | ||
import os | ||
from oauthlib.oauth2 import BackendApplicationClient | ||
from requests_oauthlib import OAuth2Session | ||
|
||
|
||
def poller(run): | ||
|
||
start = time() | ||
max_time = 15 * 60 # 15 minutes | ||
|
||
while True: | ||
|
||
if (time() - start) > max_time: | ||
raise Exception(f"Timed out waiting: run status is {run.status.state}") | ||
|
||
run.refresh() | ||
|
||
if run.status.state == "ERROR": | ||
raise Exception(f"Something got wrong with run: {run.status.state} - {run.status.message}") | ||
|
||
if run.status.state == "COMPLETED": | ||
print("Run finished.") | ||
sys.exit(0) | ||
|
||
if run.status.state == "STOPPED": | ||
print("Run stopped.") | ||
sys.exit(1) | ||
|
||
sleep(5) | ||
|
||
|
||
def main(): | ||
if "CORE_CLIENT_ID" in os.environ: | ||
# Get Core Token | ||
client_id = os.getenv("CORE_CLIENT_ID") | ||
client_secret = os.getenv("CORE_CLIENT_SECRET") | ||
scope = 'tenant1-core' | ||
client = BackendApplicationClient(client_id=client_id) | ||
oauth = OAuth2Session(client=client, scope=scope) | ||
token = oauth.fetch_token(token_url='https://core.tenant1.digitalhub-dev.smartcommunitylab.it/auth/token', client_id=client_id, client_secret=client_secret, scope=scope) | ||
os.environ["DHCORE_ACCESS_TOKEN"] = token["access_token"] | ||
|
||
# Load project | ||
proj = dh.import_project("project-ml-ci.yml") | ||
|
||
workflow_run = proj.run('pipeline_ml') | ||
|
||
# Wait for run to finish | ||
poller(workflow_run) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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
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
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