You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
multiple databases ni a project, for example a background database and a foreground database,
the foreground database has inputs from the background database
calling the find_graph_dependents method of the foreground database does not provide the right depencies, unless calling process method.
I have observed this when creating databases as follows:
create foreground database -> db
register the database -> db.register()
create & save new nodes -> db.new_node(...).save()
create background database -> db_bg
register the database -> db_bg.register()
create & save new nodes -> db_bg.new_node(...).save()
create & save edges from foreground db to background db
using the following deps:
bw2data 4.3
bwcalc 2.0
bw2io 0.9.3
Expected
There is a difference in writing a full database with the write() method and adding nodes .
Is calling the "process" method of the database object a requirement ? Or maybe there is somewhere in the "save" method of activities and exchanges that this is being overlooked ?
# ---# jupyter:# jupytext:# formats: py:percent# text_representation:# extension: .py# format_name: percent# format_version: '1.3'# jupytext_version: 1.16.4# kernelspec:# display_name: Python 3 (ipykernel)# language: python# name: python3# ---# %%importbw2dataasbdimportbw2calcasbcimportbw2ioasbi# %%print(bd.__version__)
print(bc.__version__)
print(bi.__version__)
# (4, 3)# 2.0# 0.9.3# %%bi.remote.install_project("ecoinvent-3.10-biosphere", "bk-project", overwrite_existing=True)
# %%bd.projects.set_current("bk-project")
# %%bd.databases# %%db=bd.Database('bike')
db.register()
# %%bd.databases# %%# First activity: the bikedata= {
'code': 'bike',
'name': 'bike production',
'location': 'DK',
'unit': 'bike'
}
bike=db.new_node(**data)
bike.save()
# %%bike.id# 123372841738444800# %%db_bg=bd.Database('materials')
db_bg.register()
# %%# First inputdata= {
'code': 'ng',
'name': 'natural gas production',
'location': 'NO',
'unit': 'MJ'
}
ng=db_bg.new_node(**data)
ng.save()
# Second inputdata= {
'code': 'cf',
'name': 'carbon fibre production',
'location': 'DE',
'unit': 'kg'
}
cf=db_bg.new_node(**data)
cf.save()
# %%bd.databases# %%# We add the exchange to the bike activity, from the carbon fiber prodbike.new_edge(
amount=2.5,
type='technosphere',
input=cf
).save()
# %%# Verify by printing the exchanges of the bikea_bike=db.get('bike')
foreina_bike.exchanges():
print(e)
# %%# Add another exchange to the carbon fiber productioncf.new_edge(
amount=237.3, # plus 58 kWh of electricity, in ecoinvent 3.8 uncertainty_type=5,
minimum=200,
maximum=300,
type='technosphere',
input=ng,
).save()
# %%# dependent dbsdb.find_graph_dependents()
# {'bike'}# %%db.metadata['depends']
# [ ]# %%db.process()
# %%db.find_graph_dependents()
# {'bike', 'materials'}# %%db.metadata['depends']
# ['materials']
The text was updated successfully, but these errors were encountered:
Current
In a
scenariocontext with:calling the find_graph_dependents method of the foreground database does not provide the right depencies, unless calling
process
method.I have observed this when creating databases as follows:
db
db.register()
db.new_node(...).save()
db_bg
db_bg.register()
db_bg.new_node(...).save()
using the following deps:
Expected
There is a difference in writing a full database with the
write()
method and adding nodes .Is calling the "process" method of the database object a requirement ? Or maybe there is somewhere in the "save" method of activities and exchanges that this is being overlooked ?
The text was updated successfully, but these errors were encountered: