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

Update openai and test codemodder without it #624

Merged
merged 3 commits into from
Jun 7, 2024
Merged

Conversation

clavedeluna
Copy link
Contributor

@clavedeluna clavedeluna commented Jun 4, 2024

I noticed we had openai declared both as a project dependency ( but that was not defined in all = ... and as a test dependency. I think just making it a project dependency this was is the correct way, but perhaps there was a different intention here?

Fixes a bug in codemodder if openai is not installed and test in CI to prevent it. Also updated the dependency.

Can currently open dependabot PR if this is merged.

@clavedeluna clavedeluna marked this pull request as ready for review June 4, 2024 15:17
Copy link
Member

@drdavella drdavella left a comment

Choose a reason for hiding this comment

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

@clavedeluna up til now we have included openai as an optional dependency so that users of OSS codemodder do not require the client if they're not using it. That's the reason for including it both in optional dependencies and in test dependencies since we do have unit tests that rely on it.

Until we have LLM codemods in this repo I might suggest keeping it that way.

@clavedeluna
Copy link
Contributor Author

clavedeluna commented Jun 4, 2024

@drdavella

@clavedeluna up til now we have included openai as an optional dependency so that users of OSS codemodder do not require the client if they're not using it. That's the reason for including it both in optional dependencies and in test dependencies since we do have unit tests that rely on it.

Until we have LLM codemods in this repo I might suggest keeping it that way.

I didn't say this outright in the PR description but the problem I see is that without openai getting installed as a project dependency, running codemodder fails

  File "/Users/dani/codemodder-python/src/codemodder/llm.py", line 47, in <module>
    def setup_llm_client() -> OpenAI | None:
                              ~~~~~~~^~~~~~
TypeError: unsupported operand type(s) for |: 'NoneType' and 'NoneType'

you can see this by not having openai in your environment and just running codemodder any way you like. Thankfully the issue is just a typing thing, but we weren't even aware of this because none of our environments test without openai installed. I can fix that typing issue but we'd have to test codemodder in a non-openai environment. But.... maybe just have it as a requirement?

@drdavella
Copy link
Member

drdavella commented Jun 6, 2024

@clavedeluna I still think we shouldn't require OpenAI as a dependency for this project right now. You are correct that there is an issue and thank you for identifying it. I believe the right fix is to add this at the top of the file:

from __future__ import annotations

And maybe it's a good idea to add a separate pipeline test step that just installs the codemodder package and runs codemodder --list to ensure that we don't have any other optional dependencies lurking.

Copy link

sonarcloud bot commented Jun 7, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@clavedeluna clavedeluna changed the title move and update openai dependency Update openai and test codemodder without it Jun 7, 2024
@clavedeluna clavedeluna added this pull request to the merge queue Jun 7, 2024
Merged via the queue into main with commit 461bab4 Jun 7, 2024
13 checks passed
@clavedeluna clavedeluna deleted the openai-dep branch June 7, 2024 14:54
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.

2 participants