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', 'ONLINE', 'ROLE', 'UPLOAD', 'VETOED'})
DEFAULT_FLAGS = frozenset({'BLINDED_NEUTRINOS', 'ICECUBE_UPLOAD', 'ONLINE', 'ROLE', 'UPLOAD', 'VETOED'})
PRESETS = FlagPresets(DEFAULT=ImmutableDict({'UPLOAD': 'false', 'VETOED': 'false', 'ROLE': 'test', 'ICECUBE_UPLOAD': 'false', 'ONLINE': 'true', 'BLINDED_NEUTRINOS': 'false'}), TRIGGERED_INTERNAL=ImmutableDict({'UPLOAD': 'true', 'VETOED': 'false', 'ICECUBE_UPLOAD': 'false', 'ONLINE': 'true', 'ROLE': 'observation', 'BLINDED_NEUTRINOS': 'false'}), TRIGGERED_PUBLIC=ImmutableDict({'UPLOAD': 'true', 'VETOED': 'false', 'ICECUBE_UPLOAD': 'true', 'ONLINE': 'true', 'ROLE': 'observation', 'BLINDED_NEUTRINOS': 'false'}), TRIGGERED_TEST=ImmutableDict({'UPLOAD': 'false', 'VETOED': 'false', 'ROLE': 'test', 'ICECUBE_UPLOAD': 'false', 'ONLINE': 'true', 'BLINDED_NEUTRINOS': 'true'}), RERUN=ImmutableDict({'UPLOAD': 'false', 'VETOED': 'false', 'ICECUBE_UPLOAD': 'false', 'ONLINE': 'true', 'ROLE': 'observation', '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. Update self 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.FlagsMixin

Bases: object

A mixin that can read from and write to flags the ‘FLAGS.json’ file of any object with an eventdir property.

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 from FlagDict.DEFAULT_FLAGS. Setting new flags with something like self.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.FlagDict

Submodules