Skip to content

Commit

Permalink
Remove Butler.makeRepo call
Browse files Browse the repository at this point in the history
Fix unit tests to correctly populate temporary butler repos
  • Loading branch information
srp3rd committed Aug 5, 2024
1 parent b7bde8b commit 637220a
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 5 deletions.
6 changes: 2 additions & 4 deletions python/lsst/ctrl/oods/butlerAttendant.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ def __init__(self, config, csc=None):
self.collections = self.config["collections"]
self.cleanCollections = self.config.get("cleanCollections", None)

try:
self.butlerConfig = Butler.makeRepo(repo)
except FileExistsError:
self.butlerConfig = repo
LOGGER.info(f"Using Butler repo located at {repo}")
self.butlerConfig = repo

try:
self.butler = self.createButler()
Expand Down
3 changes: 3 additions & 0 deletions tests/test_autoingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from lsst.ctrl.oods.directoryScanner import DirectoryScanner
from lsst.ctrl.oods.fileIngester import FileIngester
from lsst.ctrl.oods.utils import Utils
from lsst.daf.butler import Butler


class AutoIngestTestCase(unittest.IsolatedAsyncioTestCase):
Expand Down Expand Up @@ -80,6 +81,8 @@ def createConfig(self, config_name, fits_name):
butlerConfig["stagingDirectory"] = self.stagingDir

self.repoDir = tempfile.mkdtemp()
Butler.makeRepo(self.repoDir)

butlerConfig["repoDirectory"] = self.repoDir

# copy the FITS file to it's test location
Expand Down
2 changes: 2 additions & 0 deletions tests/test_fullasync.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from lsst.ctrl.oods.directoryScanner import DirectoryScanner
from lsst.ctrl.oods.fileIngester import FileIngester
from lsst.ctrl.oods.utils import Utils
from lsst.daf.butler import Butler


class AsyncIngestTestCase(unittest.IsolatedAsyncioTestCase):
Expand Down Expand Up @@ -80,6 +81,7 @@ def createConfig(self, config_name, fits_name):
butlerConfig["stagingDirectory"] = self.stagingDirectory

self.repoDir = tempfile.mkdtemp()
Butler.makeRepo(self.repoDir)
butlerConfig["repoDirectory"] = self.repoDir

# copy the FITS file to it's test location
Expand Down
2 changes: 2 additions & 0 deletions tests/test_gen3.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from lsst.ctrl.oods.directoryScanner import DirectoryScanner
from lsst.ctrl.oods.fileIngester import FileIngester
from lsst.ctrl.oods.utils import Utils
from lsst.daf.butler import Butler


class Gen3ComCamIngesterTestCase(unittest.IsolatedAsyncioTestCase):
Expand Down Expand Up @@ -74,6 +75,7 @@ def createConfig(self, config_name):
butlerConfig["stagingDirectory"] = self.stagingDirectory

self.repoDir = tempfile.mkdtemp()
Butler.makeRepo(self.repoDir)
butlerConfig["repoDirectory"] = self.repoDir

# copy the FITS file to it's test location
Expand Down
7 changes: 6 additions & 1 deletion tests/test_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from lsst.ctrl.oods.bucketMessage import BucketMessage
from lsst.ctrl.oods.msgIngester import MsgIngester
from lsst.ctrl.oods.msgQueue import MsgQueue
from lsst.daf.butler import Butler


class S3AuxtelIngesterTestCase(unittest.IsolatedAsyncioTestCase):
Expand Down Expand Up @@ -63,8 +64,12 @@ def createConfig(self, config_name):
with open(configFile, "r") as f:
config = yaml.safe_load(f)

ingesterConfig = config["ingester"]
butlerConfig = ingesterConfig["butlers"][0]["butler"]

self.repoDir = tempfile.mkdtemp()
config["repoDirectory"] = self.repoDir
Butler.makeRepo(self.repoDir)
butlerConfig["repoDirectory"] = self.repoDir

return config

Expand Down
2 changes: 2 additions & 0 deletions tests/test_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import yaml
from lsst.ctrl.oods.directoryScanner import DirectoryScanner
from lsst.ctrl.oods.fileIngester import FileIngester
from lsst.daf.butler import Butler


class MultiComCamIngesterTestCase(unittest.IsolatedAsyncioTestCase):
Expand Down Expand Up @@ -56,6 +57,7 @@ def createConfig(self, config_name, fits_name):
butlerConfig["stagingDirectory"] = self.stagingRootDir

self.repoDir = tempfile.mkdtemp()
Butler.makeRepo(self.repoDir)

butlerConfig["repoDirectory"] = self.repoDir

Expand Down
1 change: 1 addition & 0 deletions tests/test_tagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ async def stage(self):
butlerConfig["stagingDirectory"] = self.stagingDirectory

self.repoDir = tempfile.mkdtemp()
Butler.makeRepo(self.repoDir)
butlerConfig["repoDirectory"] = self.repoDir

self.collections = butlerConfig["collections"]
Expand Down

0 comments on commit 637220a

Please sign in to comment.