Skip to content

Commit

Permalink
Make temporary directory for test of standalone resources
Browse files Browse the repository at this point in the history
  • Loading branch information
tgravescs committed Jan 22, 2020
1 parent be4e542 commit 1bfd706
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions python/pyspark/tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,13 @@ def setUp(self):
self.tempFile = tempfile.NamedTemporaryFile(delete=False)
self.tempFile.write(b'echo {\\"name\\": \\"gpu\\", \\"addresses\\": [\\"0\\"]}')
self.tempFile.close()
# create temporary directory for Worker resources coordination
self.tempdir = tempfile.NamedTemporaryFile(delete=False)
os.unlink(self.tempdir.name)
os.chmod(self.tempFile.name, stat.S_IRWXU | stat.S_IXGRP | stat.S_IRGRP |
stat.S_IROTH | stat.S_IXOTH)
conf = SparkConf().set("spark.test.home", SPARK_HOME)
conf = conf.set("spark.resources.dir", self.tempdir.name)
conf = conf.set("spark.driver.resource.gpu.amount", "1")
conf = conf.set("spark.driver.resource.gpu.discoveryScript", self.tempFile.name)
self.sc = SparkContext('local-cluster[2,1,1024]', class_name, conf=conf)
Expand All @@ -292,6 +296,7 @@ def test_resources(self):

def tearDown(self):
os.unlink(self.tempFile.name)
shutil.rmtree(self.tempdir.name)
self.sc.stop()


Expand Down

0 comments on commit 1bfd706

Please sign in to comment.