A mechanism for vetoing steps in an analysis.
Indicates that a FileHandler’s generation was vetoed and should proceed no futher at this time. This is a benign exception that should be caught at file generation time.
VetoHandler(eventdir, manifest, vetoes)¶
A class that performs veto checks to see whether a FileHandler for a specific trigger should be vetoed. Instances can be called like functions to mark a FileHandler as vetoed.
No return value. Raises a
VetoExceptionif this file has somehow been vetoed, which should be interpreted as meaning that file generation should be aborted.
First checks if
True(this is to be interpreted as meaning that the file should never be generated); if so,
Next, runs all veto functions in
self.vetoesto see if these files have been vetoed in any way. If and when the first veto fails (returns True), its corresponding action (see the
__init__) is run, further vetoes are not checked, and
If these procedures are completed without a
VetoExceptionbeing raised, the method returns
Check whether the files in
self.manifestshould be generated based on whether their vetofiles exist (see
vetofilenames); as long as this is the case, the files will be considered permanently vetoed and should not be generated.
Read in the JSON dump of this vetofile. Returns
Noneif the file is not vetoed.
Remove PERMANENT veto status by deleting vetofiles for the file names specified in
self.manifestand event directory specified by
eventdir. This does not affect the checks contained in
self.vetoesthat are called by
self.check, so file generation will still get vetoed if those automated checks fail. This method is more useful for removing permanent vetoes from files that were manually vetoed or vetoed under older pipeline versions.
A list of filenames whose existence indicates that these files should never be generated (at least for as long as these files exist). The contents of these files can optionally contain text descriptions of why the veto happened.
Absolute paths to vetofiles listed in
self.vetofilenames(created by joining
self.eventdirto those filenames).
VetoHandlerTuple(eventdir, manifest, vetoes)¶
Alias for field number 0
Alias for field number 1
Alias for field number 2
A feature for FileHandler-like objects (producing a manifest and an eventdir) that defines a list of vetoes in a way that inherits additively from superclasses. Notably, provides a
vetoproperty returning a
VetoHandlerfor this instance. New vetoes can be added to classes by defining them in
class_vetoes(vetoes from superclasses
class_vetoesattributes are dynamically included in the
VetoMixin.vetoesdocstring for details.
VetoExceptionwas raised during generation, copy vetoes from the temporary event directory back to the parent directory and commit them.
Copy any vetoes for this filehandler over to the generation directory.
Check whether this filehandler has been vetoed before proceeding with generation.
VetoHandlerinstance for this
VetoHandlerdocstring for more info. Combines vetoes from all superclasses.
- The list of veto checks and their corresponding actions called by
self.veto.checks(). Returns the vetoes defined in
cls.class_vetoes, where vetoes specific to this class are defined, along with the vetoes returned by
cls.class_vetoesin all superclasses; for example, the order of vetoes pulled from class_vetoes (in a class and and its superclasses) for a class F with inheritance tree
A B C \ / / D E \ / F
would be: F, D, A, B, E, C (with duplicates after the first instance of a veto check removed, where the ordering of superclasses is listed left-to-right in the above graph).
By default, no vetoes are applied to a base FileHandler. Vetoes must be added to FileHandler subclasses. If you really, truly need to get rid of vetoes from superclasses, consider not inheriting from those superclasses or factoring the veto functionality out of those superclasses as a mixin before overriding this property to only return a reduced veto list.
A description of the form of this data structure from the
An iterable of N length-2 iterables of the form:
((veto1, action1), …, (vetoN, actionN))
vetofunctions are functions that take
eventdiras arguments and return
Trueif that particular veto criterion has been met (for example, a
Trueif a trigger has somehow been marked as a test trigger).
actionfunctions are callables that indicate some action that should be taken to handle the
actioncan also be
Nonefor the default behavior: to mark the set of filenames (specified by
manifest) for this trigger as vetoed, which would prevent those files from being generated.
Alternatively, you can also use an actual function for
actionto do something more subtle than just vetoing the file (e.g. delaying file generation, advanced error logging, dummy testing, etc; this could even involve an alternative file generation method for test cases or edge cases). The
vetofunctions will be run in order and the first to return
Truewill have its
actionexecuted; the rest will be ignored.
NOTE that if you specify an action, the file will NOT be vetoed by default (since your veto-handling might involve something like delaying file generation or generating it through some other method, both of which are cases where you are not actually trying to prevent the file from being generated). If you want to fully veto file generation, you will have to manually call this
VetoHandlerinstance at the end of your
actionto mark these files as PERMANENTLY vetoed and prevent file generation.
VetoExceptionWILL always be raised, however, since the called
actionis supposed to cancel any IMMEDIATE file generation by the default method (even if later attempts are still allowed).
If the path to the trigger directory contains the substring ‘INJECTION’ (case-insensitive), this veto is triggered (returns True).
If the path to the trigger directory contains the substring ‘MANUAL’ (case-insensitive), this veto is triggered (returns True).
If the path to the trigger directory contains the substring ‘SCRATCH’ (case-insensitive), this veto is triggered (returns True).
If the path to the trigger directory contains the substring ‘TEST’ (case-insensitive), this veto is triggered (returns True).
Copy any vetofiles for the
vetoedfilehandler from the temporary directory
tmpdirback to the eventdir. Vital for cleaning up after a failed generation attempt (in which the filehandler manifest would NOT be copied because the files should never have been generated; see _generation_dir_copy_manifest).
Return a new datetime representing UTC day and time.