Skip to content

Commit cc243db

Browse files
authored
Merge branch 'r0.12' into r0.12
2 parents c14058b + bb1aede commit cc243db

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

tensorflow/python/framework/ops.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from tensorflow.python.framework import versions
4444
from tensorflow.python.platform import tf_logging as logging
4545
from tensorflow.python.util import compat
46-
from tensorflow.python.util import deprecation
46+
from tensorflow.python.util import decorator_utils
4747

4848

4949
def _override_helper(clazz_object, operator, func):
@@ -3923,12 +3923,12 @@ class GraphKeys(object):
39233923
COND_CONTEXT = "cond_context"
39243924
WHILE_CONTEXT = "while_context"
39253925

3926-
@property
3927-
@deprecation.deprecated("2017-03-02",
3928-
"VARIABLES collection name is deprecated, "
3929-
"please use GLOBAL_VARIABLES instead")
3930-
def VARIABLES(self):
3931-
return self.GLOBAL_VARIABLES
3926+
@decorator_utils.classproperty
3927+
def VARIABLES(cls): # pylint: disable=no-self-argument
3928+
logging.warning("VARIABLES collection name is deprecated, "
3929+
"please use GLOBAL_VARIABLES instead; "
3930+
"VARIABLES will be removed after 2017-03-02.")
3931+
return cls.GLOBAL_VARIABLES
39323932

39333933

39343934
def add_to_collection(name, value):

tensorflow/python/util/decorator_utils.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,25 @@ def validate_callable(func, decorator_name):
6060
' @property appears before @%s in your source code:'
6161
'\n\n@property\n@%s\ndef method(...)' % (
6262
func, decorator_name, decorator_name))
63+
64+
65+
class classproperty(object): # pylint: disable=invalid-name
66+
"""Class property decorator.
67+
68+
Example usage:
69+
70+
class MyClass(object):
71+
72+
@classproperty
73+
def value(cls):
74+
return '123'
75+
76+
> print MyClass.value
77+
123
78+
"""
79+
80+
def __init__(self, func):
81+
self._func = func
82+
83+
def __get__(self, owner_self, owner_cls):
84+
return self._func(owner_cls)

0 commit comments

Comments
 (0)