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

Try to upgrade gast to 0.4.0 #46039

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tensorflow/compiler/mlir/tfr/python/tfr_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ def visit_Subscript(self, node):
# TODO(fengliuai): Here we hardcode the node.slice here to get the index
# type. Use the visit method once the type inference is done.
# slice_val, slice_ty = self.visit(node.slice)
if isinstance(node.slice, ast.Index):
if isinstance(node.slice, ast.Slice):
if isinstance(node.slice.value, ast.Constant):
# TODO(fengliuai): promote to an assignment
idx_val = self._ssa_name('cst')
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/python/autograph/converters/slices.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SliceTransformer(converter.Base):
def _process_single_assignment(self, target, value):
if not isinstance(target, gast.Subscript):
return None
if not isinstance(target.slice, gast.Index):
if not isinstance(target.slice, gast.Slice):
return None

template = """
Expand All @@ -57,7 +57,7 @@ def visit_Assign(self, node):

def visit_Subscript(self, node):
node = self.generic_visit(node)
if not isinstance(node.slice, gast.Index):
if not isinstance(node.slice, gast.Slice):
return node

if not isinstance(node.ctx, gast.Load):
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/python/autograph/pyct/ast_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def apply_to_single_assignments(targets, values, apply_fn):
value_el = values.elts[i]
else:
idx = parser.parse_expression(str(i))
value_el = gast.Subscript(values, gast.Index(idx), ctx=gast.Load())
value_el = gast.Subscript(values, gast.Slice(idx,idx+1), ctx=gast.Load())
apply_to_single_assignments(target_el, value_el, apply_fn)
else:
apply_fn(target, values)
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/python/autograph/pyct/qual_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def ast(self):
if self.has_subscript():
return gast.Subscript(
value=self.parent.ast(),
slice=gast.Index(self.qn[-1].ast()),
slice=gast.Slice(self.qn[-1].ast()),
ctx=CallerMustSetThis)
if self.has_attr():
return gast.Attribute(
Expand Down Expand Up @@ -247,7 +247,7 @@ def visit_Subscript(self, node):
# TODO(mdan): This may no longer apply if we overload getitem.
node = self.generic_visit(node)
s = node.slice
if not isinstance(s, gast.Index):
if not isinstance(s, gast.Slice):
# TODO(mdan): Support range and multi-dimensional indices.
# Continuing silently because some demos use these.
return node
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/python/autograph/pyct/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def apply_to_single_assignments(self, targets, values, apply_fn):
if isinstance(values, (gast.Tuple, gast.List)):
value_el = values.elts[i]
else:
value_el = gast.Subscript(values, gast.Index(i), ctx=gast.Store())
value_el = gast.Subscript(values, gast.Slice(i,i+1), ctx=gast.Store())
self.apply_to_single_assignments(target_el, value_el, apply_fn)
else:
# TODO(mdan): Look into allowing to rewrite the AST here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def visit_Subscript(self, node):
qn = anno.getanno(node, anno.Basic.QN)
if isinstance(node.ctx, gast.Load):
self.reads.add(qn)
elif not isinstance(node.slice, gast.Index):
elif not isinstance(node.slice, gast.Slice):
if anno.hasanno(node, anno.Basic.QN):
self.complex_reads.add(anno.getanno(node, anno.Basic.QN))
elif anno.hasanno(node.value, anno.Basic.QN):
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/tools/ci_build/builds/pip_new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ install_tensorflow_pip() {

# Install the gast package in the virtualenv. Installing it in user system
# packages does not appear to port it over when creating a virtualenv.
${PIP_BIN_PATH} install --upgrade "gast==0.3.3" || \
${PIP_BIN_PATH} install --upgrade "gast==0.4.0" || \
die "Error: gast install, upgrade FAILED"

}
Expand Down
4 changes: 2 additions & 2 deletions tensorflow/tools/ci_build/release/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function install_ubuntu_16_pip_deps {
"${PIP_CMD}" install --user 'wheel ~= 0.35'
"${PIP_CMD}" install --user 'wrapt ~= 1.12.1'
# We need to pin gast dependency exactly
"${PIP_CMD}" install --user 'gast == 0.3.3'
"${PIP_CMD}" install --user 'gast == 0.4.0'
# Finally, install tensorboard and estimator
# Note that here we want the latest version that matches (b/156523241)
"${PIP_CMD}" install --user --upgrade --force-reinstall 'tb-nightly ~= 2.4.0.a'
Expand Down Expand Up @@ -199,7 +199,7 @@ function install_macos_pip_deps {
${PIP_CMD} install $USER_FLAG 'wheel ~= 0.35'
${PIP_CMD} install $USER_FLAG 'wrapt ~= 1.12.1'
# We need to pin gast dependency exactly
${PIP_CMD} install $USER_FLAG 'gast == 0.3.3'
${PIP_CMD} install $USER_FLAG 'gast == 0.4.0'
# Finally, install tensorboard and estimator
# Note that here we want the latest version that matches (b/156523241)
${PIP_CMD} install $USER_FLAG --upgrade --force-reinstall 'tb-nightly ~= 2.4.0.a'
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/tools/ci_build/release/common_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ SET PATH=%PATH%;C:\%PYTHON_DIRECTORY%
%PY_EXE% -m pip install "wheel ~= 0.35"
%PY_EXE% -m pip install "wrapt ~= 1.12.1"
@REM We need to pin gast dependency exactly
%PY_EXE% -m pip install "gast == 0.3.3"
%PY_EXE% -m pip install "gast == 0.4.0"
@REM Finally, install tensorboard and estimator
@REM Note that here we want the latest version that matches (b/156523241)
%PY_EXE% -m pip install --upgrade --force-reinstall "tb-nightly ~= 2.4.0.a"
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/tools/pip_package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
'wrapt ~= 1.12.1',
# These packages need to be pinned exactly as newer versions are
# incompatible with the rest of the ecosystem
'gast == 0.3.3',
'gast == 0.4.0',
# TensorFlow ecosystem packages that TF exposes API for
# These need to be in sync with the existing TF version
# They are updated during the release process
Expand Down
8 changes: 4 additions & 4 deletions tensorflow/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -450,12 +450,12 @@ def tf_repositories(path_prefix = "", tf_repo_name = ""):
tf_http_archive(
name = "gast_archive",
build_file = clean_dep("//third_party:gast.BUILD"),
sha256 = "b881ef288a49aa81440d2c5eb8aeefd4c2bb8993d5f50edae7413a85bfdb3b57",
strip_prefix = "gast-0.3.3",
sha256 = "40feb7b8b8434785585ab224d1568b857edb18297e5a3047f1ba012bc83b42c1",
strip_prefix = "gast-0.4.0",
system_build_file = clean_dep("//third_party/systemlibs:gast.BUILD"),
urls = [
"http://mirror.tensorflow.org/files.pythonhosted.org/packages/12/59/eaa15ab9710a20e22225efd042cd2d6a0b559a0656d5baba9641a2a4a921/gast-0.3.3.tar.gz",
"https://files.pythonhosted.org/packages/12/59/eaa15ab9710a20e22225efd042cd2d6a0b559a0656d5baba9641a2a4a921/gast-0.3.3.tar.gz",
"http://mirror.tensorflow.org/files.pythonhosted.org/packages/83/4a/07c7e59cef23fb147454663c3271c21da68ba2ab141427c20548ae5a8a4d/gast-0.4.0.tar.gz",
"https://files.pythonhosted.org/packages/83/4a/07c7e59cef23fb147454663c3271c21da68ba2ab141427c20548ae5a8a4d/gast-0.4.0.tar.gz",
],
)

Expand Down