Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kimpaller committed Jul 30, 2024
1 parent fd690ea commit 10e3221
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 152 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,25 @@ virtual environment of constellation
--> Constellation setup <--
(Recommended: Run to vm)
1. Create owner folder or go to your preferred folder in your linux server.
mkrdir <owner_folder> or cd <owner_folder>
mkrdir <owner_folder> or cd <owner_folder>
2. Clone Constellation and Telemetry
git clone https://github.com/sdgtt/constellation.git
git clone https://github.com/sdgtt/telemetry.git
3. Create virtual environment, to create type this to your terminal:
python3 -m virtualenv <env_folder_name>
4. Go to Telemetry cloned folder and install requirements
cd telemetry/
pip install -r requirements.txt
pip install -r requirements.txt
pip install -r requirements_dev.txt
cd ..
5. Run or activate your virtualenv
source envConstellation/bin/activate

6. Go to Constellation cloned folder and install requirements
pip install telemetry
pip install -r requirements.txt
pip install -r requirements.txt
pip install -r requirements_dev.txt
7. Once installed, run the in development mode.
export FLASK_ENV=development
export ES=192.168.10.12
flask run --host=0.0.0.0 --port=5002


22 changes: 16 additions & 6 deletions app/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from urllib.parse import unquote, urlparse

from app.models import boards as b
Expand All @@ -7,7 +8,13 @@
from app.pages.hwtests import allboards as ab
from app.pages.publicci.dashboard import Dashboard
from app.pages.pyadi.plots import gen_line_plot_html
from app.utility import artifact_url_gen, filter_gen, url_gen, result_json_url, append_url_to_dict
from app.utility import (
append_url_to_dict,
artifact_url_gen,
filter_gen,
result_json_url,
url_gen,
)
from flask import (
Blueprint,
Flask,
Expand All @@ -20,14 +27,15 @@
url_for,
)
from flask.helpers import get_root_path
import os

# from junit2htmlreport import parser

# app = Flask(__name__)
server_bp = Blueprint("constellation", __name__)

JENKINS_SERVER = "jenkinsci" if "JENKINS_SERVER" not in os.environ else os.environ["JENKINS_SERVER"]
JENKINS_SERVER = (
"jenkinsci" if "JENKINS_SERVER" not in os.environ else os.environ["JENKINS_SERVER"]
)
JENKINS_PORT = None

pci_dash = Dashboard(
Expand Down Expand Up @@ -97,7 +105,9 @@ def board_api(board_name, param=None):
for k, v in boot_test.items():
if k not in ["boot_test_failure", "raw_boot_test_result"]:
new_dict.update({k: v})
boot_test_filtered.append(append_url_to_dict(new_dict, jenkins_url=JENKINS_SERVER))
boot_test_filtered.append(
append_url_to_dict(new_dict, jenkins_url=JENKINS_SERVER)
)
return {"hits": boot_test_filtered}


Expand All @@ -107,7 +117,7 @@ def score_api(param=None):
default_jenkins_project = "HW_tests/HW_test_multiconfig"
default_branch = ""
default_size = 7
default_offset = 0
default_offset = 0
filters = filter_gen(urlparse(unquote(request.url)).query)
jenkins_project = (
filters["jenkins_project"][0]
Expand All @@ -125,7 +135,7 @@ def score_api(param=None):
branch=branch,
board=board,
deprecated=deprecated,
offset = int(offset)
offset=int(offset),
)
return sc.to_json()

Expand Down
4 changes: 2 additions & 2 deletions app/models/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Artifact:
"job_build_parameters",
"file_name",
"target_board",
"artifact_info_type"
"artifact_info_type",
]

def __init__(self, raw_artifact_result=None):
Expand Down Expand Up @@ -48,7 +48,7 @@ def display(self):
class Artifacts:
def __init__(self, **filters):

self.db = DB(index_name="artifacts",keywords=Artifact.KEYWORDS)
self.db = DB(index_name="artifacts", keywords=Artifact.KEYWORDS)
db_res = self.db.search(sort="archive_date", **filters)
# create boards object from raw db_res
self._artifacts = [Artifact(row) for row in db_res["hits"]]
Expand Down
1 change: 0 additions & 1 deletion app/models/boot_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ def latest_builds(self, size, offset=0):
}
)
return builds_dict


def latest_builds_boards(self, size, offset=0):
boards = []
Expand Down
20 changes: 13 additions & 7 deletions app/models/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
"last_failing_stage",
]


class DB:
def __init__(
self,
elastic_server=ELASTIC_SERVER,
username=USERNAME,
password=PASSWORD,
index_name=INDEX,
keywords=KEYWORDS
keywords=KEYWORDS,
):
retries = 0
while True:
Expand All @@ -42,7 +43,7 @@ def __init__(
password=password,
index_name=index_name,
)
self.keywords=keywords
self.keywords = keywords
break
except Exception as e:
print("Server not yet ready")
Expand All @@ -57,7 +58,7 @@ def search(
sort="jenkins_job_date",
order="desc",
agg_field=None,
**kwargs
**kwargs,
):
result = {"hits": [], "aggregates": [], "aggregates_top": []}
if kwargs:
Expand Down Expand Up @@ -85,11 +86,15 @@ def search(
if agg_field:
for row in res["aggregations"][agg_field]["buckets"]:
result["aggregates"].append(row["key"])

agg_field_data = {}
# get top data for the aggregated field
for row_data in result["hits"]:
agg_field = agg_field.split(".keyword")[0] if "keyword" in agg_field else agg_field
agg_field = (
agg_field.split(".keyword")[0]
if "keyword" in agg_field
else agg_field
)
if row_data[agg_field] == row["key"]:
agg_field_data = row_data
break
Expand All @@ -114,11 +119,12 @@ def test_db_search():
elastic_server="primary.englab",
username="",
password="",
index_name="boot_tests"
index_name="boot_tests",
)
result = db.search(
size=1,
sort="jenkins_job_date",
order="desc",
agg_field="boot_folder_name.keyword",
)
)
assert result
6 changes: 4 additions & 2 deletions app/models/score.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ def get_test_results(self): # noqa: C901
]:
if isinstance(report[bn][test]["data"], list):
try:
assert report[bn][test]["count"] == len(report[bn][test]["data"])
assert report[bn][test]["count"] == len(
report[bn][test]["data"]
)
except Exception as e:
print(f"Inconsistency in build {bn} on test {test}")
print(report[bn][test])
Expand All @@ -210,7 +212,7 @@ def get_test_results(self): # noqa: C901
for k, boards in report[bn][test]["data"].items():
for board in boards:
count += 1
try:
try:
assert report[bn][test]["count"] == count
except Exception as e:
print(f"Inconsistency in build {bn} on test {test}")
Expand Down
Loading

0 comments on commit 10e3221

Please sign in to comment.