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

Commit 1f7edb1

Browse files
authored
Add retry for compatibility store (#119)
1 parent 6e9f089 commit 1f7edb1

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

badge_server/badge_server.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,13 @@ def run_check():
410410
for py_ver in [2, 3]:
411411
results = list(checker.get_pairwise_compatibility(
412412
py_ver, pkg_sets))
413+
logging.warning(results)
413414
py_version = PY_VER_MAPPING[py_ver]
414415

415416
for res in results:
416-
logging.warning(res)
417-
status = res[0].get('result')
418-
package = res[0].get('packages')[1]
417+
res_item = res[0]
418+
status = res_item.get('result')
419+
package = res_item.get('packages')[1]
419420
if status != 'SUCCESS':
420421
# Ignore the package that not support for given py_ver
421422
if package in \
@@ -424,8 +425,8 @@ def run_check():
424425
continue
425426
# Status showing one of the check failures
426427
version_and_res[
427-
py_version]['status'] = res.get('result')
428-
description = res.get('description')
428+
py_version]['status'] = res_item.get('result')
429+
description = res_item.get('description')
429430
details = EMPTY_DETAILS if description is None \
430431
else description
431432
version_and_res[

compatibility_lib/compatibility_lib/compatibility_store.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import datetime
1818
import enum
1919
import itertools
20+
import retrying
2021
from typing import Any, FrozenSet, Iterable, List, Mapping, Optional
2122

2223
from google.cloud import bigquery
@@ -234,6 +235,8 @@ def get_self_compatibility(self,
234235
"""
235236
return self.get_self_compatibilities([p])[p]
236237

238+
@retrying.retry(stop_max_attempt_number=7,
239+
wait_fixed=2000)
237240
def get_self_compatibilities(self,
238241
packages: Iterable[package.Package]) -> \
239242
Mapping[package.Package, List[CompatibilityResult]]:
@@ -277,6 +280,8 @@ def get_self_compatibilities(self,
277280
return {p: self._filter_older_versions(crs)
278281
for (p, crs) in package_to_result.items()}
279282

283+
@retrying.retry(stop_max_attempt_number=7,
284+
wait_fixed=2000)
280285
def get_pair_compatibility(self, packages: List[package.Package]) -> \
281286
Iterable[CompatibilityResult]:
282287
"""Returns CompatibilityStatuses for a pair of packages.
@@ -317,6 +322,8 @@ def get_pair_compatibility(self, packages: List[package.Package]) -> \
317322
self._row_to_compatibility_status(packages, row)
318323
for row in query_job)
319324

325+
@retrying.retry(stop_max_attempt_number=7,
326+
wait_fixed=2000)
320327
def get_compatibility_combinations(self,
321328
packages: List[package.Package]) -> \
322329
Mapping[FrozenSet[package.Package], List[CompatibilityResult]]:
@@ -409,7 +416,8 @@ def save_compatibility_statuses(
409416
self._release_time_table,
410417
row)
411418

412-
419+
@retrying.retry(stop_max_attempt_number=7,
420+
wait_fixed=2000)
413421
def get_dependency_info(self, package_name):
414422
"""Returns dependency info for an indicated Google OSS package.
415423

dashboard/dashboard_builder.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
from compatibility_lib import deprecated_dep_finder
4343
from compatibility_lib import package
4444

45+
logging.basicConfig()
46+
logging.getLogger().setLevel(logging.INFO)
47+
4548
_JINJA2_ENVIRONMENT = jinja2.Environment(
4649
loader=jinja2.FileSystemLoader('.'), autoescape=jinja2.select_autoescape())
4750

@@ -338,7 +341,9 @@ def main():
338341

339342
packages = [
340343
package.Package(install_name) for install_name in args.packages]
344+
logging.info("Getting self compatibility results...")
341345
package_to_results = store.get_self_compatibilities(packages)
346+
logging.info("Getting pairwise compatibility results...")
342347
pairwise_to_results = store.get_compatibility_combinations(packages)
343348

344349
package_with_dependency_info = {}
@@ -356,15 +361,15 @@ def main():
356361
dashboard_builder = DashboardBuilder(packages, results)
357362

358363
# Build the pairwise grid dashboard
359-
logging.warning('Starting build the grid...')
364+
logging.info('Starting build the grid...')
360365
grid_html = dashboard_builder.build_dashboard(
361366
'dashboard/grid-template.html')
362367
grid_path = os.path.dirname(os.path.abspath(__file__)) + '/grid.html'
363368
with open(grid_path, 'wt') as f:
364369
f.write(grid_html)
365370

366371
# Build the dashboard main page
367-
logging.warning('Starting build the main dashboard...')
372+
logging.info('Starting build the main dashboard...')
368373
main_html = dashboard_builder.build_dashboard(
369374
'dashboard/main-template.html')
370375

0 commit comments

Comments
 (0)