Skip to content

Commit 59aa274

Browse files
mdrevestf-model-analysis-team
authored and
tf-model-analysis-team
committed
Updated to use tf.io.gfile for file operations.
PiperOrigin-RevId: 276330599
1 parent 25ec9b5 commit 59aa274

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

RELEASE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
## Bug fixes and other changes
66

7+
* Updated to use tf.io.gfile for reading config files (fixes issue with
8+
reading from GCS/HDFS in 0.15.0 and 0.15.1 releases).
9+
710
## Breaking changes
811

912
## Deprecations

tensorflow_model_analysis/api/model_eval_lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ def _serialize_eval_config(eval_config: config.EvalConfig) -> Text:
8585
def load_eval_config(output_path: Text) -> config.EvalConfig:
8686
"""Loads eval config."""
8787
path = os.path.join(output_path, _EVAL_CONFIG_FILE)
88-
if os.path.exists(path):
89-
with open(path) as f:
88+
if tf.io.gfile.exists(path):
89+
with tf.io.gfile.GFile(path, 'r') as f:
9090
pb = json_format.Parse(f.read(), config_pb2.EvalConfigAndVersion())
9191
_check_version(pb.version, output_path)
9292
return pb.eval_config

tensorflow_model_analysis/api/model_eval_lib_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,8 @@ def testSerializeDeserializeEvalConfig(self):
748748
})
749749
],
750750
options=options)
751-
with open(os.path.join(output_path, 'eval_config.json'), 'w') as f:
751+
with tf.io.gfile.GFile(os.path.join(output_path, 'eval_config.json'),
752+
'w') as f:
752753
f.write(model_eval_lib._serialize_eval_config(eval_config))
753754
got_eval_config = model_eval_lib.load_eval_config(output_path)
754755
self.assertEqual(eval_config, got_eval_config)

0 commit comments

Comments
 (0)