-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Snakefile
128 lines (109 loc) · 2.95 KB
/
Snakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
from glob import iglob
from snek5000.util.archive import tar_name, archive
PYTHON_DIRECTORIES = ["docs", "src", "tests"]
rule env_export:
shell:
"""
conda env export -f environment.yml
sed -i '/^prefix/d' environment.yml
sed -i '/snek5000/d' environment.yml
"""
rule env_update:
shell: 'conda env update --file environment.yml'
rule develop:
shell: 'pip install -e .[dev]'
rule docs:
input: 'src/'
shell: 'cd docs && SPHINXOPTS="-W" make html'
rule docs_clean:
shell: 'cd docs && SPHINXOPTS="-W" make cleanall'
rule bin_archive:
input:
iglob('bin/SLURM*'),
iglob('bin/launcher_20*')
output:
tar_name(
Path.cwd(), "bin/SLURM*", subdir="bin",
default_prefix="archive"
)
run:
archive(output, input, remove=True)
rule ctags:
input:
nek5000='lib/Nek5000/core',
abl='src/abl',
snek5000='src/snek5000'
output:
'.tags'
params:
excludes = ' '.join(
(
f'--exclude={pattern}'
for pattern in
(
'.snakemake',
'__pycache__',
'obj',
'logs',
'*.tar.gz',
'*.f?????'
)
)
)
shell:
"""
ctags -f {output} --language-force=Fortran -R {input.nek5000}
ctags -f {output} {params.excludes} --append --language-force=Fortran -R {input.abl}
ctags -f {output} {params.excludes} --append -R {input.snek5000}
"""
rule watch:
params:
per_second=5,
rules='docs ctags'
shell:
'nohup watch -n {params.per_second} snakemake {params.rules} 2>&1 > /tmp/watch.log&'
rule squeue:
params:
per_second=59,
rules='docs ctags'
shell:
'watch -n {params.per_second} squeue -u $USER --start'
rule salloc:
params:
# project='snic2019-1-2',
# walltime='05:00',
project='snic2014-10-3 --reservation=dcs',
walltime='30:00',
nproc=8
shell:
'interactive -A {params.project} -t {params.walltime} -n {params.nproc}'
rule ipykernel:
shell: 'ipython kernel install --user --name=$(basename $CONDA_PREFIX)'
rule jlab:
shell:
"""
echo '-----------------------------------------'
echo ' Setup an SSH tunnel to '
printf ' '
hostname
echo '-----------------------------------------'
jupyter-lab --no-browser --port=5656
"""
rule lint:
input: PYTHON_DIRECTORIES
shell: "black --check {input}"
rule fix:
input: PYTHON_DIRECTORIES
shell: 'black {input}'
rule release:
shell:
"""
rm -rf build dist
python setup.py sdist
twine check dist/*
"""
rule testpypi:
shell:
"""
twine upload --repository testpypi dist/*
"""