Skip to content

Commit

Permalink
Fix pip tests for contrib/gan.
Browse files Browse the repository at this point in the history
- Add *_impl.py so tests can still access removed symbols.
- Add /python directory layer to make *_impy.py and __init__.py not in the same dir.

PiperOrigin-RevId: 168161722
  • Loading branch information
yifeif authored and tensorflower-gardener committed Sep 10, 2017
1 parent ce9a2b0 commit c936c11
Show file tree
Hide file tree
Showing 19 changed files with 150 additions and 28 deletions.
2 changes: 2 additions & 0 deletions tensorflow/contrib/cmake/tf_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,9 @@ add_python_module("tensorflow/contrib/framework/python/ops")
add_python_module("tensorflow/contrib/gan")
add_python_module("tensorflow/contrib/gan/python")
add_python_module("tensorflow/contrib/gan/python/features")
add_python_module("tensorflow/contrib/gan/python/features/python")
add_python_module("tensorflow/contrib/gan/python/losses")
add_python_module("tensorflow/contrib/gan/python/losses/python")
add_python_module("tensorflow/contrib/graph_editor")
add_python_module("tensorflow/contrib/graph_editor/examples")
add_python_module("tensorflow/contrib/graph_editor/tests")
Expand Down
32 changes: 21 additions & 11 deletions tensorflow/contrib/gan/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ py_library(

py_library(
name = "losses_impl",
srcs = ["python/losses/losses_impl.py"],
srcs = ["python/losses/python/losses_impl.py"],
srcs_version = "PY2AND3",
deps = [
"//tensorflow/contrib/framework:framework_py",
Expand All @@ -65,7 +65,7 @@ py_library(

py_test(
name = "losses_impl_test",
srcs = ["python/losses/losses_impl_test.py"],
srcs = ["python/losses/python/losses_impl_test.py"],
srcs_version = "PY2AND3",
deps = [
":losses_impl",
Expand All @@ -88,8 +88,9 @@ py_test(
py_library(
name = "tuple_losses",
srcs = [
"python/losses/losses_wargs.py",
"python/losses/tuple_losses.py",
"python/losses/python/losses_wargs.py",
"python/losses/python/tuple_losses.py",
"python/losses/python/tuple_losses_impl.py",
],
srcs_version = "PY2AND3",
deps = [
Expand All @@ -100,7 +101,7 @@ py_library(

py_test(
name = "tuple_losses_test",
srcs = ["python/losses/tuple_losses_test.py"],
srcs = ["python/losses/python/tuple_losses_test.py"],
srcs_version = "PY2AND3",
deps = [
":tuple_losses",
Expand All @@ -111,7 +112,10 @@ py_test(

py_library(
name = "conditioning_utils",
srcs = ["python/features/conditioning_utils.py"],
srcs = [
"python/features/python/conditioning_utils.py",
"python/features/python/conditioning_utils_impl.py",
],
srcs_version = "PY2AND3",
deps = [
"//tensorflow/contrib/layers:layers_py",
Expand All @@ -125,7 +129,7 @@ py_library(

py_test(
name = "conditioning_utils_test",
srcs = ["python/features/conditioning_utils_test.py"],
srcs = ["python/features/python/conditioning_utils_test.py"],
srcs_version = "PY2AND3",
deps = [
":conditioning_utils",
Expand All @@ -137,7 +141,10 @@ py_test(

py_library(
name = "virtual_batchnorm",
srcs = ["python/features/virtual_batchnorm.py"],
srcs = [
"python/features/python/virtual_batchnorm.py",
"python/features/python/virtual_batchnorm_impl.py",
],
srcs_version = "PY2AND3",
deps = [
"//tensorflow/python:array_ops",
Expand All @@ -154,7 +161,7 @@ py_library(

py_test(
name = "virtual_batchnorm_test",
srcs = ["python/features/virtual_batchnorm_test.py"],
srcs = ["python/features/python/virtual_batchnorm_test.py"],
srcs_version = "PY2AND3",
deps = [
":virtual_batchnorm",
Expand All @@ -176,14 +183,17 @@ py_test(

py_library(
name = "clip_weights",
srcs = ["python/features/clip_weights.py"],
srcs = [
"python/features/python/clip_weights.py",
"python/features/python/clip_weights_impl.py",
],
srcs_version = "PY2AND3",
deps = ["//tensorflow/contrib/opt:opt_py"],
)

py_test(
name = "clip_weights_test",
srcs = ["python/features/clip_weights_test.py"],
srcs = ["python/features/python/clip_weights_test.py"],
srcs_version = "PY2AND3",
deps = [
":clip_weights",
Expand Down
12 changes: 6 additions & 6 deletions tensorflow/contrib/gan/python/features/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

# Collapse features into a single namespace.
# pylint: disable=unused-import,wildcard-import
from tensorflow.contrib.gan.python.features import clip_weights
from tensorflow.contrib.gan.python.features import conditioning_utils
from tensorflow.contrib.gan.python.features import virtual_batchnorm
from tensorflow.contrib.gan.python.features.python import clip_weights
from tensorflow.contrib.gan.python.features.python import conditioning_utils
from tensorflow.contrib.gan.python.features.python import virtual_batchnorm

from tensorflow.contrib.gan.python.features.clip_weights import *
from tensorflow.contrib.gan.python.features.conditioning_utils import *
from tensorflow.contrib.gan.python.features.virtual_batchnorm import *
from tensorflow.contrib.gan.python.features.python.clip_weights import *
from tensorflow.contrib.gan.python.features.python.conditioning_utils import *
from tensorflow.contrib.gan.python.features.python.virtual_batchnorm import *
# pylint: enable=unused-import,wildcard-import

from tensorflow.python.util.all_util import remove_undocumented
Expand Down
28 changes: 28 additions & 0 deletions tensorflow/contrib/gan/python/features/python/clip_weights.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Utilities to clip weights."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from tensorflow.contrib.gan.python.features.python import clip_weights_impl
# pylint: disable=wildcard-import
from tensorflow.contrib.gan.python.features.python.clip_weights_impl import *
# pylint: enable=wildcard-import
from tensorflow.python.util.all_util import remove_undocumented

__all__ = clip_weights_impl.__all__
remove_undocumented(__name__, __all__)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import collections

from tensorflow.contrib.gan.python.features import clip_weights
from tensorflow.contrib.gan.python.features.python import clip_weights_impl as clip_weights

from tensorflow.python.ops import variables
from tensorflow.python.platform import test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Miscellanous utilities for TFGAN code and examples."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from tensorflow.contrib.gan.python.features.python import conditioning_utils_impl
# pylint: disable=wildcard-import
from tensorflow.contrib.gan.python.features.python.conditioning_utils_impl import *
# pylint: enable=wildcard-import
from tensorflow.python.util.all_util import remove_undocumented

__all__ = conditioning_utils_impl.__all__
remove_undocumented(__name__, __all__)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from __future__ import division
from __future__ import print_function

from tensorflow.contrib.gan.python.features import conditioning_utils
from tensorflow.contrib.gan.python.features.python import conditioning_utils_impl as conditioning_utils

from tensorflow.python.framework import dtypes
from tensorflow.python.ops import array_ops
Expand Down
27 changes: 27 additions & 0 deletions tensorflow/contrib/gan/python/features/python/virtual_batchnorm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Virtual batch normalization."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from tensorflow.contrib.gan.python.features.python import virtual_batchnorm_impl
# pylint: disable=wildcard-import
from tensorflow.contrib.gan.python.features.python.virtual_batchnorm_impl import *
# pylint: enable=wildcard-import
from tensorflow.python.util.all_util import remove_undocumented

__all__ = virtual_batchnorm_impl.__all__
remove_undocumented(__name__, __all__)
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import numpy as np

from tensorflow.contrib.framework.python.ops import variables as contrib_variables_lib
from tensorflow.contrib.gan.python.features import virtual_batchnorm
from tensorflow.contrib.gan.python.features.python import virtual_batchnorm_impl as virtual_batchnorm
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import random_seed
Expand Down
6 changes: 3 additions & 3 deletions tensorflow/contrib/gan/python/losses/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
from __future__ import print_function

# Collapse losses into a single namespace.
from tensorflow.contrib.gan.python.losses import losses_wargs as wargs
from tensorflow.contrib.gan.python.losses import tuple_losses
from tensorflow.contrib.gan.python.losses.python import losses_wargs as wargs
from tensorflow.contrib.gan.python.losses.python import tuple_losses

# pylint: disable=wildcard-import
from tensorflow.contrib.gan.python.losses.tuple_losses import *
from tensorflow.contrib.gan.python.losses.python.tuple_losses import *
# pylint: enable=wildcard-import

from tensorflow.python.util.all_util import remove_undocumented
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from __future__ import division
from __future__ import print_function

from tensorflow.contrib.gan.python.losses import losses_impl as tfgan_losses
from tensorflow.contrib.gan.python.losses.python import losses_impl as tfgan_losses
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import ops
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from __future__ import print_function

# pylint: disable=wildcard-import
from tensorflow.contrib.gan.python.losses import losses_impl
from tensorflow.contrib.gan.python.losses.losses_impl import *
from tensorflow.contrib.gan.python.losses.python import losses_impl
from tensorflow.contrib.gan.python.losses.python.losses_impl import *
# pylint: enable=wildcard-import

from tensorflow.python.util.all_util import remove_undocumented
Expand Down
27 changes: 27 additions & 0 deletions tensorflow/contrib/gan/python/losses/python/tuple_losses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""TFGAN utilities for loss functions that accept GANModel namedtuples."""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

# pylint: disable=wildcard-import
from tensorflow.contrib.gan.python.losses.python import tuple_losses_impl
from tensorflow.contrib.gan.python.losses.python.tuple_losses_impl import *
# pylint: enable=wildcard-import
from tensorflow.python.util.all_util import remove_undocumented

__all__ = tuple_losses_impl.__all__
remove_undocumented(__name__, __all__)
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from __future__ import division
from __future__ import print_function

from tensorflow.contrib.gan.python.losses import losses_impl
from tensorflow.contrib.gan.python.losses.python import losses_impl
from tensorflow.python.util import tf_inspect


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import numpy as np

from tensorflow.contrib.gan.python.losses import tuple_losses as tfgan_losses
from tensorflow.contrib.gan.python.losses.python import tuple_losses_impl as tfgan_losses

from tensorflow.python.platform import test

Expand Down

0 comments on commit c936c11

Please sign in to comment.