Closed colombepey closed 2 years ago
Hi,
Have you initiliazed the DB beforehand with resetDb(USER_DB)
?
Also it seems you mistaking the name of the variable USER_DB
with it's content, unless the name of your db really is "USER_DB" ? In the example notebook it is "Foreground DB".
Please follow the example Notebook
Thank you, it works now, indeed I didn't use resetDb(USER_DB)
correctly.
Although my second remark still stands.
Hello, I have an issue using the function setForeground() My code : pdb_name = "USER_DB" pdb = bw.Database(pdb_name) la.setForeground(pdb_name)
Returns an error : KeyError: 'USER_DB'
Besides, in the documentation, there seems to be an error in the function setBackground which has the exact same definition as setForeground.
Thank for your help
KeyError: 'USER_DB'
KeyError Traceback (most recent call last) Input In [69], in <cell line: 10>() 4 # del bw.databases[pdb_name] 5 # user_db = bw.Database(pdb_name) 6 # user_db.write(dict()) 7 # la.setForeground(pdb_name) 9 pdb = bw.Database(pdb_name) ---> 10 la.setForeground(pdb_name)
File D:\Users\peyrussecol\Documents\Portable\miniconda\envs\inceracv\lib\site-packages\lca_algebraic\helpers.py:51, in setForeground(db_name) 49 def setForeground(db_name) : 50 """ Set a db as being a foreground database, meaning it is parametrized and lca_algebraic should develop its activities""" ---> 51 return _setMeta(db_name, FOREGROUND_KEY, True)
File D:\Users\peyrussecol\Documents\Portable\miniconda\envs\inceracv\lib\site-packages\lca_algebraic\helpers.py:28, in _setMeta(dbname, key, value) 25 """Set meta param on DB""" 26 _metaCache[dbname][key] = value ---> 28 data = dbmeta[dbname] 29 data[key] = value 30 dbmeta[dbname] = data
File D:\Users\peyrussecol\Documents\Portable\miniconda\envs\inceracv\lib\site-packages\bw2data\serialization.py:145, in SerializedDict.getitem(self, key) 143 if isinstance(key, list): 144 key = tuple(key) --> 145 return self.data[key]
KeyError: 'USER_DB'