/
ruleinfo.py
64 lines (57 loc) · 2.02 KB
/
ruleinfo.py
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
__authors__ = "Johannes Köster"
__copyright__ = "Copyright 2021, Johannes Köster"
__email__ = "johannes.koester@uni-due.de"
__license__ = "MIT"
from copy import copy
class RuleInfo:
def __init__(self, func=None):
self.func = func
self.shellcmd = None
self.name = None
self.norun = False
self.input = None
self.output = None
self.params = None
self.message = None
self.benchmark = None
self.conda_env = None
self.container_img = None
self.is_containerized = False
self.env_modules = None
self.wildcard_constraints = None
self.threads = None
self.shadow_depth = None
self.resources = None
self.priority = None
self.version = None
self.log = None
self.docstring = None
self.group = None
self.script = None
self.notebook = None
self.wrapper = None
self.cwl = None
self.cache = False
self.path_modifier = None
self.handover = False
self.default_target = False
def apply_modifier(
self, modifier, prefix_replacables={"input", "output", "log", "benchmark"}
):
"""Update this ruleinfo with the given one (used for 'use rule' overrides)."""
path_modifier = modifier.path_modifier
skips = set()
if modifier.ruleinfo_overwrite:
for key, value in modifier.ruleinfo_overwrite.__dict__.items():
if key != "func" and value is not None:
self.__dict__[key] = value
if key in prefix_replacables:
skips.add(key)
if path_modifier.modifies_prefixes and skips:
# use a specialized copy of the path modifier
path_modifier = copy(path_modifier)
path_modifier.skip_properties = skips
# add path modifier
self.path_modifier = path_modifier
# modify wrapper if requested
self.wrapper = modifier.modify_wrapper_uri(self.wrapper)