Skip to content

Commit

Permalink
Allow schema file to be a general URI
Browse files Browse the repository at this point in the history
This allows it to be read from anywhere supported by ResourcePath.
  • Loading branch information
timj committed Aug 29, 2023
1 parent 6758148 commit 6a491c7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions python/lsst/ap/association/packageAlerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 6a491c7

Please sign in to comment.