ewokscore.variable.Variable#

class ewokscore.variable.Variable(value=<MISSING_DATA>, metadata=<MISSING_DATA>, varinfo=None, data_uri=None, data_proxy=None, pre_uhash=None, instance_nonce=None)[source]#

Bases: UniversalHashable

Has a runtime value (python object) and a persistent value (disk or memory). The location of the persistent value is either provided or derived from the universal hash of the variable, which itself can be provided or derived from the variable data.

Parameters:
  • value (Any) –

  • metadata (Any) –

  • varinfo (Optional[dict]) –

  • data_uri (Union[DataUri, str, None]) –

  • data_proxy (Optional[DataProxy]) –

  • pre_uhash (Union[str, bytes, UniversalHash, HasUhash, None]) –

  • instance_nonce (Optional[Any]) –

MISSING_DATA = <MISSING_DATA>#
classmethod class_nonce()#
classmethod class_nonce_data()#
cleanup_references()#

Remove all references to other hashables. Side effect: fixes the uhash when it depends on another hashable.

copy_without_references()[source]#

Copy that does not contain references to uhashable objects

property data_proxy: DataProxy | None#
property data_uri: DataUri | None#
deserialize(data)[source]#

Deserialize data after loading from persistent storage

Parameters:

data (dict) –

dump()[source]#

From runtime to persistent value (never overwrite). Creating the persistent value needs to be atomic.

This silently returns when: - data persistence is disabled - already persisted - data does not have a runtime value (MISSING_DATA) - non value URI can be constructed

Return type:

bool

fix_uhash()#

Fix the uhash when it is derived from the uhash data.

force_non_existing()[source]#
get_uhash_init(serialize=False)#
property has_persistent_value#
property has_runtime_value#
property has_value#
property hashing_enabled#
instance_nonce()#
is_missing()[source]#
Return type:

bool

load(raise_error=True)[source]#

From persistent to runtime value. This is called when try to get the value (lazy loading).

This silently returns when: - data persistence is disabled - uri is None (i.e. uhash is None) - raise_error=False

property metadata: dict#
serialize()[source]#

Serialize data before persistent storage

Return type:

dict

set_uhash_init(pre_uhash=None, instance_nonce=None)#
Parameters:
property uhash: UniversalHash | None#
uhash_randomize()#
undo_fix_uhash()#
undo_randomize()#
property value#