basic_archive
BASIC_ENTITY_TYPES = ('quantity', 'flow')
module-attribute
LcArchive Stored Configuration.
add these objects with archive.add_config() applied in sequence with archive.apply_config()
BasicArchive
Bases: EntityStore
Adds on basic functionality to the archive interface: add new entities; deserialize entities.
The Basic Archive also introduces the Term Manager, which is used to handle flow characterization information.
Each archive must have a term manager; however, the same term manager can be shared among several archives. If no TermManager is provided at instantiation as an input argument, then the archive will create a captive term manager that only includes entities from that archive.
ALternatively, a term manager can be created first and supplied as an argument to each created archive, which would then allow them to share their terms in common with one another.
The BasicArchive should be used for all archives that only contain flows and quantities (and contexts in the future)
__getitem__(item)
Note: this user-friendliness check adds 20% to the execution time of getitem-- so avoid it if possible (use _get_entity directly -- especially now that upstream is now deprecated) (note that _get_entity does not get contexts)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item |
|
required |
Returns:
Type | Description |
---|---|
|
entity_from_json(e)
Create an LcEntity subclass from a json-derived dict
this could use some serious refactoring
Parameters:
Name | Type | Description | Default |
---|---|---|---|
e |
|
required |
Returns:
Type | Description |
---|---|
|
export_quantities(filename, *quantities, domesticate=True, values=True, gzip=False)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
|
required | |
quantities |
positional args are quantities to serialize |
()
|
|
domesticate |
[True- new archive becomes reference] if False, the qty source origin will remain canonical |
True
|
|
values |
[True- new archive stores cfs] if False the export will only include flowable+context lists |
True
|
|
gzip |
[False] whether to gzip the file |
False
|
Returns:
Type | Description |
---|---|
|
from_already_open_file(j, filename, ref=None, **kwargs)
classmethod
This is an in-between function that should probably be refactored away / folded into archive_from_json (which is the only place it's used)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
j |
|
required | |
filename |
|
required | |
ref |
incoming ref from catalog |
None
|
|
kwargs |
|
{}
|
Returns:
Type | Description |
---|---|
|
from_file(filename, ref=None, **init_args)
classmethod
BasicArchive factory from minimal dictionary. Must include at least one of 'dataSource' or 'dataReference' fields and 0 or more flows or quantities; but note that any flow present must have its reference quantities included. The method is inherited by LcArchives which permit processes as well; any process must have its exchanged flows (and their respective quantities) included.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
The name of the file to be loaded |
required | |
ref |
fallback reference to use if none is specified in source file |
None
|
Returns:
Type | Description |
---|---|
|
load_from_dict(j, _check=True, jsonfile=None)
Archives loaded from JSON files are considered static.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
j |
|
required | |
_check |
whether to run check_counter to print out statistics at the end |
True
|
|
jsonfile |
[None] if present, add to the list of sources for the canonical ref |
None
|
Returns:
Type | Description |
---|---|
|
search(etype=None, count=None, offset=None, **kwargs)
Implement pagination
Parameters:
Name | Type | Description | Default |
---|---|---|---|
etype |
|
None
|
|
count |
|
None
|
|
offset |
|
None
|
|
kwargs |
|
{}
|
Returns:
Type | Description |
---|---|
|
serialize(characterizations=False, values=False, domesticate=False)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
characterizations |
|
False
|
|
values |
|
False
|
|
domesticate |
[False] if True, omit entities' origins so that they will appear to be from the new archive upon serialization |
False
|
Returns:
Type | Description |
---|---|
|