1load( 2 "//tensorflow:tensorflow.bzl", 3 "py_test", 4 "tf_cc_test", # @unused 5 "tf_copts", # @unused 6) 7load("//tensorflow:tensorflow.bzl", "get_compatible_with_portable") 8 9package( 10 default_visibility = [ 11 "//learning/brain/testing/tf2_migration_tools:__pkg__", 12 "//tensorflow:internal", 13 ], 14 licenses = ["notice"], 15) 16 17py_library( 18 name = "ipynb", 19 srcs = ["ipynb.py"], 20 srcs_version = "PY3", 21 deps = ["@six_archive//:six"], 22) 23 24py_library( 25 name = "ast_edits", 26 srcs = ["ast_edits.py"], 27 srcs_version = "PY3", 28 deps = [ 29 "@pasta", 30 "@six_archive//:six", 31 ], 32) 33 34py_test( 35 name = "ast_edits_test", 36 srcs = ["ast_edits_test.py"], 37 python_version = "PY3", 38 srcs_version = "PY3", 39 deps = [ 40 ":ast_edits", 41 "//tensorflow/python:client_testlib", 42 "//tensorflow/python:framework_test_lib", 43 "@six_archive//:six", 44 ], 45) 46 47py_binary( 48 name = "tf_upgrade", 49 srcs = ["tf_upgrade.py"], 50 python_version = "PY3", 51 srcs_version = "PY3", 52 deps = [ 53 ":tf_upgrade_lib", 54 "@six_archive//:six", 55 ], 56) 57 58py_library( 59 name = "tf_upgrade_lib", 60 srcs = ["tf_upgrade.py"], 61 srcs_version = "PY3", 62 deps = [ 63 ":ast_edits", 64 "@six_archive//:six", 65 ], 66) 67 68py_test( 69 name = "tf_upgrade_test", 70 srcs = ["tf_upgrade_test.py"], 71 python_version = "PY3", 72 srcs_version = "PY3", 73 tags = [ 74 "no_pip", 75 ], 76 deps = [ 77 ":tf_upgrade_lib", 78 "//tensorflow/python:client_testlib", 79 "//tensorflow/python:framework_test_lib", 80 "@six_archive//:six", 81 ], 82) 83 84py_library( 85 name = "renames_v2", 86 srcs = ["renames_v2.py"], 87 compatible_with = get_compatible_with_portable(), 88 srcs_version = "PY3", 89 visibility = ["//tensorflow:internal"], 90) 91 92py_library( 93 name = "reorders_v2", 94 srcs = ["reorders_v2.py"], 95 srcs_version = "PY3", 96) 97 98py_library( 99 name = "all_renames_v2", 100 srcs = ["all_renames_v2.py"], 101 compatible_with = get_compatible_with_portable(), 102 srcs_version = "PY3", 103 visibility = [ 104 "//tensorflow:__pkg__", 105 "//tensorflow:__subpackages__", 106 ], 107 deps = [":renames_v2"], 108) 109 110py_test( 111 name = "all_renames_v2_test", 112 srcs = ["all_renames_v2_test.py"], 113 python_version = "PY3", 114 srcs_version = "PY3", 115 deps = [ 116 ":all_renames_v2", 117 "//tensorflow/python:client_testlib", 118 "//tensorflow/python:framework_test_lib", 119 "@six_archive//:six", 120 ], 121) 122 123py_library( 124 name = "module_deprecations_v2", 125 srcs = ["module_deprecations_v2.py"], 126 srcs_version = "PY3", 127 deps = [":ast_edits"], 128) 129 130py_library( 131 name = "tf_upgrade_v2_lib", 132 srcs = ["tf_upgrade_v2.py"], 133 srcs_version = "PY3", 134 deps = [ 135 ":all_renames_v2", 136 ":ast_edits", 137 ":module_deprecations_v2", 138 ":reorders_v2", 139 "@six_archive//:six", 140 ], 141) 142 143py_library( 144 name = "tf_upgrade_v2_safety_lib", 145 srcs = ["tf_upgrade_v2_safety.py"], 146 srcs_version = "PY3", 147 deps = [ 148 ":all_renames_v2", 149 ":ast_edits", 150 ":module_deprecations_v2", 151 ], 152) 153 154py_binary( 155 name = "tf_upgrade_v2", 156 srcs = ["tf_upgrade_v2_main.py"], 157 main = "tf_upgrade_v2_main.py", 158 python_version = "PY3", 159 srcs_version = "PY3", 160 deps = [ 161 ":ast_edits", 162 ":ipynb", 163 ":tf_upgrade_v2_lib", 164 ":tf_upgrade_v2_safety_lib", 165 "@six_archive//:six", 166 ], 167) 168 169py_test( 170 name = "tf_upgrade_v2_test", 171 srcs = ["tf_upgrade_v2_test.py"], 172 python_version = "PY3", 173 srcs_version = "PY3", 174 tags = [ 175 "no_windows", 176 "nomsan", 177 "v1only", 178 ], 179 deps = [ 180 ":tf_upgrade_v2_lib", 181 "//tensorflow:tensorflow_py", 182 "//tensorflow/python:client_testlib", 183 "//tensorflow/python:framework_test_lib", 184 "//tensorflow/tools/common:public_api", 185 "//tensorflow/tools/common:traverse", 186 "@absl_py//absl/testing:parameterized", 187 "@six_archive//:six", 188 ], 189) 190 191py_test( 192 name = "tf_upgrade_v2_safety_test", 193 srcs = ["tf_upgrade_v2_safety_test.py"], 194 python_version = "PY3", 195 srcs_version = "PY3", 196 deps = [ 197 ":tf_upgrade_v2_safety_lib", 198 "//tensorflow/python:client_testlib", 199 "//tensorflow/python:framework_test_lib", 200 "@six_archive//:six", 201 ], 202) 203 204# Keep for reference, this test will succeed in 0.11 but fail in 1.0 205# py_test( 206# name = "test_file_v0_11", 207# size = "small", 208# srcs = ["testdata/test_file_v0_11.py"], 209# srcs_version = "PY3", 210# deps = [ 211# "//tensorflow:tensorflow_py", 212# ], 213# ) 214 215genrule( 216 name = "generate_upgraded_file", 217 testonly = 1, 218 srcs = ["testdata/test_file_v0_11.py"], 219 outs = [ 220 "test_file_v1_0.py", 221 "report.txt", 222 ], 223 cmd = ("$(location :tf_upgrade)" + 224 " --infile $(location testdata/test_file_v0_11.py)" + 225 " --outfile $(location test_file_v1_0.py)" + 226 " --reportfile $(location report.txt)"), 227 tools = [":tf_upgrade"], 228) 229 230py_test( 231 name = "test_file_v1_0", 232 size = "small", 233 srcs = ["test_file_v1_0.py"], 234 python_version = "PY3", 235 srcs_version = "PY3", 236 deps = [ 237 "//tensorflow:tensorflow_py", 238 ], 239) 240 241genrule( 242 name = "generate_upgraded_file_v2", 243 testonly = 1, 244 srcs = ["testdata/test_file_v1_12.py"], 245 outs = [ 246 "test_file_v2_0.py", 247 "report_v2.txt", 248 ], 249 cmd = ("$(location :tf_upgrade_v2)" + 250 " --infile $(location testdata/test_file_v1_12.py)" + 251 " --outfile $(location test_file_v2_0.py)" + 252 " --reportfile $(location report_v2.txt) && " + 253 "sed -i'.original' 's/_TEST_VERSION = 1/_TEST_VERSION = 2/g' $(location test_file_v2_0.py)"), 254 tools = [":tf_upgrade_v2"], 255) 256 257py_test( 258 name = "test_file_v1_12", 259 size = "small", 260 srcs = ["testdata/test_file_v1_12.py"], 261 python_version = "PY3", 262 srcs_version = "PY3", 263 tags = [ 264 "no_windows", 265 "v1only", 266 ], 267 deps = [ 268 "//tensorflow:tensorflow_py", 269 ], 270) 271 272py_test( 273 name = "test_file_v2_0", 274 size = "small", 275 srcs = ["test_file_v2_0.py"], 276 python_version = "PY3", 277 srcs_version = "PY3", 278 deps = [ 279 "//tensorflow:tensorflow_py", 280 ], 281) 282 283exports_files( 284 [ 285 "all_renames_v2.py", 286 "ast_edits.py", 287 "tf_upgrade.py", 288 "renames_v2.py", 289 "testdata/test_file_v0_11.py", 290 "testdata/test_file_v1_12.py", 291 ], 292) 293