Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit 15d2f1b

Browse files
authored
Merge pull request #60 from liyanhui1228/grid-fix2
Do not show python version incompatible results in dashboard
2 parents ad6617e + c4938a3 commit 15d2f1b

File tree

4 files changed

+62
-9
lines changed

4 files changed

+62
-9
lines changed

badge_server/badge_server.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@
100100
}
101101
}
102102

103-
PKG_PY_VERSION_NOT_SUPPORTED = {
104-
2: ['tensorflow', ],
105-
3: ['google-cloud-dataflow', ],
106-
}
107-
108103
SVG_CONTENT_TYPE = 'image/svg+xml'
109104

110105
EMPTY_DETAILS = 'NO DETAILS'
@@ -145,7 +140,7 @@ def _get_badge_url(version_and_res, package_name):
145140
package_name = package_name.replace('-', '.')
146141
status = version_and_res['py3']['status']
147142
if status != 'SUCCESS' and \
148-
package_name not in PKG_PY_VERSION_NOT_SUPPORTED.get(2):
143+
package_name not in configs.PKG_PY_VERSION_NOT_SUPPORTED.get(2):
149144
status = version_and_res['py2']['status']
150145

151146
color = STATUS_COLOR_MAPPING[status]
@@ -284,7 +279,8 @@ def run_check():
284279
status = res.get('result')
285280
if status != 'SUCCESS':
286281
# Ignore the package that not support for given py_ver
287-
if pkg_set[1] in PKG_PY_VERSION_NOT_SUPPORTED.get(
282+
if pkg_set[1] in \
283+
configs.PKG_PY_VERSION_NOT_SUPPORTED.get(
288284
py_ver):
289285
continue
290286
# Status showing one of the check failures

compatibility_lib/compatibility_lib/configs.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,8 @@
5656
'tensorflow',
5757
'gcloud',
5858
]
59+
60+
PKG_PY_VERSION_NOT_SUPPORTED = {
61+
2: ['tensorflow', ],
62+
3: ['google-cloud-dataflow', ],
63+
}

grid_builder.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ def __init__(self, package_to_results, pairwise_to_results):
4949
self._package_to_results = package_to_results
5050
self._pairwise_to_results = pairwise_to_results
5151

52+
def _is_py_version_incompatible(self, result):
53+
if result.status == compatibility_store.Status.INSTALL_ERROR:
54+
for version in [2, 3]:
55+
for pkg in result.packages:
56+
major_version = result.python_major_version
57+
name = pkg.install_name
58+
unsupported = configs.PKG_PY_VERSION_NOT_SUPPORTED[version]
59+
60+
if major_version == version and name in unsupported:
61+
return True
62+
return False
63+
64+
5265
def get_result(self,
5366
package_1: package.Package,
5467
package_2: package.Package) -> Mapping[str, str]:
@@ -83,7 +96,8 @@ def get_result(self,
8396
self._package_to_results[package_2])
8497

8598
for pr in package_results:
86-
if pr.status != compatibility_store.Status.SUCCESS:
99+
if not self._is_py_version_incompatible(pr) and \
100+
pr.status != compatibility_store.Status.SUCCESS:
87101
return {
88102
'status': pr.status.value,
89103
'self': True,
@@ -104,7 +118,8 @@ def get_result(self,
104118
'self': False,
105119
}
106120
for pr in pairwise_results:
107-
if pr.status != compatibility_store.Status.SUCCESS:
121+
if not self._is_py_version_incompatible(pr) and \
122+
pr.status != compatibility_store.Status.SUCCESS:
108123
return {
109124
'status': pr.status.value,
110125
'self': False,

test_grid_builder.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"""Tests for grid_builder."""
1616

17+
import mock
1718
import unittest
1819

1920
from compatibility_lib import compatibility_store
@@ -24,6 +25,7 @@
2425

2526
PACKAGE_1 = package.Package("package1")
2627
PACKAGE_2 = package.Package("package2")
28+
PACKAGE_3 = package.Package("package3")
2729

2830

2931
class TestResultHolder(unittest.TestCase):
@@ -250,3 +252,38 @@ def test_pairwise_failure(self):
250252
grid = grid_builder.GridBuilder(store)
251253
html_grid = grid.build_grid([PACKAGE_1, PACKAGE_2])
252254
self.assertIn("Installation failure", html_grid)
255+
256+
def test_not_show_py_ver_incompatible_results(self):
257+
"""CompatibilityResult failure between pair of packages. Do not display
258+
the packages that are incompatible with a specific Python version.
259+
"""
260+
store = fake_compatibility_store.CompatibilityStore()
261+
store.save_compatibility_statuses([
262+
compatibility_store.CompatibilityResult(
263+
packages=[PACKAGE_1],
264+
python_major_version=3,
265+
status=compatibility_store.Status.SUCCESS
266+
),
267+
compatibility_store.CompatibilityResult(
268+
packages=[PACKAGE_3],
269+
python_major_version=3,
270+
status=compatibility_store.Status.INSTALL_ERROR
271+
),
272+
compatibility_store.CompatibilityResult(
273+
packages=[PACKAGE_1, PACKAGE_3],
274+
python_major_version=3,
275+
status=compatibility_store.Status.INSTALL_ERROR,
276+
details="Installation failure"
277+
),
278+
])
279+
patch = mock.patch(
280+
'compatibility_lib.configs.PKG_PY_VERSION_NOT_SUPPORTED', {
281+
2: ['package4'],
282+
3: ['package3'],
283+
})
284+
285+
with patch:
286+
grid = grid_builder.GridBuilder(store)
287+
html_grid = grid.build_grid([PACKAGE_1, PACKAGE_2])
288+
289+
self.assertNotIn("Installation failure", html_grid)

0 commit comments

Comments
 (0)