Skip to content

Commit

Permalink
add ability to restrict platforms for migrator
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Apr 18, 2023
1 parent 2422901 commit c846bf3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions conda_forge_tick/feedstock_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ def populate_feedstock_attributes(
raise

LOGGER.debug("platforms: %s", plat_arch)
sub_graph["platforms"] = ["_".join(k) for k in plat_arch]

# this makes certain that we have consistent ordering
sorted_variant_yamls = [x for _, x in sorted(zip(plat_arch, variant_yamls))]
Expand Down
31 changes: 24 additions & 7 deletions conda_forge_tick/migrators/migration_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,23 @@ def __init__(
self.max_solver_attempts = max_solver_attempts

def filter(self, attrs: "AttrsTypedDict", not_bad_str_start: str = "") -> bool:
wait_for_migrators = self.loaded_yaml.get("__migrator", {}).get(
"wait_for_migrators",
[],
)
"""
Determine whether migrator needs to be filtered out.
Return value of True means to skip migrator, False means to go ahead.
Calls up the MRO until Migrator.filter, see docstring there (./core.py).
"""
migrator_payload = self.loaded_yaml.get("__migrator", {})
platform_restriction = migrator_payload.get("platform_restriction", [])
wait_for_migrators = migrator_payload.get("wait_for_migrators", [])

platform_filtered = False
if platform_restriction:
# filter out nodes where the intersection between
# attrs.platforms and platform_restriction is empty
intersection = set(attrs.get("platforms", {})) & set(platform_restriction)
platform_filtered = not bool(intersection)

need_to_wait = False
if wait_for_migrators:
found_migrators = set()
Expand All @@ -199,9 +212,13 @@ def filter(self, attrs: "AttrsTypedDict", not_bad_str_start: str = "") -> bool:
wait_for_migrators,
)

return need_to_wait or super().filter(
attrs=attrs,
not_bad_str_start=not_bad_str_start,
return (
platform_filtered
or need_to_wait
or super().filter(
attrs=attrs,
not_bad_str_start=not_bad_str_start,
)
)

def migrate(
Expand Down
1 change: 1 addition & 0 deletions conda_forge_tick/migrators_types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class AttrsTypedDict_(TypedDict, total=False):
package: PackageTypedDict
raw_meta_yaml: str
req: Set[str]
platforms: List[str]
requirements: RequirementsTypedDict
source: SourceTypedDict
test: TestTypedDict
Expand Down

0 comments on commit c846bf3

Please sign in to comment.