-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: add RHOAI Notebooks Performance tests to the HOME page #84
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
07fbbb3
backend/backend.containerfile: make compatible with OpenShift
kpouget 299d78c
frontend/frontend.containerfile: make compatible with OpenShift
kpouget b122658
backend: include a backend for RHOAI Notebooks Performance tests
kpouget a8cf4b7
backend/app/api/v1/endpoints/cpt/cptJobs.py: do not swallow exceptions
kpouget 1cf50d8
frontend: add RHOAI Notebooks Performance to the HOME page
kpouget 010ac66
frontend/src/components/templates/HomeLayout/DisplayTableDataLayout.j…
kpouget e4a25af
WIP: backend/app/services/search.py: disable urllib warnings
kpouget a333069
WIP: backend/app/services/search.py: extend the timeout
kpouget 211e3b8
WIP: backend: app/services/search.py: add a synchronous method to cal…
kpouget 39058a5
WIP: backend: disable some modules
kpouget da978e1
WIP: frontend: add to_run command
kpouget 1948716
WIP: backend: add to_run command
kpouget a2b6f38
WIP: frontend/src/App.js do not fetch other jobs
kpouget File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,46 @@ | ||
from datetime import date | ||
import pandas as pd | ||
from app.services.search import ElasticService | ||
|
||
|
||
import asyncio | ||
import typing | ||
|
||
|
||
def return_awaited_value(coroutine: asyncio.coroutines) -> typing.Any: | ||
|
||
loop = asyncio.get_event_loop() | ||
result = loop.run_until_complete(coroutine) | ||
return result | ||
|
||
|
||
async def getData(start_datetime: date, end_datetime: date, configpath: str): | ||
query = { | ||
"timeout": "300s", | ||
"query": { | ||
"bool": { | ||
"filter": { | ||
"range": { | ||
"metadata.start": { | ||
"format": "yyyy-MM-dd" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
query['query']['bool']['filter']['range']['metadata.start']['lte'] = str(end_datetime) | ||
query['query']['bool']['filter']['range']['metadata.start']['gte'] = str(start_datetime) | ||
|
||
es = ElasticService(configpath=configpath) | ||
|
||
response = await es.post(query) | ||
await es.close() | ||
|
||
tasks = [item['_source'] for item in response["hits"]["hits"]] | ||
jobs = pd.json_normalize(tasks) | ||
|
||
if len(jobs) == 0: | ||
return jobs | ||
|
||
return jobs |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from ....commons.rhoai import getData | ||
from datetime import date | ||
|
||
|
||
################################################################ | ||
# This will return a DataFrame required by the CPT endpoint | ||
################################################################ | ||
|
||
async def rhoaiNotebooksPerformanceMapper(start_datetime: date, end_datetime: date, configpath: str): | ||
df = await getData(start_datetime, end_datetime, configpath) | ||
df.insert(len(df.columns), "product", "RHOAI Notebooks Performance") | ||
df.insert(len(df.columns), "ciSystem", "Middleware Jenkins") | ||
df.insert(len(df.columns), "releaseStream", "rc") | ||
df.insert(len(df.columns), "buildUrl", "N/A") | ||
df.insert(len(df.columns), "jobStatus", "success") | ||
|
||
if df.empty: | ||
return df | ||
|
||
df["startDate"] = df["metadata.start"] | ||
df["endDate"] = df["metadata.start"] | ||
df["uuid"] = df["metadata.start"] | ||
df["version"] = df["metadata.settings.version"].fillna("no version available") | ||
df["testName"] = df["metadata.settings.image"].fillna("no test") | ||
|
||
return df |
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,64 @@ | ||
import json | ||
from fastapi import Response | ||
from datetime import datetime, timedelta, date | ||
from fastapi import APIRouter | ||
from ...commons.rhoai import getData as rhoai_getData | ||
from ...commons.example_responses import ocp_200_response, response_422 | ||
from fastapi.param_functions import Query | ||
|
||
router = APIRouter() | ||
|
||
|
||
|
||
@router.get('/api/v1/rhoai/jobs', | ||
summary="Returns a job list", | ||
description="Returns a list of jobs in the specified dates. \ | ||
If not dates are provided the API will default the values. \ | ||
`startDate`: will be set to the day of the request minus 5 days.\ | ||
`endDate`: will be set to the day of the request.", | ||
responses={ | ||
200: ocp_200_response(), | ||
422: response_422(), | ||
},) | ||
async def jobs(start_date: date = Query(None, description="Start date for searching jobs, format: 'YYYY-MM-DD'", examples=["2020-11-10"]), | ||
end_date: date = Query(None, description="End date for searching jobs, format: 'YYYY-MM-DD'", examples=["2020-11-15"]), | ||
pretty: bool = Query(False, description="Output contet in pretty format.")): | ||
|
||
if start_date is None: | ||
start_date = datetime.utcnow().date() | ||
start_date = start_date - timedelta(days=50) | ||
|
||
if end_date is None: | ||
end_date = datetime.utcnow().date() | ||
|
||
if start_date > end_date: | ||
return Response(content=json.dumps({'error': "invalid date format, start_date must be less than end_date"}), status_code=422) | ||
|
||
results = await rhoai_getData(start_date, end_date, 'rhoai.elasticsearch') | ||
|
||
if len(results) >= 1 : | ||
response = { | ||
'startDate': start_date.__str__(), | ||
'endDate': end_date.__str__(), | ||
'results': results.to_dict('records') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only this field seems to be differing in this |
||
} | ||
else : | ||
response = { | ||
'startDate': start_date.__str__(), | ||
'endDate': end_date.__str__(), | ||
'results': [] | ||
} | ||
|
||
for result in response["results"]: | ||
result["benchmark"] = result["results.benchmark_measures.benchmark"] | ||
result["shortVersion"] = result["metadata.rhods_version"] | ||
result["platform"] = "OCP "+result["metadata.ocp_version"] | ||
result["workers"] = "1" | ||
result["ciSystem"] = "Middleware Jenkins" | ||
result["networkType"] = "default" | ||
result["jobType"] = "On demand" | ||
result["jobStatus"] = "PASS" | ||
|
||
json_str = json.dumps(response, indent=4 if pretty else None) | ||
|
||
return Response(content=json_str, media_type='application/json') |
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,8 +1,10 @@ | ||
from elasticsearch import AsyncElasticsearch | ||
from elasticsearch import AsyncElasticsearch, Elasticsearch | ||
from fastapi.encoders import jsonable_encoder | ||
|
||
from app import config | ||
|
||
import urllib3 | ||
urllib3.disable_warnings() | ||
|
||
class ElasticService: | ||
# todo add bulkhead pattern | ||
|
@@ -27,6 +29,12 @@ def __init__(self,configpath="",index=""): | |
verify_certs=False, | ||
http_auth=(self.esUser,self.esPass) | ||
) | ||
self.sync_es = Elasticsearch( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might need resolving some conflicts here. |
||
self.url, | ||
use_ssl=False, | ||
verify_certs=False, | ||
http_auth=(self.esUser,self.esPass) | ||
) | ||
else: | ||
self.es = AsyncElasticsearch(self.url, verify_certs=False) | ||
|
||
|
@@ -36,7 +44,15 @@ async def post(self, query, indice=None,size=10000): | |
return await self.es.search( | ||
index=indice, | ||
body=jsonable_encoder(query), | ||
size=size) | ||
size=size, request_timeout=60) | ||
|
||
def sync_post(self, query, indice=None,size=10000): | ||
if indice is None: | ||
indice = self.indice | ||
return self.sync_es.search( | ||
index=indice, | ||
body=jsonable_encoder(query), | ||
size=size, request_timeout=60) | ||
|
||
async def close(self): | ||
await self.es.close() |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
podman run \ | ||
--interactive \ | ||
--tty \ | ||
--volume "$PWD/app:/backend/app:z" \ | ||
--volume "$PWD/ocpperf.toml:/backend/ocpperf.toml:z" \ | ||
--publish 8000:8000 \ | ||
ocpp-back /backend/scripts/start-reload.sh |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove these
metadata.*
columns from the df once they are assigned to new columns as they are not being used further anyway?