Skip to content

Conversation

sampathweb
Copy link
Collaborator

@sampathweb sampathweb commented Apr 23, 2024

With the change in keras3 to use src and api folders, the from keras import * inside keras_nlp/backend/keras.py doesn't import the src namespace.

To fix this -

  1. Renamed the keras.py to keras2.py
  2. Handle the import of keras in backend/__init__.py

This change has no impact to the users since its only required for accessing private files in Tests.

@sampathweb sampathweb added the kokoro:force-run Runs Tests on GPU label Apr 23, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Runs Tests on GPU label Apr 23, 2024
@sampathweb sampathweb added the kokoro:force-run Runs Tests on GPU label Apr 23, 2024
@kokoro-team kokoro-team removed the kokoro:force-run Runs Tests on GPU label Apr 23, 2024
from keras_nlp.backend import config

if config.keras_3():
from keras import * # noqa: F403, F401
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious to know that now that we don't have keras.py anymore and the Keras import is handled in the __init__.py, how from keras_nlp.backend import keras works.

Copy link
Collaborator Author

@sampathweb sampathweb Apr 23, 2024

Choose a reason for hiding this comment

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

It will import keras3 directly from __init__.py or keras2.py as keras.

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, Ramesh!

@fchollet fchollet merged commit 6720c23 into keras-team:master Apr 23, 2024
@sampathweb sampathweb deleted the fix-keras-import branch April 23, 2024 18:12
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.

4 participants