From cb1567e87cd92ab0394a0f7b0d5c1cb226a2cbde Mon Sep 17 00:00:00 2001 From: Frank Chen Date: Mon, 30 Apr 2018 15:40:56 -0700 Subject: [PATCH] Add new import paths to mnist_tpu.py (#4133) * Add new import paths to mnist_tpu.py This adds new import paths to mnist_tpu.py so individuals can check out the git repository and run `python mnist_tpu.py` without finagling with python import search paths. * Fix lint errors * Add disable= to pylint instructions * Remove parent path * Update comments --- official/mnist/mnist_tpu.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/official/mnist/mnist_tpu.py b/official/mnist/mnist_tpu.py index 072ba14f454..077947f2e5c 100644 --- a/official/mnist/mnist_tpu.py +++ b/official/mnist/mnist_tpu.py @@ -23,10 +23,16 @@ from __future__ import division from __future__ import print_function +import os +import sys + import tensorflow as tf # pylint: disable=g-bad-import-order -from official.mnist import dataset -from official.mnist import mnist +# For open source environment, add grandparent directory for import +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(sys.path[0])))) + +from official.mnist import dataset # pylint: disable=wrong-import-position +from official.mnist import mnist # pylint: disable=wrong-import-position # Cloud TPU Cluster Resolver flags tf.flags.DEFINE_string(