Skip to content

Commit d6424f1

Browse files
chongkongml-fairness-infra-github
authored andcommitted
Use select_constraint() in setup.py for branched dependency selection.
PiperOrigin-RevId: 330868123
1 parent b09f948 commit d6424f1

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

setup.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,30 @@
1414
# ==============================================================================
1515
"""Setup to install Fairness Indicators."""
1616

17+
import os
18+
1719
from setuptools import find_packages
1820
from setuptools import setup
1921

22+
23+
def select_constraint(default, git_master=None):
24+
"""Select dependency constraint based on TFX_DEPENDENCY_SELECTOR env var."""
25+
selector = os.environ.get('TFX_DEPENDENCY_SELECTOR')
26+
if selector == 'UNCONSTRAINED':
27+
return ''
28+
elif selector == 'GIT_MASTER' and git_master is not None:
29+
return git_master
30+
else:
31+
return default
32+
2033
REQUIRED_PACKAGES = [
2134
'tensorflow>=1.15.2,!=2.0.*,!=2.1.*,!=2.2.*,<3',
22-
'tensorflow-data-validation>=0.23,<0.24',
23-
'tensorflow-model-analysis>=0.23,<0.24',
35+
'tensorflow-data-validation' + select_constraint(
36+
default='>=0.23,<0.24',
37+
git_master='@git+https://github.com/tensorflow/data-validation@master'),
38+
'tensorflow-model-analysis' + select_constraint(
39+
default='>=0.23,<0.24',
40+
git_master='@git+https://github.com/tensorflow/model-analysis@master'),
2441
'witwidget>=1.4.4,<2',
2542
]
2643

tensorboard_plugin/setup.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,29 @@
1818
from __future__ import division
1919
from __future__ import print_function
2020

21+
import os
22+
2123
from setuptools import find_packages
2224
from setuptools import setup
2325

26+
27+
def select_constraint(default, git_master=None):
28+
"""Select dependency constraint based on TFX_DEPENDENCY_SELECTOR env var."""
29+
selector = os.environ.get('TFX_DEPENDENCY_SELECTOR')
30+
if selector == 'UNCONSTRAINED':
31+
return ''
32+
elif selector == 'GIT_MASTER' and git_master is not None:
33+
return git_master
34+
else:
35+
return default
36+
2437
REQUIRED_PACKAGES = [
2538
'protobuf>=3.6.0,<4',
2639
'tensorboard>=2.3.0,<3',
2740
'tensorflow>=2.3.0,<3',
28-
'tensorflow-model-analysis>=0.23,<0.24',
41+
'tensorflow-model-analysis' + select_constraint(
42+
default='>=0.23,<0.24',
43+
git_master='@git+https://github.com/tensorflow/model-analysis@master'),
2944
]
3045

3146
with open('README.md', 'r', encoding='utf-8') as fh:

0 commit comments

Comments
 (0)