Skip to content

Commit 18f988d

Browse files
authored
feat: Bulk build failure wiki (#948)
In order to have a `bulk` branch-specific Build Failures wiki page, need to allow for a git range to be specified for which recipes will be included. This uses the same method of determining whether a recipe is included as the build command. (i.e., it's not diffing the build failure files between branches.) Also added handling for recipes that exist but have no corresponding package in the channel. That avoids errors from new Bioconductor recipes during a bulk update.
1 parent 8255afd commit 18f988d

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

bioconda_utils/build_failure.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import time
34
from typing import Optional, Union
45
import subprocess as sp
@@ -13,6 +14,8 @@
1314
import pandas as pd
1415
import networkx as nx
1516

17+
from .githandler import BiocondaRepo
18+
1619
from bioconda_utils.recipe import Recipe
1720
from bioconda_utils import graph, utils
1821
from bioconda_utils.githandler import GitHandler
@@ -179,7 +182,7 @@ def category(self, value):
179182
self.inner["category"] = value
180183

181184

182-
def collect_build_failure_dataframe(recipe_folder, config, channel, link_fmt="txt", link_prefix=""):
185+
def collect_build_failure_dataframe(recipe_folder, config, channel, link_fmt="txt", link_prefix="", git_range=None):
183186
def get_build_failure_records(recipe):
184187
return filter(
185188
BuildFailureRecord.exists,
@@ -190,6 +193,21 @@ def has_build_failure(recipe):
190193
return any(get_build_failure_records(recipe))
191194

192195
recipes = list(utils.get_recipes(recipe_folder))
196+
197+
if git_range:
198+
if not git_range or len(git_range) > 2:
199+
sys.exit("--git-range may have only one or two arguments")
200+
other = git_range[0]
201+
ref = "HEAD" if len(git_range) == 1 else git_range[1]
202+
repo = BiocondaRepo(recipe_folder)
203+
changed_recipes = repo.get_recipes_to_build(ref, other)
204+
logger.info("Constraining to %s git modified recipes%s.", len(changed_recipes),
205+
utils.ellipsize_recipes(changed_recipes, recipe_folder))
206+
recipes = [recipe for recipe in recipes if recipe in set(changed_recipes)]
207+
if len(recipes) != len(changed_recipes):
208+
logger.info("Overlap was %s recipes%s.", len(recipes),
209+
utils.ellipsize_recipes(recipes, recipe_folder))
210+
193211
dag, _ = graph.build(recipes, config)
194212

195213
def get_data():
@@ -214,10 +232,11 @@ def get_data():
214232
recs = list(get_build_failure_records(recipe))
215233

216234
failures = ", ".join(utils.format_link(rec.path, link_fmt, prefix=link_prefix, label=rec.platform) for rec in recs)
235+
categories = ", ".join(rec.category for rec in recs)
217236
skiplisted = any(rec.skiplist for rec in recs)
218237
prs = utils.format_link(f"https://github.com/bioconda/bioconda-recipes/pulls?q=is%3Apr+is%3Aopen+{package}", link_fmt, label="show")
219-
yield (recipe, downloads, descendants, skiplisted, failures, prs)
238+
yield (recipe, downloads, descendants, skiplisted, categories, failures, prs)
220239

221-
data = pd.DataFrame(get_data(), columns=["recipe", "downloads", "depending", "skiplisted", "build failures", "pull requests"])
240+
data = pd.DataFrame(get_data(), columns=["recipe", "downloads", "depending", "skiplisted", "category", "build failures", "pull requests"])
222241
data.sort_values(by=["depending", "downloads"], ascending=False, inplace=True)
223242
return data

bioconda_utils/cli.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,11 @@ def annotate_build_failures(recipes, skiplist=False, reason=None, category=None,
10751075
@arg('--channel', help="Channel with packages to check", default="bioconda")
10761076
@arg('--output-format', help="Output format", choices=['txt', 'markdown'], default="txt")
10771077
@arg('--link-prefix', help="Prefix for links to build failures", default='')
1078-
def list_build_failures(recipe_folder, config, channel=None, output_format=None, link_prefix=None):
1078+
@arg('--git-range', nargs='+',
1079+
help='''Git range (e.g. commits or something like
1080+
"master HEAD" to check commits in HEAD vs master, or just "HEAD" to
1081+
include uncommitted changes).''')
1082+
def list_build_failures(recipe_folder, config, channel=None, output_format=None, link_prefix=None, git_range=None):
10791083
"""List recipes with build failure records"""
10801084

10811085
df = collect_build_failure_dataframe(
@@ -1084,6 +1088,7 @@ def list_build_failures(recipe_folder, config, channel=None, output_format=None,
10841088
channel,
10851089
link_fmt=output_format,
10861090
link_prefix=link_prefix,
1091+
git_range=git_range
10871092
)
10881093
if output_format == "markdown":
10891094
fmt_writer = pandas.DataFrame.to_markdown

bioconda_utils/utils.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1645,4 +1645,6 @@ def yaml_remove_invalid_chars(text: str, valid_chars_re=re.compile(r"[^ \t\n\w\d
16451645
def get_package_downloads(channel, package):
16461646
"""Use anaconda API to obtain download counts."""
16471647
data = requests.get(f"https://api.anaconda.org/package/{channel}/{package}").json()
1648-
return sum(rec["ndownloads"] for rec in data["files"])
1648+
if "files" in data:
1649+
return sum(rec["ndownloads"] for rec in data["files"])
1650+
return 0

0 commit comments

Comments
 (0)