Skip to content
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

Regression with .copy Method on an Ecoinvent Activity #229

Open
omaggiori opened this issue Jan 14, 2025 · 0 comments
Open

Regression with .copy Method on an Ecoinvent Activity #229

omaggiori opened this issue Jan 14, 2025 · 0 comments

Comments

@omaggiori
Copy link

Context:

I recently upgraded Brightway data to version 4.3 from 4.0.dev46. I was previously copying an activity from ecoinvent to my foreground database to customize and analyze exchanges.

Environment Details:

  • Python version : 3.11
  • Ecoinvent version : 3.10
  • Other used libraries : bw2io (0.9.4)

Error :

The call to the recalculate method is failing as parameters from this copied activity seems not to be initialized.


Steps to Reproduce:

Here’s how to reproduce the issue, requiring username and password from ecoinvent to be set :

bw2data.projects.set_current("TEMPLATE 3.10")

bw2io.import_ecoinvent_release(
    version="3.10",
    system_model="cutoff",
)
eidb = bw2data.Database("ecoinvent-3.10-cutoff")
fgdb = bw2data.Database("foreground_db")
fgdb.register()
act = eidb.get(
    location="GLO",
    name="consumer electronics production, mobile device, smartphone",

)

copied = act.copy(name="copiedActivity", database="foreground_db")
bw2data.parameters.add_exchanges_to_group("LCA", activity=copied)
bw2data.parameters.recalculate()

Error Message :

{
	"name": "MissingName",
	"message": "The following variables aren't defined:
polyeth|steel|plugs|int_cable|pc|gl_fibre|lcd|brass|pwb|ind|el_speaker|datacable|BP_used_smartphone|tap_water_input|co|fraction_TW_to_air|el_conn|el_comp|ferrite|batt",
	"stack": "---------------------------------------------------------------------------
MissingName                               Traceback (most recent call last)
Cell In[13], line 11
      9 copied = act.copy(name=\"copiedActivity\", database=\"foreground_db\")
     10 bw2data.parameters.add_exchanges_to_group(\"LCA\", activity=copied)
---> 11 bw2data.parameters.recalculate()

File ~/.local/share/virtualenvs/test-brightway-iPK9PK7q/lib/python3.12/site-packages/bw2data/parameters.py:1621, in ParameterManager.recalculate(self)
   1619 if obj.name in databases or obj.name == \"project\":
   1620     continue
-> 1621 ActivityParameter.recalculate(obj.name)

File ~/.local/share/virtualenvs/test-brightway-iPK9PK7q/lib/python3.12/site-packages/bw2data/parameters.py:811, in ActivityParameter.recalculate(group, signal)
    808 if not ActivityParameter.expired(group):
    809     return
--> 811 chain = ActivityParameter.dependency_chain(group)
    813 # Reset dependencies and dependency order
    814 if chain:

File ~/.local/share/virtualenvs/test-brightway-iPK9PK7q/lib/python3.12/site-packages/bw2data/parameters.py:781, in ActivityParameter.dependency_chain(group, include_self)
    779         chain.append({\"kind\": \"project\", \"group\": \"project\", \"names\": names})
    780 if needed:
--> 781     raise MissingName(
    782         \"The following variables aren't defined:\
{}\".format(\"|\".join(needed))
    783     )
    785 return chain

MissingName: The following variables aren't defined:
polyeth|steel|plugs|int_cable|pc|gl_fibre|lcd|brass|pwb|ind|el_speaker|datacable|BP_used_smartphone|tap_water_input|co|fraction_TW_to_air|el_conn|el_comp|ferrite|batt"
}

Question:

Has anyone encountered an error with this .copy method ?

Thank you in advance for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant