brightway-lca / brightway2-data

Tools for the management of inventory databases and impact assessment methods. Part of the Brightway LCA framework.
https://docs.brightway.dev/
BSD 3-Clause "New" or "Revised" License
8 stars 21 forks source link

Update utils.py #75

Closed bsteubing closed 3 years ago

bsteubing commented 3 years ago

Hi Chris, something like this would be very useful to have at the level of brightway...

bsteubing commented 3 years ago

Hi Chris, I wouldn't know right now how to add a good test for this... if you could handle that, that would be really great as I think it would take you a fraction of the time I would need for this...

cmutel commented 3 years ago

OK, I will make a test case.

BenPortner commented 3 years ago

This PR breaks my bw. With the latest master version I receive an error when importing brightway:

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\benjamin.portner\programs\miniconda\envs\bw_dev\lib\site-packages\brightway2\__init__.py", line 2, in <module>
    from bw2data import *
  File "C:\Users\benjamin.portner\programs\miniconda\envs\bw_dev\lib\site-packages\bw2data\__init__.py", line 33, in <module>
    from .project import projects
  File "C:\Users\benjamin.portner\programs\miniconda\envs\bw_dev\lib\site-packages\bw2data\project.py", line 6, in <module>
    from .utils import maybe_path
  File "C:\Users\benjamin.portner\programs\miniconda\envs\bw_dev\lib\site-packages\bw2data\utils.py", line 5, in <module>
    from .project import ProjectDataset, SubstitutableDatabase
ImportError: cannot import name 'ProjectDataset' from partially initialized module 'bw2data.project' (most likely due to a circular import) (C:\Users\benjamin.portner\programs\miniconda\envs\bw_dev\lib\site-packages\bw2data\project.py)

Could it be that there are files missing in the commit?

bsteubing commented 3 years ago

@cmutel I am not sure what goes wrong in Ben's case... do you know?

BenPortner commented 3 years ago

@cmutel This problem persists. I cannot develop on the current master branch due to the changes.

BenPortner commented 3 years ago

Think I found the reason: project.py : from .utils import maybe_path utils.py: from .project import ProjectDataset, SubstitutableDatabase --> circular import