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

Being more explicit with the import of importlib.util. #181

Merged
merged 2 commits into from
Jan 23, 2025

Conversation

drewoldag
Copy link
Collaborator

This seems to address the issue that was raised in issue #108. Still not immediately clear why this is sometimes an issue, but it seems to be.

@drewoldag drewoldag requested a review from mtauraso January 23, 2025 19:58
@drewoldag drewoldag self-assigned this Jan 23, 2025
@drewoldag drewoldag linked an issue Jan 23, 2025 that may be closed by this pull request
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 38.99%. Comparing base (c829885) to head (17cb213).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #181      +/-   ##
==========================================
+ Coverage   38.93%   38.99%   +0.06%     
==========================================
  Files          23       23              
  Lines        1983     1985       +2     
==========================================
+ Hits          772      774       +2     
  Misses       1211     1211              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Jan 23, 2025

Before [c829885] After [1733175] Ratio Benchmark (Parameter)
3.66±0.6s 2.43±1s ~0.66 benchmarks.time_computation
560 824 1.47 benchmarks.mem_list

Click here to view all benchmarks.

@@ -155,7 +156,7 @@ def _find_external_library_default_config_paths(runtime_config: dict) -> set:
else:
if key == "name" and "." in value:
external_library = value.split(".")[0]
if importlib.util.find_spec(external_library) is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK that is really weird.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if some package deep in fibad or KBMOD's dep tree is conditionally replacing functions in importlib.util?

Copy link
Collaborator Author

@drewoldag drewoldag Jan 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we start python on the command line and run the following on baldur in an environment that shares a kbmod installation

>>> import importlib
>>> importlib.ut <attempt tab complete, nothing happens>
>>> importlib.util
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'importlib' has no attribute 'util'

It does seem unpleasant, but it seems to work.

Outside of a KBMOD environment, there's no problem with:

>>> import importlib
>>> importlib.util

@drewoldag drewoldag merged commit 50ba387 into main Jan 23, 2025
8 checks passed
@drewoldag drewoldag deleted the issue/108/importlib-error branch January 23, 2025 21:19
drewoldag added a commit that referenced this pull request Jan 24, 2025
* Being more explicit with the import of importlib.util.

* Importing importlib.util in the one other place it is used.
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

Successfully merging this pull request may close these issues.

AttributeError: module 'importlib' has no attribute 'util'
2 participants