-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2235 from desihub/multi-reservation
add reservation parsing for cpu vs. gpu
- Loading branch information
Showing
4 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
""" | ||
Test desispec.workflow.batch | ||
""" | ||
|
||
import os | ||
import unittest | ||
|
||
import numpy as np | ||
from astropy.table import Table, vstack | ||
|
||
from desispec.workflow import batch | ||
|
||
class TestWorkflowBatch(unittest.TestCase): | ||
"""Test desispec.workflow.calibration_selection | ||
""" | ||
|
||
#- Tests might alter NERSC host so reset after each test | ||
@classmethod | ||
def setUpClass(cls): | ||
cls._cached_nersc_host = os.getenv('NERSC_HOST') # None if not set | ||
|
||
def tearDown(self): | ||
if self._cached_nersc_host is None: | ||
if 'NERSC_HOST' in os.environ: | ||
del os.environ['NERSC_HOST'] | ||
else: | ||
pass | ||
else: | ||
os.environ['NERSC_HOST'] = self._cached_nersc_host | ||
|
||
def test_parse_reservation(self): | ||
"""Test parse_reservation at NERSC""" | ||
os.environ['NERSC_HOST'] = 'perlmutter' | ||
|
||
# single reservation -> same name regardless of CPU or GPU | ||
self.assertEqual(batch.parse_reservation('blat', 'arc'), 'blat') | ||
self.assertEqual(batch.parse_reservation('blat', 'ccdcalib'), 'blat') | ||
self.assertEqual(batch.parse_reservation('blat', 'flat'), 'blat') | ||
self.assertEqual(batch.parse_reservation('blat', 'tilenight'), 'blat') | ||
self.assertEqual(batch.parse_reservation('blat', 'ztile'), 'blat') | ||
|
||
# blat,foo -> cpu_reservation, gpu_reservtion | ||
self.assertEqual(batch.parse_reservation('blat,foo', 'arc'), 'blat') | ||
self.assertEqual(batch.parse_reservation('blat,foo', 'ccdcalib'), 'blat') | ||
self.assertEqual(batch.parse_reservation('blat,foo', 'flat'), 'foo') | ||
self.assertEqual(batch.parse_reservation('blat,foo', 'tilenight'), 'foo') | ||
self.assertEqual(batch.parse_reservation('blat,foo', 'ztile'), 'foo') | ||
|
||
# "none" special cases to no reservation | ||
self.assertEqual(batch.parse_reservation('blat,none', 'arc'), 'blat') | ||
self.assertEqual(batch.parse_reservation('blat,none', 'ccdcalib'), 'blat') | ||
self.assertEqual(batch.parse_reservation('blat,none', 'flat'), None) | ||
self.assertEqual(batch.parse_reservation('blat,none', 'tilenight'), None) | ||
self.assertEqual(batch.parse_reservation('blat,none', 'ztile'), None) | ||
|
||
self.assertEqual(batch.parse_reservation('none,foo', 'arc'), None) | ||
self.assertEqual(batch.parse_reservation('none,foo', 'ccdcalib'), None) | ||
self.assertEqual(batch.parse_reservation('none,foo', 'flat'), 'foo') | ||
self.assertEqual(batch.parse_reservation('none,foo', 'tilenight'), 'foo') | ||
self.assertEqual(batch.parse_reservation('none,foo', 'ztile'), 'foo') | ||
|
||
# And None -> None | ||
self.assertEqual(batch.parse_reservation(None, 'arc'), None) | ||
self.assertEqual(batch.parse_reservation(None, 'ccdcalib'), None) | ||
self.assertEqual(batch.parse_reservation(None, 'flat'), None) | ||
self.assertEqual(batch.parse_reservation(None, 'tilenight'), None) | ||
self.assertEqual(batch.parse_reservation(None, 'ztile'), None) | ||
|
||
# test errors | ||
with self.assertRaises(ValueError): | ||
batch.parse_reservation('blat,foo,bar', 'arc') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
""" | ||
Test desispec.workflow.calibration_selection | ||
Test desispec.workflow.queue | ||
""" | ||
|
||
import os | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters