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

Fix imports #1491

Merged
merged 5 commits into from
Jun 15, 2024
Merged

Fix imports #1491

merged 5 commits into from
Jun 15, 2024

Conversation

rasbt
Copy link
Collaborator

@rasbt rasbt commented Jun 14, 2024

Fixes an import issue Aaron was having.

Copy link
Member

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

@rasbt It would be nice if you could paste the error you got into the PR description. If the import order matters, it is often a sign of circular imports. And if that's the case, we should try to remove the circular dependency.

@rasbt
Copy link
Collaborator Author

rasbt commented Jun 14, 2024

Good point @awaelchli . In this case it was not the circular dependency but issues with relative imports:

Traceback (most recent call last):
  File "/teamspace/studios/this_studio/server.py", line 15, in <module>
    from litgpt.generate.base import generate, next_token
  File "/teamspace/studios/this_studio/litgpt/litgpt/generate/base.py", line 17, in <module>
    from litgpt import GPT, Config, PromptStyle, Tokenizer
ImportError: cannot import name 'GPT' from 'litgpt' (unknown location)

@awaelchli
Copy link
Member

But we don't have any relative imports LitGPT. Of course, the expectation is that the package is installed. Did the user not install the package? How could changing the import order fix something like that?

@rasbt
Copy link
Collaborator Author

rasbt commented Jun 14, 2024

I don't know exactly why it is happening, but it's not the order but changing

from litgpt import GPT

to

from litgpt.model import GPT

etc.

I remember having similar issues when implementing the API in #1463 even though I have LitGPT installed as a package. I don't fully understand why it's happening.

@rasbt
Copy link
Collaborator Author

rasbt commented Jun 14, 2024

Maybe @apaz-cli can provide more context here.

@rasbt rasbt merged commit a4aebcd into main Jun 15, 2024
9 checks passed
@rasbt rasbt deleted the fix-imports branch June 15, 2024 14:11
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.

None yet

2 participants