aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/examples/tutorials
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-06-23 21:57:48 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-06-23 22:01:01 -0700
commit0b6474d5c4abebd6ebe951acb120613a5b66ec50 (patch)
tree16196ddbfda12bf6b8dc1bb48d8c3d0c63ed658e /tensorflow/examples/tutorials
parent99451d7a0d3712669267480f220f505457edf8c4 (diff)
Avoid hardcoded names for temporary files in tests.
These tests (and examples that are run as tests) were using hardcoded names for temporary files. This failed when multiple copies of these tests were run in parallel, or even successively by different users, where the second run could not overwrite files left by the first. This change uses the TEST_TMPDIR environment variable used by bazel's test runner to choose a temporary directory. If that directory is not set, /tmp is used, as before. PiperOrigin-RevId: 160026924
Diffstat (limited to 'tensorflow/examples/tutorials')
-rw-r--r--tensorflow/examples/tutorials/mnist/fully_connected_feed.py8
-rw-r--r--tensorflow/examples/tutorials/mnist/mnist_with_summaries.py7
2 files changed, 10 insertions, 5 deletions
diff --git a/tensorflow/examples/tutorials/mnist/fully_connected_feed.py b/tensorflow/examples/tutorials/mnist/fully_connected_feed.py
index be50f4529f..af89c8c77b 100644
--- a/tensorflow/examples/tutorials/mnist/fully_connected_feed.py
+++ b/tensorflow/examples/tutorials/mnist/fully_connected_feed.py
@@ -20,7 +20,7 @@ from __future__ import print_function
# pylint: disable=missing-docstring
import argparse
-import os.path
+import os
import sys
import time
@@ -257,13 +257,15 @@ if __name__ == '__main__':
parser.add_argument(
'--input_data_dir',
type=str,
- default='/tmp/tensorflow/mnist/input_data',
+ default=os.path.join(os.getenv('TEST_TMPDIR', '/tmp'),
+ 'tensorflow/mnist/input_data'),
help='Directory to put the input data.'
)
parser.add_argument(
'--log_dir',
type=str,
- default='/tmp/tensorflow/mnist/logs/fully_connected_feed',
+ default=os.path.join(os.getenv('TEST_TMPDIR', '/tmp'),
+ 'tensorflow/mnist/logs/fully_connected_feed'),
help='Directory to put the log data.'
)
parser.add_argument(
diff --git a/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py b/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py
index dc0d870315..c401d09df8 100644
--- a/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py
+++ b/tensorflow/examples/tutorials/mnist/mnist_with_summaries.py
@@ -25,6 +25,7 @@ from __future__ import division
from __future__ import print_function
import argparse
+import os
import sys
import tensorflow as tf
@@ -200,12 +201,14 @@ if __name__ == '__main__':
parser.add_argument(
'--data_dir',
type=str,
- default='/tmp/tensorflow/mnist/input_data',
+ default=os.path.join(os.getenv('TEST_TMPDIR', '/tmp'),
+ 'tensorflow/mnist/input_data'),
help='Directory for storing input data')
parser.add_argument(
'--log_dir',
type=str,
- default='/tmp/tensorflow/mnist/logs/mnist_with_summaries',
+ default=os.path.join(os.getenv('TEST_TMPDIR', '/tmp'),
+ 'tensorflow/mnist/logs/mnist_with_summaries'),
help='Summaries log directory')
FLAGS, unparsed = parser.parse_known_args()
tf.app.run(main=main, argv=[sys.argv[0]] + unparsed)