Skip to content

Commit 3d2ed2a

Browse files
committed
rename package CLI argument to feedstock
1 parent 0a46315 commit 3d2ed2a

File tree

4 files changed

+72
-50
lines changed

4 files changed

+72
-50
lines changed

Diff for: conda_forge_tick/auto_tick.py

+50-30
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ def _run_migrator(
893893
temp: list[AnyStr],
894894
time_per: float,
895895
git_backend: GitPlatformBackend,
896-
package: str | None = None,
896+
feedstock: str | None = None,
897897
) -> int:
898898
"""
899899
Run a migrator.
@@ -903,7 +903,8 @@ def _run_migrator(
903903
:param temp: The list of temporary files.
904904
:param time_per: The time limit of this migrator.
905905
:param git_backend: The GitPlatformBackend instance to use.
906-
:param package: The package to update, if None, all packages are updated.
906+
:param feedstock: The feedstock to update, if None, all feedstocks are updated. Does not contain the `-feedstock`
907+
suffix.
907908
908909
:return: The number of "good" PRs created by the migrator.
909910
"""
@@ -928,14 +929,14 @@ def _run_migrator(
928929

929930
possible_nodes = list(migrator.order(effective_graph, mctx.graph))
930931

931-
if package:
932-
if package not in possible_nodes:
932+
if feedstock:
933+
if feedstock not in possible_nodes:
933934
logger.info(
934-
f"Package {package} is not a candidate for migration of {migrator_name}. "
935+
f"Feedstock {feedstock} is not a candidate for migration of {migrator_name}. "
935936
f"If you want to investigate this, run the make-migrators command."
936937
)
937938
return 0
938-
possible_nodes = [package]
939+
possible_nodes = [feedstock]
939940

940941
# version debugging info
941942
if isinstance(migrator, Version):
@@ -1085,17 +1086,18 @@ def _setup_limits():
10851086
resource.setrlimit(resource.RLIMIT_AS, (limit_int, limit_int))
10861087

10871088

1088-
def _update_nodes_with_bot_rerun(gx: nx.DiGraph, package: str | None = None):
1089+
def _update_nodes_with_bot_rerun(gx: nx.DiGraph, feedstock: str | None = None):
10891090
"""
10901091
Go through all the open PRs and check if they are rerun
10911092
10921093
:param gx: the dependency graph
1093-
:param package: the package to update, if None, all packages are updated
1094+
:param feedstock: The feedstock to update. If None, all feedstocks are updated. Does not contain the `-feedstock`
1095+
suffix.
10941096
"""
10951097

10961098
print("processing bot-rerun labels", flush=True)
10971099

1098-
nodes = gx.nodes.items() if not package else [(package, gx.nodes[package])]
1100+
nodes = gx.nodes.items() if not feedstock else [(feedstock, gx.nodes[feedstock])]
10991101

11001102
for i, (name, node) in enumerate(nodes):
11011103
# logger.info(
@@ -1154,21 +1156,24 @@ def _filter_ignored_versions(attrs, version):
11541156
return version
11551157

11561158

1157-
def _update_nodes_with_new_versions(gx: nx.DiGraph, package: str | None = None):
1159+
def _update_nodes_with_new_versions(gx: nx.DiGraph, feedstock: str | None = None):
11581160
"""
11591161
Updates every node with its new version (when available)
11601162
11611163
:param gx: the dependency graph
1162-
:param package: the package to update, if None, all packages are updated
1164+
:param feedstock: the feedstock to update, if None, all feedstocks are updated. Does not contain the `-feedstock`
1165+
suffix.
11631166
"""
11641167

11651168
print("updating nodes with new versions", flush=True)
11661169

1167-
if package and not does_key_exist_in_hashmap("versions", package):
1168-
logger.warning(f"Package {package} not found in versions hashmap")
1170+
if feedstock and not does_key_exist_in_hashmap("versions", feedstock):
1171+
logger.warning(f"Feedstock {feedstock} not found in versions hashmap")
11691172
return
11701173

1171-
version_nodes = get_all_keys_for_hashmap("versions") if not package else [package]
1174+
version_nodes = (
1175+
get_all_keys_for_hashmap("versions") if not feedstock else [feedstock]
1176+
)
11721177

11731178
for node in version_nodes:
11741179
version_data = LazyJson(f"versions/{node}.json").data
@@ -1194,27 +1199,32 @@ def _update_nodes_with_new_versions(gx: nx.DiGraph, package: str | None = None):
11941199
vpri["new_version"] = version_from_data
11951200

11961201

1197-
def _remove_closed_pr_json(package: str | None = None):
1202+
def _remove_closed_pr_json(feedstock: str | None = None):
11981203
"""
11991204
Remove the pull request information for closed PRs.
12001205
1201-
:param package: The package to remove the PR information for. If None, all PR information is removed. If you pass
1202-
a package, closed pr_json files are not removed because this would require iterating all pr_json files.
1206+
:param feedstock: The feedstock to remove the PR information for. If None, all PR information is removed. If you pass
1207+
a feedstock, closed pr_json files are not removed because this would require iterating all pr_json files. Does not
1208+
contain the `-feedstock` suffix.
12031209
"""
12041210
print("collapsing closed PR json", flush=True)
12051211

1206-
if package:
1212+
if feedstock:
12071213
pr_info_nodes = (
1208-
[package] if does_key_exist_in_hashmap("pr_info", package) else []
1214+
[feedstock] if does_key_exist_in_hashmap("pr_info", feedstock) else []
12091215
)
12101216
version_pr_info_nodes = (
1211-
[package] if does_key_exist_in_hashmap("version_pr_info", package) else []
1217+
[feedstock]
1218+
if does_key_exist_in_hashmap("version_pr_info", feedstock)
1219+
else []
12121220
)
12131221

12141222
if not pr_info_nodes:
1215-
logger.warning(f"Package {package} not found in pr_info hashmap")
1223+
logger.warning(f"Feedstock {feedstock} not found in pr_info hashmap")
12161224
if not version_pr_info_nodes:
1217-
logger.warning(f"Package {package} not found in version_pr_info hashmap")
1225+
logger.warning(
1226+
f"Feedstock {feedstock} not found in version_pr_info hashmap"
1227+
)
12181228
else:
12191229
pr_info_nodes = get_all_keys_for_hashmap("pr_info")
12201230
version_pr_info_nodes = get_all_keys_for_hashmap("version_pr_info")
@@ -1255,7 +1265,7 @@ def _remove_closed_pr_json(package: str | None = None):
12551265

12561266
# at this point, any json blob referenced in the pr info is state != closed
12571267
# so we can remove anything that is empty or closed
1258-
if package:
1268+
if feedstock:
12591269
logger.info(
12601270
"Since you requested a run for a specific package, we are not removing closed pr_json files."
12611271
)
@@ -1270,22 +1280,32 @@ def _remove_closed_pr_json(package: str | None = None):
12701280
)
12711281

12721282

1273-
def _update_graph_with_pr_info(package: str | None = None):
1274-
_remove_closed_pr_json(package)
1283+
def _update_graph_with_pr_info(feedstock: str | None = None):
1284+
"""
1285+
:param feedstock: The feedstock to update the graph for. If None, all feedstocks are updated. Does not contain the
1286+
`-feedstock` suffix.
1287+
"""
1288+
_remove_closed_pr_json(feedstock)
12751289
gx = load_existing_graph()
1276-
_update_nodes_with_bot_rerun(gx, package)
1277-
_update_nodes_with_new_versions(gx, package)
1290+
_update_nodes_with_bot_rerun(gx, feedstock)
1291+
_update_nodes_with_new_versions(gx, feedstock)
12781292
dump_graph(gx)
12791293

12801294

1281-
def main(ctx: CliContext, package: str | None = None) -> None:
1295+
def main(ctx: CliContext, feedstock: str | None = None) -> None:
1296+
"""
1297+
Run the main bot logic.
1298+
1299+
:param ctx: The CLI context.
1300+
:param feedstock: If not None, only the given feedstock is updated. Does not contain the `-feedstock` suffix.
1301+
"""
12821302
global START_TIME
12831303
START_TIME = time.time()
12841304

12851305
_setup_limits()
12861306

12871307
with fold_log_lines("updating graph with PR info"):
1288-
_update_graph_with_pr_info(package)
1308+
_update_graph_with_pr_info(feedstock)
12891309
deploy(ctx, dirs_to_deploy=["version_pr_info", "pr_json", "pr_info"])
12901310

12911311
# record tmp dir so we can be sure to clean it later
@@ -1339,7 +1359,7 @@ def main(ctx: CliContext, package: str | None = None) -> None:
13391359

13401360
for mg_ind, migrator in enumerate(migrators):
13411361
good_prs = _run_migrator(
1342-
migrator, mctx, temp, time_per_migrator[mg_ind], git_backend, package
1362+
migrator, mctx, temp, time_per_migrator[mg_ind], git_backend, feedstock
13431363
)
13441364
if good_prs > 0:
13451365
pass

Diff for: conda_forge_tick/cli.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -131,44 +131,46 @@ def make_graph(
131131
@job_option
132132
@n_jobs_option
133133
@click.argument(
134-
"package",
134+
"feedstock",
135135
required=False,
136136
default=None,
137137
type=str,
138138
)
139139
@pass_context
140140
def update_upstream_versions(
141-
ctx: CliContext, job: int, n_jobs: int, package: Optional[str]
141+
ctx: CliContext, job: int, n_jobs: int, feedstock: Optional[str]
142142
) -> None:
143143
"""
144144
Update the upstream versions of feedstocks in the graph.
145145
146-
If PACKAGE is given, only update that package, otherwise update all packages.
146+
If FEEDSTOCK is given, only update that feedstock, otherwise update all feedstocks.
147+
The FEEDSTOCK argument should omit the `-feedstock` suffix.
147148
"""
148149
from . import update_upstream_versions
149150

150151
check_job_param_relative(job, n_jobs)
151152

152-
update_upstream_versions.main(ctx, job=job, n_jobs=n_jobs, package=package)
153+
update_upstream_versions.main(ctx, job=job, n_jobs=n_jobs, feedstock=feedstock)
153154

154155

155156
@main.command(name="auto-tick")
156157
@click.argument(
157-
"package",
158+
"feedstock",
158159
required=False,
159160
default=None,
160161
type=str,
161162
)
162163
@pass_context
163-
def auto_tick(ctx: CliContext, package: str | None) -> None:
164+
def auto_tick(ctx: CliContext, feedstock: str | None) -> None:
164165
"""
165166
Run the main bot logic that runs all migrations, updates the graph accordingly, and opens the corresponding PRs.
166167
167-
If PACKAGE is given, only run the bot for that package, otherwise run the bot for all packages.
168+
If FEEDSTOCK is given, only run the bot for that feedstock, otherwise run the bot for all feedstocks.
169+
The FEEDSTOCK argument should omit the `-feedstock` suffix.
168170
"""
169171
from . import auto_tick
170172

171-
auto_tick.main(ctx, package=package)
173+
auto_tick.main(ctx, feedstock=feedstock)
172174

173175

174176
@main.command(name="make-status-report")

Diff for: conda_forge_tick/update_upstream_versions.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ def update_upstream_versions(
436436
debug: bool = False,
437437
job=1,
438438
n_jobs=1,
439-
package: Optional[str] = None,
439+
feedstock: Optional[str] = None,
440440
) -> None:
441441
"""
442442
Update the upstream versions of packages.
@@ -445,15 +445,15 @@ def update_upstream_versions(
445445
:param debug: Whether to run in debug mode
446446
:param job: The job number
447447
:param n_jobs: The total number of jobs
448-
:param package: The package to update. If None, update all packages.
448+
:param feedstock: The feedstock to update. If None, update all feedstocks. Does not contain the `-feedstock` suffix.
449449
"""
450-
if package and package not in gx.nodes:
451-
logger.error(f"Package {package} not found in graph. Exiting.")
450+
if feedstock and feedstock not in gx.nodes:
451+
logger.error(f"Feedstock {feedstock} not found in graph. Exiting.")
452452
return
453453

454454
# In the future, we should have some sort of typed graph structure
455455
all_nodes: Iterable[Tuple[str, Mapping[str, Mapping]]] = (
456-
[(package, gx.nodes.get(package))] if package else gx.nodes.items()
456+
[(feedstock, gx.nodes.get(feedstock))] if feedstock else gx.nodes.items()
457457
)
458458

459459
job_nodes = filter_nodes_for_job(all_nodes, job, n_jobs)
@@ -481,7 +481,7 @@ def extract_payload(node: Tuple[str, Mapping[str, Mapping]]) -> Tuple[str, Mappi
481481

482482
updater = (
483483
_update_upstream_versions_sequential
484-
if debug or package
484+
if debug or feedstock
485485
else _update_upstream_versions_process_pool
486486
)
487487

@@ -493,14 +493,14 @@ def main(
493493
ctx: CliContext,
494494
job: int = 1,
495495
n_jobs: int = 1,
496-
package: Optional[str] = None,
496+
feedstock: Optional[str] = None,
497497
) -> None:
498498
"""
499499
Main function for updating the upstream versions of packages.
500500
:param ctx: The CLI context.
501501
:param job: The job number.
502502
:param n_jobs: The total number of jobs.
503-
:param package: The package to update. If None, update all packages.
503+
:param feedstock: The feedstock to update. If None, update all feedstocks. Does not contain the `-feedstock` suffix.
504504
"""
505505
logger.info("Reading graph")
506506
# Graph enabled for inspection
@@ -514,5 +514,5 @@ def main(
514514
debug=ctx.debug,
515515
job=job,
516516
n_jobs=n_jobs,
517-
package=package,
517+
feedstock=feedstock,
518518
)

Diff for: tests/test_upstream_versions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1223,12 +1223,12 @@ def test_include_node_bad_pull_request_upstream(caplog):
12231223

12241224

12251225
def test_update_upstream_versions_nonexistent_package(caplog):
1226-
package_name = "nonexistent-package"
1226+
feedstock_name = "nonexistent-package"
12271227

12281228
caplog.set_level(logging.DEBUG)
12291229
update_upstream_versions(
12301230
nx.DiGraph(),
1231-
package=package_name,
1231+
feedstock=feedstock_name,
12321232
)
12331233

12341234
assert "Package nonexistent-package not found in graph" in caplog.text
@@ -1640,7 +1640,7 @@ def test_main(
16401640
ctx = CliContext()
16411641
ctx.debug = debug
16421642

1643-
main(ctx, job=3, n_jobs=10, package="testpackage")
1643+
main(ctx, job=3, n_jobs=10, feedstock="testpackage")
16441644

16451645
makedirs_mock.assert_called_once_with("versions", exist_ok=True)
16461646
load_graph_mock.assert_called_once()

0 commit comments

Comments
 (0)