-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IntegrityError: NOT NULL constraint failed: exchangedataset.input_code #187
Comments
Can you tell which premise version do you use? These errors appear in the Activity-Browser terminal? The project in which premise exports the database has the mention "25" in it: is it because it is created with brightway 2.5? If so, any brightway25-generated database cannot be read in Activity-Browser yet. AB only reads bw2-generated databases. Also, when you say:
Is it during premise execution? Can you print |
I am using version 2.1.9 importing a ecospold file. The error appears in when I run the code in jupyter notebook. The outputs such as ('Vanadium V', ('water', 'ground-, long-term'), 'kilogram', '3.7') not found in biosphere dictionary. are generated in the premise execution. And I run it in brightway 2 environment, it shows brightway25 because I previously run it in bw25 environment in another trail and did not change the name. The name of the environment is activity-browser because I also downloaded ab in the environment. packages in environment at C:\Users.conda\envs\activity-brower:Name Version Build Channelab-plugin-scenariolink 0.1.1 py_0 romainsacchi |
I tried to create a new environment and run the same code. The error and the output of " not found in biosphere dictionary": remains. Could it be the result of the unlinked changes when importing the database? |
OK. The message outputs given by premise regarding biosphere flows like:
is normal. That is because the biosphere database of ecoinvent 3.7 does not have all the biosphere flows required by the new inventories premise imports. So these flows are just ignored. |
But I doubt this is related to that other issue you mention:
If I understand correctly, this error occurs when you use the databases through |
Yes, "activity-browser " is the name of the environment I run the code through. |
Hi @OliverLyon, unfortunately, I could not reproduce your error. I exported a superstructure database with the same scenarios and the same ei 3.7.1 database as you used, and I ran it with Activity Browser (same version) and obtained some results. Are you able to export your faulty AB project (Project -> Export project) and somehow send it to me via file transfer? |
Hi @romainsacchi, Sorry about the confusion of activity-browser. I am not using the activity browser in this case. "acrtivity-browser" is just the name of the environment I created since I installed brightway2, activity browser and premise in this environment. The code went well when extracting the 3.7.1 database and creating new database with inbuilt scenarios. base_setup_with_ecoinvent( from premise import NewDatabase bd.projects.set_current("bw2_project_test") scenarios = [ ndb = NewDatabase( The only part that have and error is the superstructure output: ndb.write_superstructure_db_to_brightway(name="bw_project_test_superstructure"), At this stage I have not import the superstructure to activity browser yet. |
Can you maybe run:
and try the script again? |
Thank you for the reply. I tried this: But the error remains: |
Is "ecoinvent_3.7.1_cutoff_ecoSpold02" a brightway database in a brightway project that you installed from ecospold2 files? My advice would be to create a new brightway project, with a new biosphere and ecoinvent database and try again. Could eb that something went wrong during the import and is now creating some issue. |
Yes, "ecoinvent_3.7.1_cutoff_ecoSpold02" is the brightway database I installed from a ecospold2 file. I tried to directly import the ecospold2 file instead of from brightway project then I'm not receiving the previous error. Now I have a new error for writing the superstructure: Is it related to the biosphere database name it requires me to type in when running the code? I tried to type in biosphere3 alternatively, then I get the following error when writing superstructure database: |
|
I restarted the kernel, now it comes back to the previous error: |
I tried to transform the in built scenarios into superstructure databases, and I received the following error:
IntegrityError Traceback (most recent call last)
File ~.conda\envs\activity-browser\Lib\site-packages\peewee.py:3322, in Database.execute_sql(self, sql, params, commit)
3321 cursor = self.cursor()
-> 3322 cursor.execute(sql, params or ())
3323 return cursor
IntegrityError: NOT NULL constraint failed: exchangedataset.input_code
And I also got a number of outputs such as: ('Vanadium V', ('water', 'ground-, long-term'), 'kilogram', '3.7') not found in biosphere dictionary.
Does anyone know why this is happening and how to solve this? I pasted the code I use below.
Thanks.
base_setup_with_ecoinvent(
"bw25_project_test",
"ecoinvent_3.7.1_cutoff_ecoSpold02",
r"C:\Users\Desktop\EcoInvent\ecoinvent 3.7.1_cutoff_ecoSpold02\datasets",
reparametrize_lognormals=True,
)
from premise import NewDatabase
from datapackage import Package
from premise import *
bd.projects.set_current("bw25_project_test")
scenarios = [
{"model": "REMIND", "pathway": "SSP1-NPi", "year": 2020},
{"model": "REMIND", "pathway": "SSP1-NPi", "year": 2030},
{"model": "REMIND", "pathway": "SSP1-NPi", "year": 2040},
{"model": "REMIND", "pathway": "SSP1-NPi", "year": 2050},
]
ndb = NewDatabase(
scenarios=scenarios,
#scenarios=[
# {"model": "image", "pathway": "SSP2-Base", "year": 2050}
#],
source_db="ecoinvent_3.7.1_cutoff_ecoSpold02",
source_version="3.7.1",
key='tUePmX_S5B8ieZkkM7WUU2CnO8SmShwmAeWK9x2rTFo=',
use_cached_inventories=True, # This will use any cached inventories
keep_source_db_uncertainty=False, # False by default, set to True if you want to keep ecoinvent's uncertainty data
keep_imports_uncertainty=False, # False by default, set to True if you want to keep the uncertainty data of the additional inventories
use_absolute_efficiency=False, # False by default, set to True if you want to use the IAM's absolute efficiencies
)
The text was updated successfully, but these errors were encountered: