Base exception for parsimony.
Extend this for defining exceptions.
Generates the key value using the function and supplied parameters.
Parameters: |
|
---|---|
Returns: | value generated by the function |
Mark the key for mandatory regeneration.
This can be done at any time before or after a generator is executed. The value for the generator will be removed from any underlying, attached, stores and caches if needed then regenerated upon a generate() call
Parameters: | key – |
---|---|
Returns: |
Gets the configured call wrapper. Currently, a default of PickledCallableWrapper is chosen.
Return callable_wrapper: | |
---|---|
CallableWrapper Generator object |
Gets the configured obfuscator. Currently, a default of SHA512Obfuscator is chosen.
Return obfuscator: | |
---|---|
Obfuscator object |
Gets the configured default store. Currently, a default of PickledStore is chosen.
Return store: | Store object |
---|
Returns the configured cache. Currently, a default of MemCache is returned
Returns: |
---|
Return the directory to store parsimony data in.
Returns: | .parsimony |
---|
Get the context name
Returns: | Current context name |
---|
Set the context name. This should be something that can be a directory name.
Generator abstract base class. This is the core object for cached generation.
Internal method to store the value in storage.
This method may be overriden in subclasses. Do not use externally.
Returns: | generated value |
---|
Generate the object referred to by the key.
If the object has never been generated before, the necessary work to create it is performed and the object is cached in a ParameterStore.
If the object has been generated, but the parameters have changed, the object is regenerated and the ParameterStore is overwritten.
Return generated_value: | |
---|---|
The value for this generator’s key. |
Return a parameter based on key.
Parameters: | parameter_key – |
---|---|
Returns: | parameter matching the parameter key |
Get the key of this Generator
Return key: | string |
---|
Internal method to load the value from storage.
This method may be overriden in subclasses. Do not use externally.
Returns: | generated value |
---|
Internal method to regenerate the value based on current parameters.
This method must be overriden in subclasses. Do not use externally.
Returns: | generated value |
---|
Indicate if the generated value is fresh or stale with respect to non-parmeter changes. In the case of completely parameter driven values this will always be true. In the case of external objects or persisted data, it must be checked appropriately.
This may be overridden in subclasses. :return: True if the value is fresh.
Generator for callables using that stores results.
Call the callable with parameters to generate the value
Returns: | generated value |
---|
Monitors the path for changes. This is primarily useful as a parameter key
No need to deal with persistence since this generator is completely defined by it’s parameters.
No need to deal with persistence since this generator is completely defined by it’s parameters. :return: the path
Returns the path :return: the path
Determines if the file has been modified.
Returns: | If file timestamp has changed or not |
---|
Allows a text file to be treated as a generateable object.
The mechanism is to load the file once and any time the file has been subsequently modified.
This is by definition already stored. Do nothing.
Reads all of the file contents into a string.
Returns: | text file contents |
---|
Loads the file data.
Returns: | self.load() |
---|
Interface for data hashers
Obfuscation is the method to make easily comparable, storage efficent, potentially secure versions of the data.
Create the hashed data representation
This is method must be overridden by subclasses.
Parameters: | data – data to obfuscate |
---|---|
Returns: | obfuscated representation such as a hash |
DataObfuscator that uses the SHA512 hashing mechanism.
Generate SHA512 of the hashable data representation
Parameters: | data – data to obfuscate |
---|---|
Returns: | hash |
A store is an object that implements read and write capabilities for key-ed values
Method to retrieve the persisted value of this store.
Must be overridden by subclasses.
Returns: | the saved value from this store |
---|
Method to persist a value in this store
Must be overridden by subclasses.
Store that uses the local file system and pickle as the underlying mechanism.
Pickle load the stored value
Dump the value to the pickle store
Parameters: | value – value to dump |
---|
Interface of a Cache object. Cache’s are responsible for persisting parameter values and determining parameter equality.
Compare the stored value to the given value
Must be overridden by subclasses.
Parameters: |
|
---|---|
Returns: | equality test |
Get the parameter sub-keys for the given generator key
Must be overridden by subclasses.
Parameters: | key – Generator key |
---|---|
Returns: | list of key |
Store new value for the parameter.
Must be overridden by subclasses.
Parameters: |
|
---|
Parameter Cache that will bring parameters from a store into local memory if it exists and persist updates to the store.
Update the memory cache and store
Parameters: |
|
---|