From 6a491c71ca4b8603a2501aba7281763a151291d6 Mon Sep 17 00:00:00 2001 From: Tim Jenness Date: Tue, 29 Aug 2023 10:30:57 +0100 Subject: [PATCH] Allow schema file to be a general URI This allows it to be read from anywhere supported by ResourcePath. --- python/lsst/ap/association/packageAlerts.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/lsst/ap/association/packageAlerts.py b/python/lsst/ap/association/packageAlerts.py index f20a3de1..55481120 100644 --- a/python/lsst/ap/association/packageAlerts.py +++ b/python/lsst/ap/association/packageAlerts.py @@ -37,6 +37,7 @@ from lsst.pex.exceptions import InvalidParameterError import lsst.pipe.base as pipeBase from lsst.utils.timer import timeMethod +from lsst.resources import ResourcePath """Methods for packaging Apdb and Pipelines data into Avro alerts. @@ -48,8 +49,8 @@ class PackageAlertsConfig(pexConfig.Config): """ schemaFile = pexConfig.Field( dtype=str, - doc="Schema definition file for the avro alerts.", - default=alertPack.get_path_to_latest_schema() + doc="Schema definition file URI for the avro alerts.", + default=alertPack.get_uri_to_latest_schema() ) minCutoutSize = pexConfig.RangeField( dtype=int, @@ -75,7 +76,9 @@ class PackageAlertsTask(pipeBase.Task): def __init__(self, **kwargs): super().__init__(**kwargs) - self.alertSchema = alertPack.Schema.from_file(self.config.schemaFile) + uri = ResourcePath(self.config.schemaFile) + with uri.as_local() as schemaFile: + self.alertSchema = alertPack.Schema.from_file(schemaFile.ospath) os.makedirs(self.config.alertWriteLocation, exist_ok=True) @timeMethod