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

Incorrect import when there are two files with the same name but in different directories #209

Closed
khatchad opened this issue Jul 21, 2024 · 1 comment · Fixed by ponder-lab/ML#123 or #212
Assignees
Labels
bug Something isn't working PYTHONPATH

Comments

@khatchad
Copy link
Collaborator

khatchad commented Jul 21, 2024

I am seeing an import statement in an initialization file (__init__.py) import the wrong file when there's (at least) two files with the same name but in different directories. For example, consider the following initialization script:

https://github.com/kyzhouhzau/NLPGNN/blob/b9ecec2c6df1b3e40a54511366dcb6085cf90c34/nlpgnn/models/__init__.py#L14-L15

We should import bert.py from the models package. However, in the logs, I am seeing the following:

adding 260 = global:global script nlpgnn/models/albert.py at 122 to PreBB1:0..121
adding 260 = fieldref 260.259 at 123 to PreBB1:0..122
...
adding 262 = global:global script tests/GNN/BERT-TextGCN/bert.py at 125 to PreBB1:0..124
adding 262 = fieldref 262.259 at 126 to PreBB1:0..125
...

Here, albert.py is correct---it comes from models. However, bert.py comes from a test file when it should come from models.

Regression

In this project, there's only one albert.py but two bert.pys. Somehow, we're selecting the wrong one.

Thoughts

We may have missed changes when adding PYTHONPATH when translating from PYTHON to CAst (CAst to IR looks OK).

@khatchad khatchad added bug Something isn't working PYTHONPATH labels Jul 21, 2024
@khatchad khatchad self-assigned this Jul 21, 2024
khatchad added a commit to ponder-lab/ML that referenced this issue Jul 22, 2024
khatchad added a commit to ponder-lab/ML that referenced this issue Jul 22, 2024
khatchad added a commit to ponder-lab/ML that referenced this issue Jul 22, 2024
khatchad added a commit to ponder-lab/ML that referenced this issue Jul 23, 2024
@khatchad khatchad linked a pull request Jul 23, 2024 that will close this issue
khatchad added a commit to ponder-lab/ML that referenced this issue Jul 23, 2024
@khatchad
Copy link
Collaborator Author

While not completely correct for a different reason, I added a small enhancement that seems to be avoiding this issue. I am now seeing in the logs:

adding 260 = global:global script nlpgnn/models/albert.py at 122 to PreBB1:0..121
adding 260 = fieldref 260.259 at 123 to PreBB1:0..122
...
adding 262 = global:global script nlpgnn/models/bert.py at 124 to PreBB1:0..123
adding 262 = fieldref 262.259 at 125 to PreBB1:0..124

It's now picking the correct bert.py by choosing the one in the same (or sub) directory for the script being parsed.

khatchad added a commit to ponder-lab/ML that referenced this issue Jul 24, 2024
khatchad added a commit that referenced this issue Jul 24, 2024
msridhar pushed a commit that referenced this issue Nov 8, 2024
Sorry for the large sync up. I'll try to summarize the changes as best
as I can:

- Start a `CODEOWNERS` file (please modify if desired).
- Add dependabot build schedule.
- Move Black out of spotless and into the build (much faster; spotless
support for Black is not working well).
- Various formatting fixes as a result of expanding spotless to XML
files and others.
- Make other metadata consistent with "recent" change to Java upgrade.
- `PYTHONPATH` module fixes (e.g.,
#209).
- Workaround #195.
- Enhance TF2 tests: fail if we don't have a node for a function under
test (was passing before). Because the ML tests are still on Jython 2
and modules aren't supported there, we have a bunch of tests to
consider.
- Initialization script enhancements (e.g.,
#202).
- Add `reshape()` parsing (this causes a need for a workaround after
exposing a bug).
- Some dependency version upgrades.
- Various entry point additions, e.g., `abseil`, `click`.
- Add missing initialization files (`__init__.py`).

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PYTHONPATH
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant