Module trase.tools.pcs.supply_chains.supply_chains

Supply chain objects.

Classes

class SupplyChain (flows=None, cur=None, flatten=True, fill_paths=True)

Collection of flows.

Ancestors

Instance variables

var commodity_sum

Return sum of commodity volumes of last steps of flows.

var sum

Return sum of volumes of flows.

Methods

def get_chunks(self, chunk_size=1000, chunks_by=None, disconnect=False)
def get_subchain(self, include=None, exclude=None)

Create supply chain object that contains only flows including nodes specified by their variable name or their attribute Node.name, and excluding specified nodes.

Keyword arguments: include – list of Node objects to include exclude – list of Node objects to exclude cur – main database cursor object

def show(self)

Full representation of supply chain; triggers creation of lazy attributes.

def show_flows(self)

Display flows on separate lines by groups of 24.

def to_csv(self, filepath)

Write supply chain to csv file. Keyword arguments: filepath – file path

def to_db(self, ref_id, overwrite=False, autocommit=True)

Write supply chain data to particular reference id. It is the caller's responsibility to ensure that the reference already exists.

The flows in this object will be appended to any flows that already exist (even if the new flows are identical to the old ones).

If reference node roles already exist, then they will be deleted and replaced with the reference node roles in this object.

:param overwrite: if true, first delete all data currently associated with the reference. The delete will be done in a transaction, so if there is a failure in the subsequent insertion of data, the deletion will not be visible.

Inherited members