Writer

The Jobber class is responsible to evaluate the configuration settings and to execute the computations in parallel tasks (using the celery framework and the message queue RabbitMQ).

The writer Module

Base classes for the output methods of the various codecs.

class openquake.engine.writer.CacheInserter(dj_model, max_cache_size)[source]

Bases: object

Bulk insert bunches of Django objects by converting them in strings and by using COPY FROM.

add(obj)[source]
Parameters:obj – a Django model object

Append an object to the list of objects to save. If the list exceeds the max_cache_size, flush it on the database.

static array_to_pgstring(a)[source]

Convert a Python list/array into the Postgres string-representation of it.

fields

Returns the field names as introspected from the db, except the id field. The introspection is done only once per table. NB: we cannot trust the ordering in the Django model.

flush()[source]

Save the pending objects on the database with a COPY FROM.

classmethod flushall()[source]

Flush the caches of all the instances of CacheInserter.

instances = <_weakrefset.WeakSet object>
classmethod saveall(objects, block_size=1000)[source]

Save a sequence of Django objects in the database in a single transaction, by using a COPY FROM. Returns the ids of the inserted objects.

to_line(obj)[source]

Convert the fields of a Django object into a line string suitable for import via COPY FROM. The encoding is UTF8.