openpathsampling.storage.stores.CVStore

class openpathsampling.storage.stores.CVStore[source]

ObjectStore to store a dict with StorableObject : value

__init__()[source]
Parameters:
  • content_class

  • json (bool or str json or jsonobj) – if False the store will not create a json variable for serialization if True the store will use the json pickling to store objects and a single storable object will be serialized and not referenced. If a string is given the string is taken as the variable type of the json variable. Here only two values are allowed: jsonobj (equivalent to True) or json which will also reference directly given storable objects.

  • nestable (bool) – if True this marks the content_class to be saved as nested dict objects and not a pointing to saved objects. So the saved complex object is only stored once and not split into several objects that are referenced by each other in a tree-like fashion

Notes

Usually you want caching, but limited. Recommended is to use an LRUCache with a reasonable maximum number of objects that depends on the typical number of objects to cache and their size

The class that takes care of storing data in a file is called a Storage, so the netCDF+ subclassed Storage is a storage. The classes that know how to load and save an object from the storage are called Store, like ObjectStore, SampleStore, etc…

The difference between json and jsonobj is subtle. Consider storing a complex object. Then there are two ways to do that. 1. json: Store a reference to the object (provided) it is stored and 2. jsonobj: serialize the object and only use references for contained objects. All inner objects will always be stored using references. The only exception is using nestable. Consider objects that contain references to objects of the same type, like e.g. operations in an equation (2*3 + 3). Each operation represents a value but each operation needs values to operate on. To save such an object you have again two options: 1. nestable=False. Store all single objects and always reference the contained objects. For an equation that would mean to store several objects op1 = plus(op2, 3), op2 = times(2, 3). Since this is correct though not intuitive you can also use 2. nestable=True. Store all the serialized objects nested into one object (string). For our example this corresponds to plus(times(2,3), 3).

Methods

__init__()

add_attribute(store_cls, attribute, template)

add_diskcache(cv[, template, ...])

Return the storage.vars[''] variable that contains the values

add_single_to_cache(idx, json)

Add a single object to cache by json

add_single_to_cache_named(idx, name, json)

Add a single object to cache by json

args()

Return a list of args of the __init__ function of a class

base()

Return the most parent class actually derived from StorableObject

cache_all()

Fill the caches of all CVs

cache_store(cv)

Return the storage.vars[''] variable that contains the values

clear_cache()

Clear the cache and force reloading

complete(cv)

Call the related complete function to precompute values for all objects

complete_all()

Complete all attributes

complete_attribute(attribute)

Compute all missing values of a CV and store them

count_weaks()

Return number of objects subclassed from StorableObject still in memory

create_uuid_index()

create_variable(var_name, var_type[, ...])

Create a new variable in the netCDF storage.

descendants()

Return a list of all subclassed objects

find(name)

Return last object with a given name

find_all(name)

find_indices(name)

Return indices for all objects with a given name

fix_name()

Set the objects name to be immutable.

forget(obj)

This will revert remembering non-stored objects.

free()

Return the number of the next free index for this store

from_dict(dct)

Reconstruct an object from a dictionary representaiton

get(item)

get_uuid()

has_cache(cv)

Test weather a CV has a diskstore attached

idx(obj)

Return the index in this store for a given object

initialize()

Initialize the associated storage to allow for object storage.

is_created()

is_name_locked(name)

Test whether in a unique name store a name is already taken

key_store(cv)

Return the store that saves the key objects

load(idx)

Returns an object from the storage.

load_indices()

named(name)

Name an unnamed object.

objects()

Returns a dictionary of all storable objects

pos(obj)

pos_uuid(uid)

prefix_delegate(dct)

proxy(item)

Return a proxy of a object for this store

reference(obj)

register(storage, prefix)

Associate the object store to a specific storage with a given prefix

register_fallback(store)

release_name(name)

Releases a locked name

remember(obj)

Tell a store that an obj should be assumed as stored

reserve_name(name)

Locks a name as used

restore()

reverse_uuid()

ruuid(uid)

save(obj[, idx])

Saves an object to the storage.

set_cache_store(cv)

Sets the attached storage of a CV to this store

set_caching(caching)

Set the caching mode for this store

set_dimension_prefix_store([prefix_store])

Select which store or none should be used to prefix dimension names

set_observer(active)

(De-)Activate observing creation of storable objects

sync(cv)

This will update the stored cache of the attribute.

sync_all()

Sync all attribute caches to disk

sync_attribute(attribute)

Store all cached values of a CV in the diskcache

to_dict()

Convert object into a dictionary representation

update_name_cache()

Update the internal name cache with all stored names in the store.

write(variable, idx, obj[, attribute])

Attributes

ACTIVE_LONG

CREATION_COUNT

INSTANCE_UUID

allowed_types

base_cls

Return the base class

base_cls_name

Return the name of the base class

cls

Return the class name as a string

default_cache

default_name

Return the default name.

default_store_chunk_size

dimension_prefix

first

Returns the first stored object.

is_named

True if this object has a custom name.

last

Returns the last generated trajectory.

name

Return the current name of the object.

name_idx

Returns a dictionary of all names pointing to stored indices

observe_objects

simplifier

Return the simplifier instance used to create JSON serialization

storage

Return the associated storage object