Created
September 8, 2022 19:18
-
-
Save rodluger/fd99676a3c07e758da3c0e7dbde130b1 to your computer and use it in GitHub Desktop.
Get showyourwork cache info
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
def get_cache_info(*args, **kwargs): | |
import inspect | |
from pathlib import Path | |
# Wait until the DAG has been built | |
snakemake.workflow.checkpoints.syw__dag.get() | |
# Get all jobs from the DAG | |
dag = None | |
levels = inspect.stack() | |
for level in levels: | |
dag = level.frame.f_locals.get("dag", None) | |
if dag is not None: | |
break | |
jobs = [job for job in dag.jobs if snakemake.workflow.workflow.is_cached_rule(job.rule)] | |
# Print cache file names | |
cache = snakemake.workflow.workflow.output_file_cache | |
for job in jobs: | |
for outputfile, cachefile in cache.get_outputfiles_and_cachefiles(job): | |
cachefile = Path(cachefile).name | |
print(f"{outputfile} -> {cachefile}") | |
# Abort | |
raise Exception("Aborting...") | |
rule cache_info: | |
input: | |
get_cache_info | |
priority: | |
snakemake.jobs.Job.HIGHEST_PRIORITY | |
output: | |
touch("src/data/CACHEINFO") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment