Skip to content

Commit cb1567e

Browse files
author
Frank Chen
authored
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
1 parent 22a0033 commit cb1567e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

official/mnist/mnist_tpu.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,16 @@
2323
from __future__ import division
2424
from __future__ import print_function
2525

26+
import os
27+
import sys
28+
2629
import tensorflow as tf # pylint: disable=g-bad-import-order
2730

28-
from official.mnist import dataset
29-
from official.mnist import mnist
31+
# For open source environment, add grandparent directory for import
32+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(sys.path[0]))))
33+
34+
from official.mnist import dataset # pylint: disable=wrong-import-position
35+
from official.mnist import mnist # pylint: disable=wrong-import-position
3036

3137
# Cloud TPU Cluster Resolver flags
3238
tf.flags.DEFINE_string(

0 commit comments

Comments
 (0)