From c188ac66f2c5ecf3ba80c7f1443e0cb90eea102a Mon Sep 17 00:00:00 2001 From: Jonas Eschle Date: Mon, 14 Oct 2024 20:12:51 -0700 Subject: [PATCH] PR #779: Fix pip build Imported from GitHub PR https://github.com/keras-team/tf-keras/pull/779 As discussed in #776 I tried but actually run into the issue that layers/experimental cannot be used as a build target, as the builds _inside_ experimental _require_ layers -> circular deps. The other folders in `layers` circumvent this by specifying only the specific build targets. Instead of changing the logic (i.e. is experimental meant to be dev-built only?), I did what the error advertised and added it to the ignored builds, as it's seemingly not made to be built Copybara import of the project: -- 9d3bb64a50014181aa5aab057645df78475cb21e by Jonas Eschle : docs: update CONTRIBUTING.md with new name tf-keras (cherry picked from commit fb79960f0a694272a7f5328c88bf55e16581be06) -- 7bd7b3dcae8abc0d966f82a5ef769508659d9f0c by Jonas Eschle : fix: python build ignore experimental due to circular refs (cherry picked from commit 9b349e3898aa167cf3eca4a45519b20e6505befe) Merging this change closes #779 FUTURE_COPYBARA_INTEGRATE_REVIEW=https://github.com/keras-team/tf-keras/pull/779 from jonas-eschle:fix_pip_build 7bd7b3dcae8abc0d966f82a5ef769508659d9f0c PiperOrigin-RevId: 685927076 --- CONTRIBUTING.md | 16 ++++++++-------- tf_keras/tools/pip_package/create_pip_helper.py | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bc152441c..72e93997c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ development environment and run the unit tests. This is covered in the section ### Step 3. Create a pull request Once the change is ready, open a pull request from your branch in your fork to -the master branch in [keras-team/keras](https://github.com/keras-team/keras). +the master branch in [keras-team/tf-keras](https://github.com/keras-team/tf-keras). ### Step 4. Sign the Contributor License Agreement @@ -149,8 +149,8 @@ as a dependency, we need to uninstall `keras-nightly` so that tests will run against TF-Keras code in the local workspace. ```shell -git clone https://github.com/YOUR_GITHUB_USERNAME/keras.git -cd keras +git clone https://github.com/YOUR_GITHUB_USERNAME/tf-keras.git +cd tf-keras pip install -r requirements.txt pip uninstall keras-nightly ``` @@ -220,14 +220,14 @@ We use [Bazel](https://bazel.build/) to build and run the tests. ### Run a test file -For example, to run the tests in `keras/engine/base_layer_test.py`, +For example, to run the tests in `tf_keras/engine/base_layer_test.py`, we can run the following command at the root directory of the repo. ```shell -bazel test keras/engine:base_layer_test +bazel test tf_keras/engine:base_layer_test ``` -`keras/engine` is the relative path to the directory containing the `BUILD` file +`tf_keras/engine` is the relative path to the directory containing the `BUILD` file defining the test. `base_layer_test` is the test target name defined with `tf_py_test` in the `BUILD` file. @@ -239,7 +239,7 @@ can use the following command to run all the tests in `activations_test.py`, whose names contain `test_serialization`. ``` -bazel test keras:activations_test --test_filter=*test_serialization* +bazel test tf_keras:activations_test --test_filter=*test_serialization* ``` ### Run all tests @@ -267,7 +267,7 @@ command above. However, it may slow down the tests for not running in parallel and may cause the test to timeout. -## Contributing to TF-Keras applications +## Contributing to TF-tf_keras applications Contributions to the [pre-trained application library](https://keras.io/api/applications/) are diff --git a/tf_keras/tools/pip_package/create_pip_helper.py b/tf_keras/tools/pip_package/create_pip_helper.py index 65401cfa9..676ec4753 100644 --- a/tf_keras/tools/pip_package/create_pip_helper.py +++ b/tf_keras/tools/pip_package/create_pip_helper.py @@ -37,6 +37,7 @@ PIP_EXCLUDED_DIRS = frozenset( [ "tf_keras/benchmarks", + "tf_keras/layers/experimental", # cannot build currently, circular refs "tf_keras/tests", ] ) @@ -45,6 +46,7 @@ EXCLUDED_INIT_FILE_DIRECTORIES = frozenset( [ "tf_keras/benchmarks", + "tf_keras/layers/experimental", "tf_keras/tools", ] )