Skip to content

Commit edb3632

Browse files
authored
Add flake8 lint checking (#253)
The CI will now fail if `flake8` lint checking fails. A number of minor changes have been made to remove unused imports and break excessively long lines. (Flake8's tolerance is less generous than black's.) Several unused variable have been removed, including a `version` from the Quay graphs `getMatchRuns` ... the file history shows this was initially used in the query string, but it was removed and (probably inadvertently) restored (without the associated query phrase) by REVAMP. The other main unused variable is "data" in the `ingress-performance` case of the OCP graph API. This code has always been unimplemented; instead of attempting to resolve that here, I've created issue #252.
1 parent 5a26637 commit edb3632

File tree

28 files changed

+76
-73
lines changed

28 files changed

+76
-73
lines changed

.github/workflows/backend-check.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ jobs:
3232
cd backend
3333
tox -e format,isort
3434
- name: Check for lint
35-
# Report errors but don't fail until we achieve stability!
36-
continue-on-error: true
3735
run: |
3836
cd backend
3937
tox -e lint

backend/.flake8

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[flake8]
2+
ignore = E203,E226,W503,E704
3+
4+
# Black tries to limit lines to 88 characters: keep flake8 from complaining
5+
# as long as we're below 100.
6+
max-line-length = 100

backend/app/api/v1/commons/constants.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,12 @@
168168

169169
SPLUNK_SEMAPHORE_COUNT = 5 # Arbitrary concurrency limit in an asyncio semaphore
170170

171-
# These products don't need to be included in the filter dict when applying filters on the Home tab,
172-
# as the filtering function will automatically handle them using the corresponding product-to-mapper lookup.
171+
# These products don't need to be included in the filter dict when applying
172+
# filters on the Home tab, as the filtering function will automatically handle
173+
# them using the corresponding product-to-mapper lookup.
173174
STANDOUT_PRODUCTS = ["ocp", "telco", "quay"]
174175
# These products aren't listed by their exact names like "hce" and "ocm",
175-
# but instead represent grouped categories such as "Developer", "Insights", etc.
176+
# but instead represent grouped categories such as "Developer" or "Insights".
176177
GENERAL_PRODUCTS = ["hce", "ocm"]
177178
TELCO_STATUS_MAP = {"success": "passed", "failed": "failed", "failure": "failure"}
178179

backend/app/api/v1/commons/example_responses.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,11 @@ def response_422():
170170
"networkType": "OVNKubernetes",
171171
"buildTag": "1886955825944072192",
172172
"jobStatus": "success",
173-
"buildUrl": "https://prow.ci.openshift.org/view/gs/test-platform-results/pr-logs/pull/openshift_release/60981/rehearse-60981-periodic-ci-openshift-ols-load-generator-main-ols-load-test-100workers/1886955825944072192",
174-
"upstreamJob": "rehearse-60981-periodic-ci-openshift-ols-load-generator-main-ols-load-test-100workers",
173+
"buildUrl": "https://prow.ci.openshift.org/view/gs/test-platform-results/pr-logs/"
174+
"pull/openshift_release/60981/rehearse-60981-periodic-ci-openshift-ols-"
175+
"load-generator-main-ols-load-test-100workers/1886955825944072192",
176+
"upstreamJob": "rehearse-60981-periodic-ci-openshift-ols-load-generator-main-"
177+
"ols-load-test-100workers",
175178
"upstreamJobBuild": "778dd992-8353-4cec-9807-7343290267f8",
176179
"executionDate": "2025-02-05T03:19:50Z",
177180
"jobDuration": "3396",

backend/app/api/v1/commons/hce.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import date, datetime
1+
from datetime import date
22

33
import pandas as pd
44

backend/app/api/v1/commons/telco.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import app.api.v1.commons.constants as constants
77
import app.api.v1.commons.hasher as hasher
88
import app.api.v1.commons.utils as utils
9-
import app.api.v1.endpoints.telco.telcoGraphs as telcoGraphs
109
from app.services.splunk import SplunkService
1110

1211

@@ -96,12 +95,6 @@ async def getFilterData(
9695
start_datetime: date, end_datetime: date, filter: str, configpath: str
9796
):
9897

99-
cfg = config.get_config()
100-
try:
101-
jenkins_url = cfg.get("telco.config.job_url")
102-
except Exception as e:
103-
print(f"Error reading telco configuration: {e}")
104-
10598
query = {
10699
"earliest_time": "{}T00:00:00".format(start_datetime.strftime("%Y-%m-%d")),
107100
"latest_time": "{}T23:59:59".format(end_datetime.strftime("%Y-%m-%d")),

backend/app/api/v1/commons/utils.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,15 @@ def update_filter_product(filter):
246246
filter_dict = get_dict_from_qs(filter) if filter else {}
247247
filter_product = filter_dict.pop("product", None)
248248

249-
# The product filter dropdown includes options like "ocp", "telco", "quay", "Developer", "Insights", etc.
249+
# The product filter dropdown includes options like "ocp", "telco", "quay",
250+
# "Developer", "Insights", etc
251+
#
250252
# Among these, "ocp", "quay", and "telco" are considered STANDOUT_PRODUCTS.
251253
# These standout products are handled through a product-to-mapper lookup,
252-
# so they do NOT need to be included in the filter_dict explicitly.
253-
# The remaining products (like "Developer", "Insights", etc.) must be filtered using "hce" and "ocm" mappers,
254-
# so they are retained in the filter_dict for backend filtering.
254+
# so they do NOT need to be included in the filter_dict explicitly. The
255+
# remaining products (like "Developer", "Insights", etc.) must be filtered
256+
# using "hce" and "ocm" mappers, so they are retained in the filter_dict
257+
# for backend filtering.
255258

256259
if filter_product:
257260
matched = [p for p in filter_product if p in constants.STANDOUT_PRODUCTS]

backend/app/api/v1/endpoints/cpt/cptJobs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import asyncio
22
from datetime import date, datetime, timedelta
33
import json
4-
from multiprocessing import cpu_count
54
import traceback
65
from urllib.parse import urlencode
76

backend/app/api/v1/endpoints/cpt/maps/hce.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from datetime import date
2-
import traceback
32
from urllib.parse import urlencode
43

54
import pandas as pd
@@ -35,7 +34,7 @@ async def hceMapper(
3534
updated_filter = await get_updated_filter(filter)
3635

3736
response = await getData(
38-
start_datetime, end_datetime, size, offset, updated_filter, f"hce.elasticsearch"
37+
start_datetime, end_datetime, size, offset, updated_filter, "hce.elasticsearch"
3938
)
4039

4140
if isinstance(response, pd.DataFrame) or not response:
@@ -79,7 +78,7 @@ async def hceFilter(start_datetime: date, end_datetime: date, filter: str):
7978
updated_filter = await get_updated_filter(filter)
8079

8180
response = await getFilterData(
82-
start_datetime, end_datetime, updated_filter, f"hce.elasticsearch"
81+
start_datetime, end_datetime, updated_filter, "hce.elasticsearch"
8382
)
8483

8584
if isinstance(response, pd.DataFrame) or not response:

backend/app/api/v1/endpoints/cpt/maps/ocm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async def ocmMapper(
2424
updated_filter = await get_updated_filter(filter)
2525

2626
response = await getData(
27-
start_datetime, end_datetime, size, offset, filter, f"ocm.elasticsearch"
27+
start_datetime, end_datetime, size, offset, updated_filter, "ocm.elasticsearch"
2828
)
2929
if isinstance(response, pd.DataFrame) or not response:
3030
df = response["data"]
@@ -53,7 +53,7 @@ async def ocmFilter(start_datetime: date, end_datetime: date, filter: str):
5353
updated_filter = await get_updated_filter(filter)
5454

5555
response = await getFilterData(
56-
start_datetime, end_datetime, updated_filter, f"ocm.elasticsearch"
56+
start_datetime, end_datetime, updated_filter, "ocm.elasticsearch"
5757
)
5858
if isinstance(response, pd.DataFrame) or not response:
5959
return {"total": 0, "filterData": [], "summary": {}}

0 commit comments

Comments
 (0)