Skip to content

Commit

Permalink
Add temporary deployment test
Browse files Browse the repository at this point in the history
  • Loading branch information
fred3m committed May 13, 2024
1 parent 88ef998 commit ea3feed
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion scripts/rubintv_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import argparse
import logging
import os
import pathlib
from lsst.rubintv.analysis.service.data import DataCenter
Expand All @@ -34,12 +35,63 @@
from lsst.rubintv.analysis.service.worker import Worker

default_config = os.path.join(pathlib.Path(__file__).parent.absolute(), "config.yaml")

log = logging.getLogger('lsst.rubintv.analysis.server.worker')

class UniversalToVisit(DataMatch):

Check failure on line 40 in scripts/rubintv_worker.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

E302

expected 2 blank lines, found 1
def get_join(self):
return

def connection_test():

Check failure on line 44 in scripts/rubintv_worker.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

E302

expected 2 blank lines, found 1
REPO_LOCATION = os.getenv(
'DAF_BUTLER_REPOSITORY_INDEX',
'/sdf/group/rubin/repo/ir2/butler.yaml'
)
REPO_COLLECTIONS = os.getenv(
'DAF_BUTLER_COLLECTIONS',
'LSSTCam/raw/all,LSSTCam/calib'
).split('/')

try:
import lsst.afw.image as afwImage
import numpy as np
data = np.zeros((10, 10), dtype=np.float32)
img = afwImage.ImageF(data)

Check failure on line 58 in scripts/rubintv_worker.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

F841

local variable 'img' is assigned to but never used
msg = 'Create an afwImage - stack import successful'
print(msg)
log.info(msg)
except Exception as e:
log.exception(f'Failed to create an afwImage: {e}')

try:
from lsst.daf.butler import Butler
butler = Butler(REPO_LOCATION,
collections=REPO_COLLECTIONS)
msg = 'Created a full camera butler - repo mount sucessful'
print(msg)
log.info(msg)
except Exception as e:
log.exception(f'Failed to create the butler: {e}')

try:
import lsst.summit.utils.butlerUtils as butlerUtils
butler = butlerUtils.makeDefaultLatissButler(embargo=True)
msg = 'Created an embargo LATISS butler - embargo credentials working'
print(msg)
log.info(msg)
except Exception as e:
log.exception(f'Failed to create LATISS embargo butler: {e}')

try:
from lsst.daf.butler import DimensionRecord
where = "exposure.day_obs>=20230101 AND exposure.seq_num=1"
records = butler.registry.queryDimensionRecords('exposure', where=where, datasets='raw')
record = list(records)[0]
assert isinstance(record, DimensionRecord)
msg = 'Successfully accessed an exposure record - butler is really working'
print(msg)
log.info(msg)
except Exception as e:
log.exception(f'Failed to get a dimension record from the butler: {e}')

def main():

Check failure on line 96 in scripts/rubintv_worker.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

E302

expected 2 blank lines, found 1
parser = argparse.ArgumentParser(description="Initialize a new RubinTV worker.")
Expand All @@ -52,8 +104,16 @@ def main():
parser.add_argument(
"-c", "--config", default=default_config, type=str, help="Location of the configuration file."
)
parser.add_argument(
"-t", "--test", default=True, help="Run connection tests."
)
args = parser.parse_args()

# Run the connection test.
# This code can be deleted after the initial deployment
if args.test:
connection_test()

# Load the configuration file
with open(args.config, "r") as file:
config = yaml.safe_load(file)
Expand Down

0 comments on commit ea3feed

Please sign in to comment.