Skip to content

Conversation

@qued
Copy link
Contributor

@qued qued commented Oct 11, 2023

PR to make to make packaging a little nicer, in line with how packaging works in unstructured. In particular, support for extras is added.

This consists of:

  • Adding the file sg.in for dependencies related to supergradients. This file has been pip-compiled with output sg.txt.
  • All dependencies have been pip-compiled.
  • Adding the file constraints.in to add a numpy constraint that is required for compliance with supergradients. Dependencies that precede sg.in need to know about this to avoid conflicts. constraints.in is added as a constraints file for all other dependency files.
  • make targets are added for installing supergradients dependencies.
  • CI is updated to install supergradients dependencies.
  • supergradients extra is added to setup.py and MANIFEST.in so it can be picked up by PyPi.
  • To support the fact that the supergradients dependencies are not guaranteed to be installed, the way imports are handled in the super_gradients.py model file has been changed so imports are only attempted in the model constructor, in a module-level global variable. The constructor was used instead of doing the import in initialize due to an error that occurred during import when initiated from initialize.

Testing

From a fresh pyenv environment, and from the base folder of unstructured-inference:

pip install -e .
pip list | grep gradient

(There should be no output, as supergradients should not be installed.)

Now:

pip install -e ."[supergradients]"
pip list | grep gradient

(Output should show super-gradients is installed.)

@qued qued marked this pull request as ready for review October 13, 2023 15:19
Copy link
Contributor

@pravin-unstructured pravin-unstructured left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@qued qued enabled auto-merge (squash) October 14, 2023 00:54
@qued qued merged commit dbb203a into main Oct 14, 2023
@qued qued deleted the build/improve-packaging branch October 14, 2023 01:07
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.

3 participants