llama.intent module

Classes for tracking whether files are cooling down after a failed generation attempt or are currently being generated.

class llama.intent.CoolDown(eventdir, manifest_filehandlers)

Bases: llama.classes.RiderFile, llama.classes.JsonRiderMixin

An object for keeping track of whether a particular file failed to generate recently and determining how long the pipeline should wait before trying again to generate it. Instances of this class are meant to be calculated as properties from FileHandlers and similar classes.

Parameters:
  • manifest (list) – List of names of the files that need to be generated (and which might fail, necessitating a cooldown countdown).
  • eventdir (str) – Path to the directory containing that file.
in_progress()

Determine whether a cooldown is still in progress for generating this file, i.e. whether this file generation routine failed too recently for another generation attempt.

rider_fmt = '.{}.cooldown.json'
write()

Write a json file with the name .<FILENAME>.cooldown.json for each file in the manifest containing the time of the last attempt at generating the file as well as the number of consecutive failed attempts at generating the file. Format is

{
“num_attempts”: 3, “last_attempt”: “2016-09-12T17:16:20.337867”

}

Where last_attempt in particular is an ISO formatted time string.

class llama.intent.Intent(eventdir, manifest_filehandlers)

Bases: llama.classes.RiderFile, llama.classes.JsonRiderMixin

An object tracking intent to make a file. Tracks whether another process should start making this file. Saves the timestamp at which intent expires to a rider file for each file in a FileHandler’s manifest.

in_progress()

Check whether this file is already being generated and has not timed out yet.

rider_fmt = '.{}.intent.json'
write(timeout)

Write the timeout (as a UNIX timestamp) at which this file has timed out and another file can attempt to generate it.

llama.intent.utcnow()

Return a new datetime representing UTC day and time.