We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Update tensorflow-hub requirement to allow 0.12.0?
If the feature is related to a specific library below, please raise an issue in
the respective repo directly:

[TensorFlow Data Validation Repo](https://github.com/tensorflow/data-validation/issues)

[TensorFlow Model Analysis Repo](https://github.com/tensorflow/model-analysis/issues)

[TensorFlow Transform Repo](https://github.com/tensorflow/transform/issues)

[TensorFlow Serving Repo](https://github.com/tensorflow/serving/issues)

**System information**

- TFX Version (you are using):  1.0.0-rc0
- Environment in which you plan to use the feature (e.g., Local
  (Linux/MacOS/Windows), Interactive Notebook, Google Cloud, etc..): MacOS, AWS
- Are you willing to contribute it (Yes/No): Yes

**Describe the feature and the current behavior/state.**
tfx (1.0.0-rc0) currently depends on tensorflow-hub (>=0.9.0,<0.10)

I was wondering if we could update tensorflow-hub dependancy for tfx to allow tf-hub 0.12.0, so something like (>=0.9.0,<=0.12.0)?

I am not sure if that would break anything in tfx, but I am happy to investigate and contribute to this change

**Will this change the current API? How?**
No

**Who will benefit with this feature?**
tensorflow-hub has added some new features in 0.10.0 and beyond (specifically the one I'm interested in "`compute_output_shape` in `hub.KerasLayer`" which they added in 0.12.0). It would be cool to be able to take advantage of those while still being able to use tfx

**Do you have a workaround or are completely blocked by this?** :
Blocked

**Name of your Organization (Optional)**


**Any Other info.**


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `tfx/dependencies.py`
Content:
```
1 # Copyright 2019 Google LLC. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """Package dependencies for TFX.
15 
16 tfx and family libraries (such as tensorflow-model-analysis) adopts environment
17 variable (TFX_DEPENDENCY_SELECTOR) based dependency version selection. This
18 dependency will be baked in to the wheel, in other words you cannot change
19 dependency string once wheel is built.
20 
21 - UNCONSTRAINED uses dependency without any version constraint string, which is
22   useful when you manually build wheels of parent library (e.g. tfx-bsl) of
23   arbitrary version, and install it without dependency constraints conflict.
24 - NIGHTLY uses x.(y+1).0.dev version as a lower version constraint. tfx nightly
25   will transitively depend on nightly versions of other TFX family libraries,
26   and this version constraint is required.
27 - GIT_MASTER uses github master branch URL of the dependency, which is useful
28   during development, or when depending on the github master HEAD version of
29   tfx. This is because tfx github master HEAD version is actually using github
30   master HEAD version of parent libraries.
31   Caveat: URL dependency is not upgraded with --upgrade flag, and you have to
32   specify --force-reinstall flag to fetch the latest change from each master
33   branch HEAD.
34 - For the release, we use a range of version, which is also used as a default.
35 """
36 import os
37 
38 
39 def select_constraint(default, nightly=None, git_master=None):
40   """Select dependency constraint based on TFX_DEPENDENCY_SELECTOR env var."""
41   selector = os.environ.get('TFX_DEPENDENCY_SELECTOR')
42   if selector == 'UNCONSTRAINED':
43     return ''
44   elif selector == 'NIGHTLY' and nightly is not None:
45     return nightly
46   elif selector == 'GIT_MASTER' and git_master is not None:
47     return git_master
48   else:
49     return default
50 
51 
52 def make_pipeline_sdk_required_install_packages():
53   return [
54       'absl-py>=0.9,<0.13',
55       'ml-metadata' + select_constraint(
56           # LINT.IfChange
57           default='>=1.0.0,<1.1.0',
58           # LINT.ThenChange(tfx/workspace.bzl)
59           nightly='>=1.1.0.dev',
60           git_master='@git+https://github.com/google/ml-metadata@master'),
61       'packaging>=20,<21',
62       'portpicker>=1.3.1,<2',
63       'protobuf>=3.12.2,<4',
64       'docker>=4.1,<5',
65       # TODO(b/176812386): Deprecate usage of jinja2 for placeholders.
66       'jinja2>=2.7.3,<3',
67   ]
68 
69 
70 def make_required_install_packages():
71   # Make sure to sync the versions of common dependencies (absl-py, numpy,
72   # and protobuf) with TF.
73   return make_pipeline_sdk_required_install_packages() + [
74       'apache-beam[gcp]>=2.29,<3',
75       'attrs>=19.3.0,<21',
76       'click>=7,<8',
77       'google-api-python-client>=1.7.8,<2',
78       'google-cloud-aiplatform>=0.5.0,<0.8',
79       'google-cloud-bigquery>=1.28.0,<3',
80       'grpcio>=1.28.1,<2',
81       # TODO(b/173976603): remove pinned keras-tuner upperbound when its
82       # dependency expecatation with TensorFlow is sorted out.
83       'keras-tuner>=1,<1.0.2',
84       'kubernetes>=10.0.1,<12',
85       # TODO(b/179195488): remove numpy dependency after 1.20 migration.
86       # This dependency was added only to limit numpy 1.20 installation.
87       'numpy>=1.16,<1.20',
88       'pyarrow>=1,<3',
89       'pyyaml>=3.12,<6',
90       'tensorflow>=1.15.2,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,<3',
91       'tensorflow-hub>=0.9.0,<0.10',
92       'tensorflow-data-validation' + select_constraint(
93           default='>=1.0.0,<1.1.0',
94           nightly='>=1.1.0.dev',
95           git_master='@git+https://github.com/tensorflow/data-validation@master'
96       ),
97       'tensorflow-model-analysis' + select_constraint(
98           default='>=0.31,<0.32',
99           nightly='>=0.32.0.dev',
100           git_master='@git+https://github.com/tensorflow/model-analysis@master'
101       ),
102       'tensorflow-serving-api>=1.15,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,<3',
103       'tensorflow-transform' + select_constraint(
104           default='>=1.0.0,<1.1.0',
105           nightly='>=1.1.0.dev',
106           git_master='@git+https://github.com/tensorflow/transform@master'),
107       'tfx-bsl' + select_constraint(
108           default='>=1.0.0,<1.1.0',
109           nightly='>=1.1.0.dev',
110           git_master='@git+https://github.com/tensorflow/tfx-bsl@master'),
111   ]
112 
113 
114 def make_extra_packages_airflow():
115   """Prepare extra packages needed for Apache Airflow orchestrator."""
116   return [
117       # TODO(b/188940096): update supported version.
118       'apache-airflow[mysql]>=1.10.14,<3',
119       # TODO(b/182848576): Delete pinned sqlalchemy after apache-airflow 2.0.2
120       # or later.(github.com/apache/airflow/issues/14811)
121       'sqlalchemy>=1.3,<1.4',
122   ]
123 
124 
125 def make_extra_packages_kfp():
126   """Prepare extra packages needed for Kubeflow Pipelines orchestrator."""
127   return [
128       'kfp>=1.6.1,<2',
129       'kfp-pipeline-spec>=0.1.7,<0.2',
130   ]
131 
132 
133 def make_extra_packages_test():
134   """Prepare extra packages needed for running unit tests."""
135   # Note: It is okay to pin packages to exact versions in this list to minimize
136   # conflicts.
137   return make_extra_packages_airflow() + make_extra_packages_kfp() + [
138       'pytest>=5,<6',
139   ]
140 
141 
142 def make_extra_packages_docker_image():
143   # Packages needed for tfx docker image.
144   return [
145       'kfp-pipeline-spec>=0.1.7,<0.2',
146       'mmh>=2.2,<3',
147       'python-snappy>=0.5,<0.6',
148   ]
149 
150 
151 def make_extra_packages_tfjs():
152   # Packages needed for tfjs.
153   return [
154       'tensorflowjs>=3.6.0,<4',
155   ]
156 
157 
158 def make_extra_packages_tf_ranking():
159   # Packages needed for tf-ranking which is used in tfx/examples/ranking.
160   return [
161       'tensorflow-ranking>=0.3.3,<0.4',
162       'struct2tensor' + select_constraint(
163           default='>=0.31,<0.32',
164           nightly='>=0.32.0.dev',
165           git_master='@git+https://github.com/google/struct2tensor@master'),
166   ]
167 
168 
169 def make_extra_packages_examples():
170   # Extra dependencies required for tfx/examples.
171   return [
172       # Required for presto ExampleGen custom component in
173       # tfx/examples/custom_components/presto_example_gen
174       'presto-python-client>=0.7,<0.8',
175       # Required for slack custom component in
176       # tfx/examples/custom_components/slack
177       'slackclient>=2.8.2,<3',
178       'websocket-client>=0.57,<1',
179       # Required for bert examples in tfx/examples/bert
180       'tensorflow-text>=1.15.1,<3',
181       # Required for tfx/examples/cifar10
182       'flatbuffers>=1.12,<2',
183       'tflite-support>=0.1.0a1,<0.1.1',
184       # Required for tfx/examples/penguin/experimental
185       # LINT.IfChange
186       'scikit-learn>=0.23,<0.24',
187       # LINT.ThenChange(
188       #     examples/penguin/experimental/penguin_pipeline_sklearn_gcp.py)
189       # Required for the experimental tfx/examples using Flax, e.g.,
190       # tfx/examples/penguin.
191       'jax>=0.2.13,<0.3',
192       'jaxlib>=0.1.64,<0.2',
193       'flax>=0.3.3,<0.4',
194       # Required for tfx/examples/penguin/penguin_utils_cloud_tuner.py
195       'tensorflow-cloud>=0.1,<0.2',
196   ]
197 
198 
199 def make_extra_packages_all():
200   # All extra dependencies.
201   return [
202       *make_extra_packages_test(),
203       *make_extra_packages_tfjs(),
204       *make_extra_packages_tf_ranking(),
205       *make_extra_packages_examples(),
206   ]
207
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/tfx/dependencies.py b/tfx/dependencies.py
--- a/tfx/dependencies.py
+++ b/tfx/dependencies.py
@@ -88,7 +88,7 @@
       'pyarrow>=1,<3',
       'pyyaml>=3.12,<6',
       'tensorflow>=1.15.2,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,<3',
-      'tensorflow-hub>=0.9.0,<0.10',
+      'tensorflow-hub>=0.9.0,<=0.12.0',
       'tensorflow-data-validation' + select_constraint(
           default='>=1.0.0,<1.1.0',
           nightly='>=1.1.0.dev',
@@ -97,8 +97,7 @@
       'tensorflow-model-analysis' + select_constraint(
           default='>=0.31,<0.32',
           nightly='>=0.32.0.dev',
-          git_master='@git+https://github.com/tensorflow/model-analysis@master'
-      ),
+          git_master='@git+https://github.com/tensorflow/model-analysis@master'),
       'tensorflow-serving-api>=1.15,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,<3',
       'tensorflow-transform' + select_constraint(
           default='>=1.0.0,<1.1.0',

{"golden_diff": "diff --git a/tfx/dependencies.py b/tfx/dependencies.py\n--- a/tfx/dependencies.py\n+++ b/tfx/dependencies.py\n@@ -88,7 +88,7 @@\n       'pyarrow>=1,<3',\n       'pyyaml>=3.12,<6',\n       'tensorflow>=1.15.2,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,<3',\n-      'tensorflow-hub>=0.9.0,<0.10',\n+      'tensorflow-hub>=0.9.0,<=0.12.0',\n       'tensorflow-data-validation' + select_constraint(\n           default='>=1.0.0,<1.1.0',\n           nightly='>=1.1.0.dev',\n@@ -97,8 +97,7 @@\n       'tensorflow-model-analysis' + select_constraint(\n           default='>=0.31,<0.32',\n           nightly='>=0.32.0.dev',\n-          git_master='@git+https://github.com/tensorflow/model-analysis@master'\n-      ),\n+          git_master='@git+https://github.com/tensorflow/model-analysis@master'),\n       'tensorflow-serving-api>=1.15,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,<3',\n       'tensorflow-transform' + select_constraint(\n           default='>=1.0.0,<1.1.0',\n", "issue": "Update tensorflow-hub requirement to allow 0.12.0?\nIf the feature is related to a specific library below, please raise an issue in\r\nthe respective repo directly:\r\n\r\n[TensorFlow Data Validation Repo](https://github.com/tensorflow/data-validation/issues)\r\n\r\n[TensorFlow Model Analysis Repo](https://github.com/tensorflow/model-analysis/issues)\r\n\r\n[TensorFlow Transform Repo](https://github.com/tensorflow/transform/issues)\r\n\r\n[TensorFlow Serving Repo](https://github.com/tensorflow/serving/issues)\r\n\r\n**System information**\r\n\r\n- TFX Version (you are using):  1.0.0-rc0\r\n- Environment in which you plan to use the feature (e.g., Local\r\n  (Linux/MacOS/Windows), Interactive Notebook, Google Cloud, etc..): MacOS, AWS\r\n- Are you willing to contribute it (Yes/No): Yes\r\n\r\n**Describe the feature and the current behavior/state.**\r\ntfx (1.0.0-rc0) currently depends on tensorflow-hub (>=0.9.0,<0.10)\r\n\r\nI was wondering if we could update tensorflow-hub dependancy for tfx to allow tf-hub 0.12.0, so something like (>=0.9.0,<=0.12.0)?\r\n\r\nI am not sure if that would break anything in tfx, but I am happy to investigate and contribute to this change\r\n\r\n**Will this change the current API? How?**\r\nNo\r\n\r\n**Who will benefit with this feature?**\r\ntensorflow-hub has added some new features in 0.10.0 and beyond (specifically the one I'm interested in \"`compute_output_shape` in `hub.KerasLayer`\" which they added in 0.12.0). It would be cool to be able to take advantage of those while still being able to use tfx\r\n\r\n**Do you have a workaround or are completely blocked by this?** :\r\nBlocked\r\n\r\n**Name of your Organization (Optional)**\r\n\r\n\r\n**Any Other info.**\r\n\n", "before_files": [{"content": "# Copyright 2019 Google LLC. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Package dependencies for TFX.\n\ntfx and family libraries (such as tensorflow-model-analysis) adopts environment\nvariable (TFX_DEPENDENCY_SELECTOR) based dependency version selection. This\ndependency will be baked in to the wheel, in other words you cannot change\ndependency string once wheel is built.\n\n- UNCONSTRAINED uses dependency without any version constraint string, which is\n  useful when you manually build wheels of parent library (e.g. tfx-bsl) of\n  arbitrary version, and install it without dependency constraints conflict.\n- NIGHTLY uses x.(y+1).0.dev version as a lower version constraint. tfx nightly\n  will transitively depend on nightly versions of other TFX family libraries,\n  and this version constraint is required.\n- GIT_MASTER uses github master branch URL of the dependency, which is useful\n  during development, or when depending on the github master HEAD version of\n  tfx. This is because tfx github master HEAD version is actually using github\n  master HEAD version of parent libraries.\n  Caveat: URL dependency is not upgraded with --upgrade flag, and you have to\n  specify --force-reinstall flag to fetch the latest change from each master\n  branch HEAD.\n- For the release, we use a range of version, which is also used as a default.\n\"\"\"\nimport os\n\n\ndef select_constraint(default, nightly=None, git_master=None):\n  \"\"\"Select dependency constraint based on TFX_DEPENDENCY_SELECTOR env var.\"\"\"\n  selector = os.environ.get('TFX_DEPENDENCY_SELECTOR')\n  if selector == 'UNCONSTRAINED':\n    return ''\n  elif selector == 'NIGHTLY' and nightly is not None:\n    return nightly\n  elif selector == 'GIT_MASTER' and git_master is not None:\n    return git_master\n  else:\n    return default\n\n\ndef make_pipeline_sdk_required_install_packages():\n  return [\n      'absl-py>=0.9,<0.13',\n      'ml-metadata' + select_constraint(\n          # LINT.IfChange\n          default='>=1.0.0,<1.1.0',\n          # LINT.ThenChange(tfx/workspace.bzl)\n          nightly='>=1.1.0.dev',\n          git_master='@git+https://github.com/google/ml-metadata@master'),\n      'packaging>=20,<21',\n      'portpicker>=1.3.1,<2',\n      'protobuf>=3.12.2,<4',\n      'docker>=4.1,<5',\n      # TODO(b/176812386): Deprecate usage of jinja2 for placeholders.\n      'jinja2>=2.7.3,<3',\n  ]\n\n\ndef make_required_install_packages():\n  # Make sure to sync the versions of common dependencies (absl-py, numpy,\n  # and protobuf) with TF.\n  return make_pipeline_sdk_required_install_packages() + [\n      'apache-beam[gcp]>=2.29,<3',\n      'attrs>=19.3.0,<21',\n      'click>=7,<8',\n      'google-api-python-client>=1.7.8,<2',\n      'google-cloud-aiplatform>=0.5.0,<0.8',\n      'google-cloud-bigquery>=1.28.0,<3',\n      'grpcio>=1.28.1,<2',\n      # TODO(b/173976603): remove pinned keras-tuner upperbound when its\n      # dependency expecatation with TensorFlow is sorted out.\n      'keras-tuner>=1,<1.0.2',\n      'kubernetes>=10.0.1,<12',\n      # TODO(b/179195488): remove numpy dependency after 1.20 migration.\n      # This dependency was added only to limit numpy 1.20 installation.\n      'numpy>=1.16,<1.20',\n      'pyarrow>=1,<3',\n      'pyyaml>=3.12,<6',\n      'tensorflow>=1.15.2,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,<3',\n      'tensorflow-hub>=0.9.0,<0.10',\n      'tensorflow-data-validation' + select_constraint(\n          default='>=1.0.0,<1.1.0',\n          nightly='>=1.1.0.dev',\n          git_master='@git+https://github.com/tensorflow/data-validation@master'\n      ),\n      'tensorflow-model-analysis' + select_constraint(\n          default='>=0.31,<0.32',\n          nightly='>=0.32.0.dev',\n          git_master='@git+https://github.com/tensorflow/model-analysis@master'\n      ),\n      'tensorflow-serving-api>=1.15,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,<3',\n      'tensorflow-transform' + select_constraint(\n          default='>=1.0.0,<1.1.0',\n          nightly='>=1.1.0.dev',\n          git_master='@git+https://github.com/tensorflow/transform@master'),\n      'tfx-bsl' + select_constraint(\n          default='>=1.0.0,<1.1.0',\n          nightly='>=1.1.0.dev',\n          git_master='@git+https://github.com/tensorflow/tfx-bsl@master'),\n  ]\n\n\ndef make_extra_packages_airflow():\n  \"\"\"Prepare extra packages needed for Apache Airflow orchestrator.\"\"\"\n  return [\n      # TODO(b/188940096): update supported version.\n      'apache-airflow[mysql]>=1.10.14,<3',\n      # TODO(b/182848576): Delete pinned sqlalchemy after apache-airflow 2.0.2\n      # or later.(github.com/apache/airflow/issues/14811)\n      'sqlalchemy>=1.3,<1.4',\n  ]\n\n\ndef make_extra_packages_kfp():\n  \"\"\"Prepare extra packages needed for Kubeflow Pipelines orchestrator.\"\"\"\n  return [\n      'kfp>=1.6.1,<2',\n      'kfp-pipeline-spec>=0.1.7,<0.2',\n  ]\n\n\ndef make_extra_packages_test():\n  \"\"\"Prepare extra packages needed for running unit tests.\"\"\"\n  # Note: It is okay to pin packages to exact versions in this list to minimize\n  # conflicts.\n  return make_extra_packages_airflow() + make_extra_packages_kfp() + [\n      'pytest>=5,<6',\n  ]\n\n\ndef make_extra_packages_docker_image():\n  # Packages needed for tfx docker image.\n  return [\n      'kfp-pipeline-spec>=0.1.7,<0.2',\n      'mmh>=2.2,<3',\n      'python-snappy>=0.5,<0.6',\n  ]\n\n\ndef make_extra_packages_tfjs():\n  # Packages needed for tfjs.\n  return [\n      'tensorflowjs>=3.6.0,<4',\n  ]\n\n\ndef make_extra_packages_tf_ranking():\n  # Packages needed for tf-ranking which is used in tfx/examples/ranking.\n  return [\n      'tensorflow-ranking>=0.3.3,<0.4',\n      'struct2tensor' + select_constraint(\n          default='>=0.31,<0.32',\n          nightly='>=0.32.0.dev',\n          git_master='@git+https://github.com/google/struct2tensor@master'),\n  ]\n\n\ndef make_extra_packages_examples():\n  # Extra dependencies required for tfx/examples.\n  return [\n      # Required for presto ExampleGen custom component in\n      # tfx/examples/custom_components/presto_example_gen\n      'presto-python-client>=0.7,<0.8',\n      # Required for slack custom component in\n      # tfx/examples/custom_components/slack\n      'slackclient>=2.8.2,<3',\n      'websocket-client>=0.57,<1',\n      # Required for bert examples in tfx/examples/bert\n      'tensorflow-text>=1.15.1,<3',\n      # Required for tfx/examples/cifar10\n      'flatbuffers>=1.12,<2',\n      'tflite-support>=0.1.0a1,<0.1.1',\n      # Required for tfx/examples/penguin/experimental\n      # LINT.IfChange\n      'scikit-learn>=0.23,<0.24',\n      # LINT.ThenChange(\n      #     examples/penguin/experimental/penguin_pipeline_sklearn_gcp.py)\n      # Required for the experimental tfx/examples using Flax, e.g.,\n      # tfx/examples/penguin.\n      'jax>=0.2.13,<0.3',\n      'jaxlib>=0.1.64,<0.2',\n      'flax>=0.3.3,<0.4',\n      # Required for tfx/examples/penguin/penguin_utils_cloud_tuner.py\n      'tensorflow-cloud>=0.1,<0.2',\n  ]\n\n\ndef make_extra_packages_all():\n  # All extra dependencies.\n  return [\n      *make_extra_packages_test(),\n      *make_extra_packages_tfjs(),\n      *make_extra_packages_tf_ranking(),\n      *make_extra_packages_examples(),\n  ]\n", "path": "tfx/dependencies.py"}], "after_files": [{"content": "# Copyright 2019 Google LLC. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\"\"\"Package dependencies for TFX.\n\ntfx and family libraries (such as tensorflow-model-analysis) adopts environment\nvariable (TFX_DEPENDENCY_SELECTOR) based dependency version selection. This\ndependency will be baked in to the wheel, in other words you cannot change\ndependency string once wheel is built.\n\n- UNCONSTRAINED uses dependency without any version constraint string, which is\n  useful when you manually build wheels of parent library (e.g. tfx-bsl) of\n  arbitrary version, and install it without dependency constraints conflict.\n- NIGHTLY uses x.(y+1).0.dev version as a lower version constraint. tfx nightly\n  will transitively depend on nightly versions of other TFX family libraries,\n  and this version constraint is required.\n- GIT_MASTER uses github master branch URL of the dependency, which is useful\n  during development, or when depending on the github master HEAD version of\n  tfx. This is because tfx github master HEAD version is actually using github\n  master HEAD version of parent libraries.\n  Caveat: URL dependency is not upgraded with --upgrade flag, and you have to\n  specify --force-reinstall flag to fetch the latest change from each master\n  branch HEAD.\n- For the release, we use a range of version, which is also used as a default.\n\"\"\"\nimport os\n\n\ndef select_constraint(default, nightly=None, git_master=None):\n  \"\"\"Select dependency constraint based on TFX_DEPENDENCY_SELECTOR env var.\"\"\"\n  selector = os.environ.get('TFX_DEPENDENCY_SELECTOR')\n  if selector == 'UNCONSTRAINED':\n    return ''\n  elif selector == 'NIGHTLY' and nightly is not None:\n    return nightly\n  elif selector == 'GIT_MASTER' and git_master is not None:\n    return git_master\n  else:\n    return default\n\n\ndef make_pipeline_sdk_required_install_packages():\n  return [\n      'absl-py>=0.9,<0.13',\n      'ml-metadata' + select_constraint(\n          # LINT.IfChange\n          default='>=1.0.0,<1.1.0',\n          # LINT.ThenChange(tfx/workspace.bzl)\n          nightly='>=1.1.0.dev',\n          git_master='@git+https://github.com/google/ml-metadata@master'),\n      'packaging>=20,<21',\n      'portpicker>=1.3.1,<2',\n      'protobuf>=3.12.2,<4',\n      'docker>=4.1,<5',\n      # TODO(b/176812386): Deprecate usage of jinja2 for placeholders.\n      'jinja2>=2.7.3,<3',\n  ]\n\n\ndef make_required_install_packages():\n  # Make sure to sync the versions of common dependencies (absl-py, numpy,\n  # and protobuf) with TF.\n  return make_pipeline_sdk_required_install_packages() + [\n      'apache-beam[gcp]>=2.29,<3',\n      'attrs>=19.3.0,<21',\n      'click>=7,<8',\n      'google-api-python-client>=1.7.8,<2',\n      'google-cloud-aiplatform>=0.5.0,<0.8',\n      'google-cloud-bigquery>=1.28.0,<3',\n      'grpcio>=1.28.1,<2',\n      # TODO(b/173976603): remove pinned keras-tuner upperbound when its\n      # dependency expecatation with TensorFlow is sorted out.\n      'keras-tuner>=1,<1.0.2',\n      'kubernetes>=10.0.1,<12',\n      # TODO(b/179195488): remove numpy dependency after 1.20 migration.\n      # This dependency was added only to limit numpy 1.20 installation.\n      'numpy>=1.16,<1.20',\n      'pyarrow>=1,<3',\n      'pyyaml>=3.12,<6',\n      'tensorflow>=1.15.2,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,<3',\n      'tensorflow-hub>=0.9.0,<=0.12.0',\n      'tensorflow-data-validation' + select_constraint(\n          default='>=1.0.0,<1.1.0',\n          nightly='>=1.1.0.dev',\n          git_master='@git+https://github.com/tensorflow/data-validation@master'\n      ),\n      'tensorflow-model-analysis' + select_constraint(\n          default='>=0.31,<0.32',\n          nightly='>=0.32.0.dev',\n          git_master='@git+https://github.com/tensorflow/model-analysis@master'),\n      'tensorflow-serving-api>=1.15,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,<3',\n      'tensorflow-transform' + select_constraint(\n          default='>=1.0.0,<1.1.0',\n          nightly='>=1.1.0.dev',\n          git_master='@git+https://github.com/tensorflow/transform@master'),\n      'tfx-bsl' + select_constraint(\n          default='>=1.0.0,<1.1.0',\n          nightly='>=1.1.0.dev',\n          git_master='@git+https://github.com/tensorflow/tfx-bsl@master'),\n  ]\n\n\ndef make_extra_packages_airflow():\n  \"\"\"Prepare extra packages needed for Apache Airflow orchestrator.\"\"\"\n  return [\n      # TODO(b/188940096): update supported version.\n      'apache-airflow[mysql]>=1.10.14,<3',\n      # TODO(b/182848576): Delete pinned sqlalchemy after apache-airflow 2.0.2\n      # or later.(github.com/apache/airflow/issues/14811)\n      'sqlalchemy>=1.3,<1.4',\n  ]\n\n\ndef make_extra_packages_kfp():\n  \"\"\"Prepare extra packages needed for Kubeflow Pipelines orchestrator.\"\"\"\n  return [\n      'kfp>=1.6.1,<2',\n      'kfp-pipeline-spec>=0.1.7,<0.2',\n  ]\n\n\ndef make_extra_packages_test():\n  \"\"\"Prepare extra packages needed for running unit tests.\"\"\"\n  # Note: It is okay to pin packages to exact versions in this list to minimize\n  # conflicts.\n  return make_extra_packages_airflow() + make_extra_packages_kfp() + [\n      'pytest>=5,<6',\n  ]\n\n\ndef make_extra_packages_docker_image():\n  # Packages needed for tfx docker image.\n  return [\n      'kfp-pipeline-spec>=0.1.7,<0.2',\n      'mmh>=2.2,<3',\n      'python-snappy>=0.5,<0.6',\n  ]\n\n\ndef make_extra_packages_tfjs():\n  # Packages needed for tfjs.\n  return [\n      'tensorflowjs>=3.6.0,<4',\n  ]\n\n\ndef make_extra_packages_tf_ranking():\n  # Packages needed for tf-ranking which is used in tfx/examples/ranking.\n  return [\n      'tensorflow-ranking>=0.3.3,<0.4',\n      'struct2tensor' + select_constraint(\n          default='>=0.31,<0.32',\n          nightly='>=0.32.0.dev',\n          git_master='@git+https://github.com/google/struct2tensor@master'),\n  ]\n\n\ndef make_extra_packages_examples():\n  # Extra dependencies required for tfx/examples.\n  return [\n      # Required for presto ExampleGen custom component in\n      # tfx/examples/custom_components/presto_example_gen\n      'presto-python-client>=0.7,<0.8',\n      # Required for slack custom component in\n      # tfx/examples/custom_components/slack\n      'slackclient>=2.8.2,<3',\n      'websocket-client>=0.57,<1',\n      # Required for bert examples in tfx/examples/bert\n      'tensorflow-text>=1.15.1,<3',\n      # Required for tfx/examples/cifar10\n      'flatbuffers>=1.12,<2',\n      'tflite-support>=0.1.0a1,<0.1.1',\n      # Required for tfx/examples/penguin/experimental\n      # LINT.IfChange\n      'scikit-learn>=0.23,<0.24',\n      # LINT.ThenChange(\n      #     examples/penguin/experimental/penguin_pipeline_sklearn_gcp.py)\n      # Required for the experimental tfx/examples using Flax, e.g.,\n      # tfx/examples/penguin.\n      'jax>=0.2.13,<0.3',\n      'jaxlib>=0.1.64,<0.2',\n      'flax>=0.3.3,<0.4',\n      # Required for tfx/examples/penguin/penguin_utils_cloud_tuner.py\n      'tensorflow-cloud>=0.1,<0.2',\n  ]\n\n\ndef make_extra_packages_all():\n  # All extra dependencies.\n  return [\n      *make_extra_packages_test(),\n      *make_extra_packages_tfjs(),\n      *make_extra_packages_tf_ranking(),\n      *make_extra_packages_examples(),\n  ]\n", "path": "tfx/dependencies.py"}]}