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

Some extractor methods do not have the use_mp flag implemented, causing them to fail. #233

Open
riftia opened this issue Dec 2, 2023 · 1 comment

Comments

@riftia
Copy link

riftia commented Dec 2, 2023

When trying to import a database with bw2io.SingleOutputEcospold1Importer, there is a flag called use_mp that controls whether multiprocessing will be used or not. This flag is inherited by the default Ecospold1LCIAExtractor extractor class.
But if you want to change the default extractor to something else, for example, Ecospold1LCIAExtractor or the JSONLDExtractor, the import process fails because use_mp flag is not implemented in these non-default extractors.

>>> import bw2io
>>> from bw2io.extractors import ecospold1_lcia

>>> db_name = "eco38"
>>> importer = bw2io.SingleOutputEcospold1Importer(filepath=f, db_name=db_name, extractor=ecospold1_lcia.Ecospold1LCIAExtractor)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[/home/riftia/repo/p3op/test2.ipynb](https://file+.vscode-resource.vscode-cdn.net/home/riftia/repo/p3op/test2.ipynb) Cell 11 line 1
----> [1](vscode-notebook-cell:/home/riftia/repo/p3op/test2.ipynb#X21sZmlsZQ%3D%3D?line=0) i = bw2io.SingleOutputEcospold1Importer(filepath=f, db_name="eco38", extractor=ecospold1_lcia.Ecospold1LCIAExtractor)
      [2](vscode-notebook-cell:/home/riftia/repo/p3op/test2.ipynb#X21sZmlsZQ%3D%3D?line=1) i.statistics()

File [~/repo/p3op/.venv/lib/python3.10/site-packages/bw2io/importers/ecospold1.py:85](https://file+.vscode-resource.vscode-cdn.net/home/riftia/repo/p3op/~/repo/p3op/.venv/lib/python3.10/site-packages/bw2io/importers/ecospold1.py:85), in SingleOutputEcospold1Importer.__init__(self, filepath, db_name, use_mp, extractor)
     [83](https://file+.vscode-resource.vscode-cdn.net/home/riftia/repo/p3op/~/repo/p3op/.venv/lib/python3.10/site-packages/bw2io/importers/ecospold1.py:83) start = time()
     [84](https://file+.vscode-resource.vscode-cdn.net/home/riftia/repo/p3op/~/repo/p3op/.venv/lib/python3.10/site-packages/bw2io/importers/ecospold1.py:84) try:
---> [85](https://file+.vscode-resource.vscode-cdn.net/home/riftia/repo/p3op/~/repo/p3op/.venv/lib/python3.10/site-packages/bw2io/importers/ecospold1.py:85)     self.data = extractor.extract(filepath, db_name, use_mp=use_mp)
     [86](https://file+.vscode-resource.vscode-cdn.net/home/riftia/repo/p3op/~/repo/p3op/.venv/lib/python3.10/site-packages/bw2io/importers/ecospold1.py:86) except RuntimeError as e:
     [87](https://file+.vscode-resource.vscode-cdn.net/home/riftia/repo/p3op/~/repo/p3op/.venv/lib/python3.10/site-packages/bw2io/importers/ecospold1.py:87)     raise MultiprocessingError(
     [88](https://file+.vscode-resource.vscode-cdn.net/home/riftia/repo/p3op/~/repo/p3op/.venv/lib/python3.10/site-packages/bw2io/importers/ecospold1.py:88)         "Multiprocessing error; re-run using `use_mp=False`"
     [89](https://file+.vscode-resource.vscode-cdn.net/home/riftia/repo/p3op/~/repo/p3op/.venv/lib/python3.10/site-packages/bw2io/importers/ecospold1.py:89)     ).with_traceback(e.__traceback__)

TypeError: Ecospold1LCIAExtractor.extract() got an unexpected keyword argument 'use_mp'
@cmutel
Copy link
Member

cmutel commented Dec 4, 2023

This should be fixed in 28b9d76; @riftia could you check to make sure it is aligned with your expectations?

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

2 participants