Skip to content

Commit

Permalink
Confine SQL to cache class, not ChannelIndex (#164)
Browse files Browse the repository at this point in the history
* move run_exports query into cache class

* add news
  • Loading branch information
dholth authored May 28, 2024
1 parent ebe9bb1 commit 021f4bd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
10 changes: 1 addition & 9 deletions conda_index/index/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,15 +1086,7 @@ def build_run_exports_data(self, subdir, verbose=False, progress=False):
run_exports_conda_packages = {}

# load cached packages
for row in cache.db.execute(
"""
SELECT path, run_exports FROM stat
LEFT JOIN run_exports USING (path)
WHERE stat.stage = ?
ORDER BY path
""",
(cache.upstream_stage,),
):
for row in cache.run_exports():
path, run_exports_data = row
run_exports_data = {"run_exports": json.loads(run_exports_data or "{}")}
if path.endswith(CONDA_PACKAGE_EXTENSION_V1):
Expand Down
15 changes: 15 additions & 0 deletions conda_index/index/sqlitecache.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,21 @@ def store_index_json_stat(self, database_path, mtime, size, index_json):
(database_path, mtime, size, index_json["sha256"], index_json["md5"]),
)

def run_exports(self):
"""
Query returning run_exports data, to be formatted by
ChannelIndex.build_run_exports_data()
"""
return self.db.execute(
"""
SELECT path, run_exports FROM stat
LEFT JOIN run_exports USING (path)
WHERE stat.stage = ?
ORDER BY path
""",
(self.upstream_stage,),
)


def _cache_post_install_details(paths_json_str):
post_install_details_json = {
Expand Down
20 changes: 20 additions & 0 deletions news/163-cache-run-exports
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
### Enhancements

* <news item>

### Bug fixes

* Move `run_exports.json` query into cache, instead of directly using SQL in
`ChannelIndex`. (#163)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>

0 comments on commit 021f4bd

Please sign in to comment.