llama.com.utils module¶
Classes and utilities for communicating with external organizations (e.g. downloading inputs and uploading results, sending alerts, etc.). Pretty much everything having to do with data transfer should be inheriting from primitives in this package.
-
class
llama.com.utils.
UploadReceipt
¶ Bases:
llama.filehandler.FileHandler
,llama.filehandler.mixins.OnlineVetoMixin
,llama.filehandler.mixins.ObservingVetoMixin
A log file created as a side effect of uploading some other original file to some remote server (like gw-astronomy.org or gracedb). The generate() function should contain instructions on how to upload the original file and should log helpful information to the UploadReceipt file. The presence of an UploadReceipt file should be taken as evidence that an upload has succeeded.
Define the file that is to be uploaded as
UPLOAD
when subclassingUploadReceipt
.-
CLASSNAME_FMT
= None¶
-
FILENAME_FMT
= None¶
-
UPLOAD
= None¶
-
class_vetoes
= ((<function upload_flag_false>, None),)¶
-
classmethod
decorator_dict
(upload)¶ See
UploadReceipt.upload_this
. Takes the decoratedFileHandler
class as its first argument. By default takes no additional arguments.- Parameters
upload – The decorated
FileHandler
class that is being registered for upload.- Returns
newclassdict – A dictionary that can be passed to
type
to specify the attributes of a new class.- Return type
dict
-
classmethod
set_class_attributes
(subclass)¶ See
FileHandler.set_class_attributes
; this method additionally sets theFILENAME
andDEPENDENCIES
attributes based onsubclass.UPLOAD
.
-
classmethod
upload_this
(*args, namespace=None, **kwargs)¶ Return a decorator that automatically uploads
FileHandler
classes by implementing this class with thatFileHandler
class as theUPLOAD
attribute. Additional attributes are set bycls.decorator_dict
using theFileHandler
class decorated by the returneddecorator
,*args
, and**kwargs
.- Parameters
*args – Positional arguments to pass to
cls.decorator_dict
(after theFileHandler
class decorated by the returneddecorator
, which takes the first positional argument position).namespace (dict, optional) – The namespace to which the new
UploadReceipt
created bydecorator
will be added. The default behavior is to defineUploadReceipt
in the global namespace of the calling frame (so that using the decorator is equivalent to manually defining theUploadReceipt
class with the decoratedFileHandler
as its upload immediately after defining theFileHandler
to be decorated).**kwargs – Keyword arguments to pass to
cls.decorator_dict
.
- Returns
decorator – A decorator that takes a
FileHandler
and returns an implementation of this class with the decoratedFileHandler
as itsUPLOAD
file (along with any other implementation attributes calculated by this class’sdecorator_dict
function using the newFileHandler
class,*args
, and**kwargs
as input). The generated classname will be namedcls.CLASSNAME_FMT.format(upload)
(whereupload
is the decoratedFileHandler
) and will be added as a variable with that name tonamespace
.- Return type
func
- Raises
TypeError – If there is only one positional argument provided which is itself a
type
(since this usually indicates that the developer forgot to call this method to get the actual decorator and instead applied this function as if it were a decorator to theFileHandler
class they intend to decorate).Exception –
decorator_dict
can, in principle, throw other exceptions as well. See the specific implementation for details.
-
-
llama.com.utils.
upload_flag_false
(eventdir)¶ Return whether a trigger directory has its “UPLOAD” flag set to “false”.