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 subclassing UploadReceipt.

class_vetoes = ((<function upload_flag_false>, None),)
classmethod decorator_dict(upload)

See UploadReceipt.upload_this. Takes the decorated FileHandler 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 the FILENAME and DEPENDENCIES attributes based on subclass.UPLOAD.

classmethod upload_this(*args, namespace=None, **kwargs)

Return a decorator that automatically uploads FileHandler classes by implementing this class with that FileHandler class as the UPLOAD attribute. Additional attributes are set by cls.decorator_dict using the FileHandler class decorated by the returned decorator, *args, and **kwargs.

  • *args – Positional arguments to pass to cls.decorator_dict (after the FileHandler class decorated by the returned decorator, which takes the first positional argument position).
  • namespace (dict, optional) – The namespace to which the new UploadReceipt created by decorator will be added. The default behavior is to define UploadReceipt in the global namespace of the calling frame (so that using the decorator is equivalent to manually defining the UploadReceipt class with the decorated FileHandler as its upload immediately after defining the FileHandler to be decorated).
  • **kwargs – Keyword arguments to pass to cls.decorator_dict.

decorator – A decorator that takes a FileHandler and returns an implementation of this class with the decorated FileHandler as its UPLOAD file (along with any other implementation attributes calculated by this class’s decorator_dict function using the new FileHandler class, *args, and **kwargs as input). The generated classname will be named cls.CLASSNAME_FMT.format(upload) (where upload is the decorated FileHandler) and will be added as a variable with that name to namespace.

Return type:


  • 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 the FileHandler class they intend to decorate).
  • Exceptiondecorator_dict can, in principle, throw other exceptions as well. See the specific implementation for details.

Return whether a trigger directory has its “UPLOAD” flag set to “false”.