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

Allow importing keras_nlp without tensorflow #1660

Merged
merged 3 commits into from
Jul 10, 2024

Conversation

mattdangerw
Copy link
Member

@mattdangerw mattdangerw commented Jun 4, 2024

This change does not break the dependency of tensorflow for all text
preprocessing, so most real world workflows will still require a
tensorflow install.

But this would allow running some modeling in Jax with all preprocessing
done with a separately library.

And most important, this will give friendly, actionable install
instructions the first time something is used that requires a
tensorflow install.

@mattdangerw mattdangerw changed the title Allow importing keras_nlp without no_tensorflow_test Allow importing keras_nlp without tensorflow Jun 4, 2024
@mattdangerw mattdangerw added the kokoro:force-run Runs Tests on GPU label Jun 4, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Runs Tests on GPU label Jun 4, 2024
@mattdangerw mattdangerw force-pushed the tf-import-better branch 3 times, most recently from 3cbc6f0 to 1a239bf Compare July 9, 2024 02:30
@mattdangerw mattdangerw added the kokoro:force-run Runs Tests on GPU label Jul 9, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Runs Tests on GPU label Jul 9, 2024
This change **does not** break the dependency of tensorflow for all text
preprocessing, so most real world workflows will still require a
tensorflow install.

But this would allow running some modeling in Jax with all preprocessing
done with a separately library.

And most important, this will give friendly, actionable install
instructions the first time something is used that requires a
tensorflow install.
Copy link
Member

@SamanehSaadat SamanehSaadat left a comment

Choose a reason for hiding this comment

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

Thanks, Matt! Just left some questions!

import keras_nlp


class NoTensorflow(unittest.TestCase):
Copy link
Member

Choose a reason for hiding this comment

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

Is this testing basic functions when TF is not installed? I'm curious to know how you make sure that TF is not installed for this test.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's in the actions.yml controlling github actions. When testing on jax and torch, as a last step we uninstall Tensorflow and run these tests.

This will give us some coverage is someone imports Tensorflow unconditionally. It should break this test.

Copy link
Member

Choose a reason for hiding this comment

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

Got it! Thanks for explaining!

import keras_nlp


class NoTensorflow(unittest.TestCase):
Copy link
Member

Choose a reason for hiding this comment

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

Got it! Thanks for explaining!

@mattdangerw mattdangerw merged commit be524fc into keras-team:master Jul 10, 2024
8 checks passed
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