diff --git a/libcflib/harvest_pkgs.xsh b/libcflib/harvest_pkgs.xsh index e591768..63a5b63 100644 --- a/libcflib/harvest_pkgs.xsh +++ b/libcflib/harvest_pkgs.xsh @@ -37,8 +37,11 @@ def create_graphs(): for dep in channel_graphs[channel].nodes[pkg]['req']: if (dep, pkg) not in channel_graphs[channel].edges: - channel_graphs[channel].add_edge(dep, pkg, arch=set()) + channel_graphs[channel].add_edge(dep, pkg, + arch=set(), + version=set()) channel_graphs[channel].edges[(dep, pkg)]['arch'].add(arch) + channel_graphs[channel].edges[(dep, pkg)]['version'].add(art['version']) return channel_graphs diff --git a/libcflib/model.py b/libcflib/model.py index 5640c19..53051d3 100644 --- a/libcflib/model.py +++ b/libcflib/model.py @@ -5,6 +5,8 @@ import os from typing import Iterator +import networkx as nx + class Model(object): def __init__(self): @@ -131,7 +133,6 @@ def __repr__(self): def _load(self): env = builtins.__xonsh_env__ filename = os.path.join(env.get("LIBCFGRAPH_DIR"), self._channel + ".json") - # TODO: use networkx to get the data so we have edges with open(filename, "r") as f: self._d.update(json.load(f).get(self._name, {})) super()._load() @@ -150,3 +151,16 @@ def _load(self): with open(filename, "r") as f: self._d.update(json.load(f).get(self._name, {})) super()._load() + + +class Graph(Model): + def __init__(self, *, channel="conda-forge"): + self._channel = channel + super().__init__() + + def _load(self): + env = builtins.__xonsh_env__ + filename = os.path.join(env.get("LIBCFGRAPH_DIR"), "conda-forge.json") + with open(filename, "r") as f: + self._d["graph"] = nx.node_link_graph(json.load(f)) + super()._load() diff --git a/libcflib/schemas.py b/libcflib/schemas.py index 8fae139..9b112c1 100644 --- a/libcflib/schemas.py +++ b/libcflib/schemas.py @@ -13,8 +13,7 @@ "type": "bool", }, "PRed": { - "_description": "For each migrator which" - "track which PRs have" + "_description": "For each migrator which track which PRs have " "been issued", "type": "list", "schema": {"type": "string"}, @@ -26,10 +25,9 @@ }, "commit": {"type": "string", "_description": "The latest commit"}, "new_version": { - "anyof_type": ["string", "bool"], + "anyof_type": ["string"], "_description": "The new version", }, - "meta_yaml": {"type": "dict", "_description": "The meta_yaml"}, }, }, "artifact": { diff --git a/tests/conftest.py b/tests/conftest.py index 3645ee1..f694720 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,5 +4,5 @@ @pytest.fixture def tmpgraphdir(tmpdir_factory): d = tmpdir_factory.mktemp("graph", numbered=False) - d.mkdir('artifacts').mkdir('mypkg').mkdir("/somechannel").mkdir("noarch") + d.mkdir("artifacts").mkdir("mypkg").mkdir("/somechannel").mkdir("noarch") return d diff --git a/tests/test_model.py b/tests/test_model.py index f0cbb09..2208102 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -7,13 +7,13 @@ def test_artifact(tmpgraphdir): d = {"a": "hi", "world": "python"} - art_dir = os.path.join(tmpgraphdir, 'artifacts', 'mypkg', 'somechannel', 'noarch') + art_dir = os.path.join(tmpgraphdir, "artifacts", "mypkg", "somechannel", "noarch") with open(os.path.join(art_dir, "mypkg.json"), "w") as f: json.dump(d, f) env = builtins.__xonsh_env__ env["LIBCFGRAPH_DIR"] = tmpgraphdir - pkg, channel, arch = art_dir.split('/')[-3:] + pkg, channel, arch = art_dir.split("/")[-3:] n = Artifact(pkg=pkg, channel=channel, arch=arch, name="mypkg") assert n.a == "hi" assert n["a"] == "hi" @@ -22,5 +22,6 @@ def test_artifact(tmpgraphdir): # make sure we can hash artifacts hash(n) + # TODO: test package # TODO: test feedstock