Last active
March 31, 2020 20:23
-
-
Save beckermr/1e1c4d9f5412f991c298e2e101151712 to your computer and use it in GitHub Desktop.
test if migration for a package is ready
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import logging | |
from contextlib import redirect_stdout, redirect_stderr | |
import io | |
from conda_forge_tick.utils import load_graph | |
from conda_forge_tick.auto_tick import migration_factory | |
migration = sys.argv[1] | |
node = sys.argv[2] | |
logger = logging.getLogger("conda_forge_tick.migrators.core") | |
logger.setLevel(logging.DEBUG) | |
ch = logging.StreamHandler() | |
ch.setLevel(logging.DEBUG) | |
logger.addHandler(ch) | |
print("loading the graph...", end="", flush=True) | |
gx = load_graph() | |
print("done", flush=True) | |
m = [] | |
print("reading migrators...", end="", flush=True) | |
f = io.StringIO() | |
with redirect_stderr(f), redirect_stdout(f): | |
migration_factory(m, gx) | |
print("done", flush=True) | |
my_mg = None | |
for mg in m: | |
if mg.name == migration: | |
my_mg = mg | |
if my_mg is None: | |
raise RuntimeError( | |
"Could not find migration '%s'! current names: %s" % ( | |
migration, | |
[mg.name for mg in m])) | |
print("migrator:", my_mg.name, flush=True) | |
with gx.nodes[node]['payload'] as attrs: | |
print("graph node:", node, flush=True) | |
print("migration ready?", not my_mg.filter(attrs), flush=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment