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

[Install] Rework optional imports #767

Merged

Conversation

riedgar-ms
Copy link
Collaborator

@riedgar-ms riedgar-ms commented Apr 18, 2024

Trying to make optional imports behave more uniformly, with support in setup.py for lots of possible extras.

@riedgar-ms
Copy link
Collaborator Author

Tagging @ryanpeach @hudson-ai and @Harsha-Nori , since I'm sure you will all have suggestions :-)

So far, I've just done some work on adding a schemas extra, which handles jsonschema and pydantic. I have also added an extra job to the QA workflow, to make sure that the minimal install can be imported successfully.

setup.py Outdated
@@ -52,8 +52,8 @@ def find_version(*file_paths):
],
extras_require={
"docs": ["ipython", "numpydoc", "sphinx_rtd_theme", "sphinx", "nbsphinx"],
"schemas": ["jsonschema", "pydantic"],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Next up would be server and all of the various supported models (each in their own extras).

@codecov-commenter
Copy link

codecov-commenter commented Apr 18, 2024

Codecov Report

Attention: Patch coverage is 86.95652% with 6 lines in your changes are missing coverage. Please review.

Project coverage is 62.49%. Comparing base (9862750) to head (d91b18a).

Files Patch % Lines
guidance/_server.py 76.92% 3 Missing ⚠️
guidance/library/_json.py 62.50% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #767      +/-   ##
==========================================
- Coverage   65.69%   62.49%   -3.21%     
==========================================
  Files          55       55              
  Lines        4064     4058       -6     
==========================================
- Hits         2670     2536     -134     
- Misses       1394     1522     +128     

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

guidance/_grammar.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
@riedgar-ms riedgar-ms changed the title Rework optional imports [Install] Rework optional imports Apr 19, 2024
@riedgar-ms
Copy link
Collaborator Author

@ryanpeach and @Harsha-Nori , I've updated this in response to comments, and also extracted openai as an 'extra.' While doing this, I discovered that pydantic is actually a dependency of openai, thereby explaining why some things surprising things had been working.

I have tried to give pydantic the same treatment, but I was unable to get things working. I could see pip install pydantic, but then fail to load pydantic.json-schema which was a bit strange.

@slundberg
Copy link
Collaborator

Thanks @riedgar-ms! I also ran into this when I dropped the openai dep. LGTM

@ryanpeach
Copy link
Contributor

Much better!

@ryanpeach
Copy link
Contributor

Tbh pydantic might become a useful required dependency. Ever thought of just keeping it?

@riedgar-ms
Copy link
Collaborator Author

Tbh pydantic might become a useful required dependency. Ever thought of just keeping it?

I'm keeping it required for now. It is something which might be worth keeping generally.

@Harsha-Nori
Copy link
Collaborator

Harsha-Nori commented Apr 19, 2024

LGTM too. I'm also ok with Pydantic being a required import per @ryanpeach's suggestion

@riedgar-ms riedgar-ms merged commit 947792a into guidance-ai:main Apr 19, 2024
96 checks passed
@riedgar-ms riedgar-ms deleted the riedgar-ms/optional-import-rework branch April 19, 2024 17:46
@hudson-ai
Copy link
Collaborator

Sorry for being late to the party! Looks good. Thanks @riedgar-ms

This pull request was closed.
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.

6 participants