From ec46708a6f08b38a0bf03a5115d9e9d9b9f3415a Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Fri, 6 Sep 2024 08:32:49 +0200 Subject: [PATCH 1/4] fix: new URL has been entered --- handout/README.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/handout/README.txt b/handout/README.txt index 82b09521..196e8430 100644 --- a/handout/README.txt +++ b/handout/README.txt @@ -30,7 +30,7 @@ Please note: * This handout does not display material to be used as a reference. * In particular, the recepient has been informed that people new - to Snakemake and HPC should partake this course themselves as (some) + to Snakemake and HPC should follow this course themselves as (some) material can and will be outdated, eventually. * This is a handout release: Slides are merged and some (graphical) content has been dropped. @@ -38,4 +38,4 @@ Please note: notice applies. -Please direct suggestion for improvements to https://github.com/cmeesters/snakemake-hpc-teaching-material/issues . +Please direct suggestion for improvements to https://github.com/snakemake/snakemake-hpc-teaching-material/issues . From 616f00e23051dd0fa4e448e38d8d52ad3f012def Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Tue, 10 Sep 2024 18:41:52 +0200 Subject: [PATCH 2/4] docs: update README and deleted pack release script --- README.md | 5 ++++- pack_release.py | 40 ---------------------------------------- 2 files changed, 4 insertions(+), 41 deletions(-) delete mode 100755 pack_release.py diff --git a/README.md b/README.md index f430966c..8559020b 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,13 @@ In order to typeset the slides you want, you can simply run $ ./render --master-tex -c ``` -Two master slide sets are offered: +Three master slide sets are offered: - `slides/Snakemake_HPC_Users.tex` - which contains a slide set tailored for users of ready-to use and non-curated workflows, their HPC parameterization and execution - `slides/Snakemake_HPC_Creators.tex` - which contains a slide set tailored for creators of new workflows. +- `slides/Snakemake_HPC_Admins.tex'' - which contains some slides tailored to administrators to tell them some bits about Snakemake and global configurations. + +A lecturer may choose to render a handout version of a slide set with the `--handout` flag. Handouts do not contain some images or slide overlays and are a little bit smaller then full course slide sets. ### Customizing Slides diff --git a/pack_release.py b/pack_release.py deleted file mode 100755 index 15267ecf..00000000 --- a/pack_release.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import sys -import os -import shutil -import subprocess -import shlex -import zipfile - -if __name__ == '__main__': - parser = argparse.ArgumentParser() - parser.add_argument('--version', required = True, - help = "indicate the handout version, e.g. edition") - parser.add_argument('--pdf', required = True, - help = "indicate a PDF document") - parser.add_argument('--sample-directory', required = True, - help = "path to directory with script files (cloze and solution") - args = parser.parse_args() - - pdf = args.pdf - - handout_version = os.path.splitext(pdf)[0] + '.pdf' - final_place = os.path.basename(handout_version) - - file_list=[(handout_version, final_place), - ('handout/README.txt', 'README.txt')] - opj = os.path.join - for root, dirs, files in os.walk(args.sample_directory): - for fname in files: - # restrict to sample files, no helper files - if 'copy' in fname or 'README' in fname: continue - file_list.append((opj(root,fname), opj(*root.split('/')[1:],fname))) - - buildzipfname = 'snakemake_intro_%s.zip' % args.version - z = zipfile.ZipFile(buildzipfname, 'w', compression = zipfile.ZIP_DEFLATED) - for item in file_list: - z.write(item[0], item[1]) - z.close() - From 8235d1dc64fc10a0a0aeae152562d7bcf07c7a71 Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Tue, 10 Sep 2024 20:25:21 +0200 Subject: [PATCH 3/4] feat: render script is now able to pack a handout release, too --- render | 73 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 13 deletions(-) diff --git a/render b/render index 24cfe98b..ef91f7d1 100755 --- a/render +++ b/render @@ -12,6 +12,7 @@ import subprocess import sys from tempfile import TemporaryDirectory import yaml +import zipfile # non standard libraries from jinja2 import Environment, FileSystemLoader @@ -33,6 +34,7 @@ PATH = os.path.split(os.path.realpath(__file__))[0] jinja_env = Environment(loader=FileSystemLoader(PATH), **options) + def edition_from_tag(): """ sets the edition from the latests tag @@ -41,6 +43,7 @@ def edition_from_tag(): cmd = "git tag -l | tail -1" return subprocess.getoutput(cmd) + def screen_master(masterdoc, tempdir): prefix = os.path.join(tempdir, "slides") fnames = list() @@ -122,7 +125,7 @@ def run_pdflatex(fname="out.tex", path=".", handout=False): cmd += r' "\def\ishandout{1} \input{' + fname + r'}"' else: cmd += f" {fname}" - cmd = shlex.split(cmd) + cmd = shlex.split(cmd) retcode = subprocess.call(cmd, cwd=path) pdfname = get_pdf_name(fname) shutil.copy(os.path.join(path, pdfname), os.path.join(outdir, pdfname)) @@ -182,17 +185,19 @@ def find_and_replace_sections(boundaries, section_estimate, fname): ) # adapt the two lines with our new boundaries: elif first_done and second_done: - lines[ - first_done - ] = " \\tableofcontents[sections={%d-%d},currentsection]\n" % ( - boundaries["lower"], - boundaries["first_half_end"], + lines[first_done] = ( + " \\tableofcontents[sections={%d-%d},currentsection]\n" + % ( + boundaries["lower"], + boundaries["first_half_end"], + ) ) - lines[ - second_done - ] = " \\tableofcontents[sections={%d-%d},currentsection]\n" % ( - boundaries["second_half_start"], - boundaries["upper"], + lines[second_done] = ( + " \\tableofcontents[sections={%d-%d},currentsection]\n" + % ( + boundaries["second_half_start"], + boundaries["upper"], + ) ) else: logger.error(f"TOC expectations for '{fname}' not met") @@ -215,12 +220,22 @@ if __name__ == "__main__": ) parser.add_argument( "--handout", default=False, action=argparse.BooleanOptionalAction - ) + ) parser.add_argument( "-n", "--no-rerun", default=False, action=argparse.BooleanOptionalAction ) + parser.add_argument( + "--sample-directory", + help="needed with `--handout` - should indicate directory with script file (cloze and solution)", + ) args = parser.parse_args() + if args.handout and not args.sample_directory: + print( + "ERROR: must indicate --sample-directory when writing handouts", + file=sys.stderr, + ) + # the master tex needs to be without the 'slides' path, because # on the tempfs, the relative path work without args.master_tex = os.path.basename(args.master_tex) @@ -260,9 +275,41 @@ if __name__ == "__main__": to_adapt = os.path.join(tempdir, "slides", fname) + ".tex" find_and_replace_sections(boundaries, section_estimate, to_adapt) # now the typesetting needs to be triggered - run_pdflatex(fname=args.master_tex, path=os.path.join(tempdir, "slides"), handout=args.handout) + run_pdflatex( + fname=args.master_tex, + path=os.path.join(tempdir, "slides"), + handout=args.handout, + ) # re-run might be required if args.no_rerun: print("no rerun as requested") sys.exit() run_pdflatex(fname=args.master_tex, path=os.path.join(tempdir, "slides")) + + # only to produce handouts (together with script bundles) + if args.handout: + handout_version = ( + os.path.join("slides", os.path.splitext(args.master_tex)[0]) + ".pdf" + ) + + final_place = os.path.basename(handout_version) + + file_list = [ + (handout_version, final_place), + ("handout/README.txt", "README.txt"), + ] + opj = os.path.join + + for root, dirs, files in os.walk(args.sample_directory): + for fname in files: + # restrict to sample files, no helper files + if "copy" in fname or "README" in fname: + continue + file_list.append( + (opj(root, fname), opj(*root.split("/")[1:], fname)) + ) + buildzipfname = "snakemake_intro_%s.zip" % edition_from_tag() + z = zipfile.ZipFile(buildzipfname, "w", compression=zipfile.ZIP_DEFLATED) + for item in file_list: + z.write(item[0], item[1]) + z.close() From 96ed021df0e2e5bc367b61281e50cff049c156ce Mon Sep 17 00:00:00 2001 From: Christian Meesters Date: Tue, 10 Sep 2024 20:35:22 +0200 Subject: [PATCH 4/4] Update README.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8559020b..2b0564c5 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Three master slide sets are offered: - `slides/Snakemake_HPC_Creators.tex` - which contains a slide set tailored for creators of new workflows. - `slides/Snakemake_HPC_Admins.tex'' - which contains some slides tailored to administrators to tell them some bits about Snakemake and global configurations. -A lecturer may choose to render a handout version of a slide set with the `--handout` flag. Handouts do not contain some images or slide overlays and are a little bit smaller then full course slide sets. +A lecturer may choose to render a handout version of a slide set with the `--handout` flag. Handouts do not contain some images or slide overlays and are a little bit smaller than full course slide sets. ### Customizing Slides