Skip to content

[BUG] No module named 'power_grid_model._utils' #297

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

Open
Bjorn346 opened this issue May 8, 2025 · 7 comments
Open

[BUG] No module named 'power_grid_model._utils' #297

Bjorn346 opened this issue May 8, 2025 · 7 comments
Labels
bug Something isn't working

Comments

@Bjorn346
Copy link

Bjorn346 commented May 8, 2025

Describe the bug

When importing PgmJsonConverter, the error message 'ModuleNotFoundError: No module named 'power_grid_model._utils'' is appearing. The power_grid_model._utils does not exist anymore on that location, since version v1.10.107 of the Power-grid-model, but was moved to power_grid_model._core.utils.

To Reproduce

from power_grid_model_io.converters import PgmJsonConverter

Expected behavior

No error message in Pyhton

Output from commandline

Traceback (most recent call last):
File "c:*\Calc_MV_voltages.py", line 1, in
from power_grid_model_io.converters import VisionExcelConverter, PgmJsonConverter
File "C:*.venv\Lib\site-packages\power_grid_model_io\converters_init_.py", line 9, in
from power_grid_model_io.converters.pgm_json_converter import PgmJsonConverter
File "C:*.venv\Lib\site-packages\power_grid_model_io\converters\pgm_json_converter.py", line 16, in
from power_grid_model._utils import is_nan
ModuleNotFoundError: No module named 'power_grid_model._utils'

Suggested solution

Within file "src/power_grid_model_io/converters/pgm_json_converter.py" replace line 16 from
from power_grid_model._utils import is_nan to from power_grid_model._core.utils import is_nan

@Bjorn346 Bjorn346 added the bug Something isn't working label May 8, 2025
@Bjorn346 Bjorn346 changed the title [BUG] *No module named 'power_grid_model._utils'* [BUG] No module named 'power_grid_model._utils' May 8, 2025
@mgovers
Copy link
Member

mgovers commented May 8, 2025

Hi @Bjorn346 , you are completely right. We missed this.

@nitbharambe @Jerry-Jinfeng-Guo for compatibility, this also requires bumping power-gridmodel >= v1.10.x` but it may still be problematic for existing pgm-io versions if they version pin on older pgm versions.

The best solution is probably to do 2 PRs on the PGM-IO side to

  • first pin powe-grid-model < the version before emas PR and merge and release
  • and then apply this fix + bump power-grid-model >= version with ema's PR

@Bjorn346 you can maybe also do the fix.

EDIT: a more verbose but more robust way could be to do this on the power-grid-model side:

  • re-create power_grid_model._utils and import these functions and merge
  • then add to pgm-io the requirement power-grid-model < v1.11
  • then create a new PR on power-grid-model to remove power-grid_model._utils(to be merged for thev1.11.0` release)
  • create new PR to pgm-io to apply the suggested fix here + bump power-grid-model >= v1.11

@mgovers mgovers moved this to Q2 2025 in Power Grid Model May 8, 2025
@nitbharambe
Copy link
Member

@Bjorn346 Good find on the problem and the solution!
@mgovers The 2nd approach indeed seems better.

Cause relates to PowerGridModel/power-grid-model#787 and PowerGridModel/power-grid-model#784 where we made imports private and the issue originated from PowerGridModel/power-grid-model#953

@nitbharambe
Copy link
Member

Step 1: PowerGridModel/power-grid-model#988
Step 2: #298
Step 3: PowerGridModel/power-grid-model#989
Step 4: @Bjorn346 let us know if you wish to do this fix :)

@mgovers
Copy link
Member

mgovers commented May 8, 2025

@nitbharambe please also consider the option to copy-paste the is_nan functionality. It's basic and i don't think it's big enough to directly import it from PGM

@nitbharambe
Copy link
Member

@mgovers Since this has come up in discussion with @petersalemink95 / @Jerry-Jinfeng-Guo too, lets indeed do that instead.
For step 4, we copy the entire isnan into the file instead of importing it.

@nitbharambe please also consider the option to copy-paste the is_nan functionality. It's basic and i don't think it's big enough to directly import it from PGM

@Bjorn346
Copy link
Author

Bjorn346 commented May 8, 2025

I am personally not experienced with professional version-controlled developing, so @nitbharambe and @mgovers please go ahead with fixing the bug, as I genuinely don't know how to propose, pull-request and push fixes ;-).

@nitbharambe
Copy link
Member

Step 4: is_nan functionality copied: #299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Q2 2025
Development

No branches or pull requests

3 participants