Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions libcflib/db.xsh
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,9 @@ class DB:
yield data

def load_packages(self):
with indir($LIBCFGRAPH_DIR + '/artifacts/'):
artifacts = g`**/*.json`
artifacts = sorted(artifacts)
groups = toolz.groupby(lambda a: a.split('/')[0], artifacts)
for package, artifact in groups.items():
p = Package(name=package, artifact_ids=artifact)
self._packages[p.name] = p
for package in os.listdir($LIBCFGRAPH_DIR + '/artifacts/'):
p = Package(name=package)
self._packages[p.name] = p

@property
def packages(self):
Expand Down
3 changes: 2 additions & 1 deletion libcflib/harvest_pkgs.xsh
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ def create_graphs():
req.add(dep.split(' ')[0])
if pkg not in channel_graphs[channel]:
channel_graphs[channel].add_node(pkg)
for k in ['versions', 'archs', 'req']:
for k in ['versions', 'archs', 'req', 'artifact_id']:
if k not in channel_graphs[channel].nodes[pkg]:
channel_graphs[channel].nodes[pkg][k] = set()

channel_graphs[channel].nodes[pkg]['archs'].add(arch)
channel_graphs[channel].nodes[pkg]['versions'].add(art['version'])
channel_graphs[channel].nodes[pkg]['req'].update(req)
channel_graphs[channel].nodes[pkg]['artifact_id'].update(art_fp)

for dep in channel_graphs[channel].nodes[pkg]['req']:
if (dep, pkg) not in channel_graphs[channel].edges:
Expand Down
21 changes: 8 additions & 13 deletions libcflib/model.py → libcflib/model.xsh
Original file line number Diff line number Diff line change
Expand Up @@ -111,29 +111,24 @@ def _load(self):


class Package(Model):
def __init__(self, *, name=None, artifact_ids=None, channel="conda-forge"):
def __init__(self, *, name=None):
self._name = name
self._channel = "conda-forge"
super().__init__()
self.name = name
self.channel = channel
# eager load
self._load()

def __repr__(self):
return f"Package({self.name})"

def _load(self):
with indir($LIBCFGRAPH_DIR + '/artifacts/' + self._name):
artifact_ids = g`**/*.json`
artifact_ids = sorted(artifact_ids)
self.artifacts = defaultdict(lambda: defaultdict(set))
for a in artifact_ids:
_, channel, arch, artifact_name = a.split("/", 3)
self.artifacts[channel][arch].add(artifact_name)

def __repr__(self):
return f"Package({self.name}"

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()


Expand Down