Skip to content

local

Code for generating a catalog populated with local data sources. This is where active workflow development can occur. See GitHub root / workflow.txt for thoughts.

MAIN IDEA: local.py: The local config file. specifies source locations and resource-specific configurations for data sources. It must define the following variables: CATALOG_ROOT = location to build a permanent data catalog TEST_ROOT = location to store temporary test materials (blown away after every use) RESOURCES_CONFIG = a dict mapping source nicknames to instantiation parameters. The instantiation parameters have two required keys: 'source': key whose value is an executable DataSource subclass 'enable_test': key whose absence (or falsity) will suppress tests. All other kv pairs in the dict are passed as input arguments to the DataSource.

data_source.py: provides an abstract class for specifying data sources. Each data source should be defined as a subclass of DataSource that implements its interface.

tests/test_local.py: uses local.py to generate and validate the persistent catalog at the location specified in CATALOG_ROOT.

TO ADD A NEW DATA SOURCE:

  1. Produce a resource factory for your data source.

1a. Create or locate an appropriate DataSource subclass, and implement its abstract methods: references: generate a list of semantic references the class knows how to instantiate interfaces(ref): generate a list of interfaces known for the given ref (ref must be in references) make_resources(ref): generate an exhaustive sequence of LcResource objects for a given ref

1b. Make sure the resources created by your DataSource subclass include any necessary configuration information

  1. Provide configuration info for your data source

2a. Import your DataSource subclass here.

2b. Create an entry in RESOURCES_CONFIG with at minimum the 'source' and 'enable_test' keys, as well as any necessary input arguments.

  1. Run python -m unittest lcatools/data_sources/tests/test_local.py

RESOURCES_CONFIG = {'ipcc2007': {'source': GwpIpcc2007, 'enable_test': True}, 'uslci': {'source': UsLciConfig, 'enable_test': True}, 'traci': {'source': TraciConfig, 'data_root': '/data/LCI/TRACI/', 'enable_test': True}} module-attribute

RESOURCES_CONFIG_LOCAL = { 'ecoinvent': { 'source': EcoinventConfig, 'data_root': '/data/LCI/Ecoinvent/', 'enable_test': False }, 'calrecycle': { 'source': CalRecycleConfig, 'data_root': '/data/GitHub/CalRecycle/LCA_Data/', 'enable_test': False }, 'ecoinvent_lcia': { 'source': EcoinventLciaConfig, 'version': '3.1', 'data_root': '/data/LCI/Ecoinvent/LCIA/', 'enable_test': False } }

RESOURCES_CONFIG.update(RESOURCES_CONFIG_LOCAL) # still trying to figure out the best way to do this