llama.flags package¶
A mixin for keeping track of the state of flags applied to an event, e.g. whether an event is in ‘test’ or ‘observation’ mode.
-
class
llama.flags.
FlagDict
(eventdir)¶ Bases:
object
A dict-like interface to flags that sets and gets values from an on-disk file containing flags for a specific event directory. Note that values and keys must both be strings. For flags in
FlagDict.ALLOWED_VALUES
, the provided value can only be set to one of the allowed values. Either of these dictionaries can be extended as necessary to provide extra defaults and restrictions across all FlagDict instances.- Parameters
eventdir (str) – The path to the event directory that contains these flags.
-
ALLOWED_VALUES
= frozenset({'BLINDED_NEUTRINOS', 'ICECUBE_UPLOAD', 'MANUAL', 'ONLINE', 'ROLE', 'UPLOAD', 'VETOED'})¶
-
DEFAULT_FLAGS
= frozenset({'BLINDED_NEUTRINOS', 'ICECUBE_UPLOAD', 'MANUAL', 'ONLINE', 'ROLE', 'UPLOAD', 'VETOED'})¶
-
PRESETS
= FlagPresets(DEFAULT=FlagPreset({'VETOED': 'false', 'ROLE': 'test', 'UPLOAD': 'false', 'ICECUBE_UPLOAD': 'false', 'ONLINE': 'true', 'MANUAL': 'false', 'BLINDED_NEUTRINOS': 'false'}), TRIGGERED_INTERNAL=FlagPreset({'VETOED': 'false', 'UPLOAD': 'true', 'ROLE': 'observation', 'ICECUBE_UPLOAD': 'false', 'ONLINE': 'true', 'MANUAL': 'false', 'BLINDED_NEUTRINOS': 'false'}), TRIGGERED_PUBLIC=FlagPreset({'VETOED': 'false', 'UPLOAD': 'true', 'ROLE': 'observation', 'ONLINE': 'true', 'MANUAL': 'false', 'ICECUBE_UPLOAD': 'true', 'BLINDED_NEUTRINOS': 'false'}), TRIGGERED_TEST=FlagPreset({'VETOED': 'false', 'ROLE': 'test', 'UPLOAD': 'false', 'ICECUBE_UPLOAD': 'false', 'ONLINE': 'true', 'BLINDED_NEUTRINOS': 'true', 'MANUAL': 'false'}), RERUN=FlagPreset({'VETOED': 'false', 'ROLE': 'observation', 'UPLOAD': 'false', 'ICECUBE_UPLOAD': 'false', 'ONLINE': 'true', 'MANUAL': 'false', 'BLINDED_NEUTRINOS': 'false'}), MANUAL=FlagPreset({'VETOED': 'false', 'UPLOAD': 'true', 'MANUAL': 'true', 'ROLE': 'observation', 'ONLINE': 'true', 'ICECUBE_UPLOAD': 'true', 'BLINDED_NEUTRINOS': 'false'}))¶
-
items
() → list of D's (key, value) pairs, as 2-tuples.¶
-
keys
() → list of D's keys¶
-
update
(*E, **F)¶ (Same as
dict.update
.)self.update([E, ]**F)
-> None. Updateself
from dict/iterable E and F.- If E is present and has a .keys() method, then does:
for k in E: self[k] = E[k]
- If E is present and lacks a .keys() method, then does:
for k, v in E: self[k] = v
- In either case, this is followed by:
for k in F: self[k] = F[k]
-
values
() → list of D's values¶
-
class
llama.flags.
FlagPreset
¶ Bases:
llama.classes.ImmutableDict
A set of key, value pairs for
llama
flags to serve common use cases. Adds an optional extradescription
field toImmutableDict
that can be used to describe the intended use case for aFlagPreset
.
-
class
llama.flags.
FlagsMixin
¶ Bases:
object
A mixin that can read from and write to flags the ‘FLAGS.json’ file of any object with an
eventdir
property.-
decorate_checkout
()¶ Copy flags to the temporary directory on checkout (since they can control execution behavior).
-
property
flags
¶ A list of flags that apply to this instance, e.g. whether this is a testing or production event. See
llama.flags.FlagDict
for details.- Returns
flags – A collection of flags for this event directory with a dictionary-like interface. Flags are read from file using standard dictionary syntax, e.g.
self.flags['foo']
, with default flags added fromFlagDict.DEFAULT_FLAGS
. Setting new flags with something likeself.flags['foo'] = bar
will write the new flags to file. Changes to flags are not automatically version-controlled because they are committed as part of event directory state prior to any file generation attempts.- Return type
-
-
llama.flags.
flag_table
(flagdict, color=True, emphasize=())¶ Print flags into a nice table for terminals. If
color
isTrue
, add terminal color escape codes for emphasis. Specify flags that should be emphasized by listing the flag names inemphasize
(does not apply ifcolor
isFalse
).
Submodules