Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/DM-33226.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The ``Instrument.configPaths`` property can now refer to ``lsst.resources.ResourcePath`` URIs as well as strings (paths or URI strings).
11 changes: 6 additions & 5 deletions python/lsst/pipe/base/_instrument.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@

import contextlib
import datetime
import os.path
from abc import ABCMeta, abstractmethod
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, Self, cast, final

from lsst.daf.butler import DataCoordinate, DataId, DimensionPacker, DimensionRecord, Formatter
from lsst.daf.butler.registry import DataIdError
from lsst.pex.config import Config, RegistryField
from lsst.resources import ResourcePath, ResourcePathExpression
from lsst.utils import doImportType
from lsst.utils.introspection import get_full_type_name

Expand All @@ -65,7 +65,7 @@ class Instrument(metaclass=ABCMeta):
the base class.
"""

configPaths: Sequence[str] = ()
configPaths: Sequence[ResourcePathExpression] = ()
"""Paths to config files to read for specific Tasks.

The paths in this list should contain files of the form `task.py`, for
Expand Down Expand Up @@ -366,9 +366,10 @@ def applyConfigOverrides(self, name: str, config: Config) -> None:
Config instance to which overrides should be applied.
"""
for root in self.configPaths:
path = os.path.join(root, f"{name}.py")
if os.path.exists(path):
config.load(path)
resource = ResourcePath(root, forceDirectory=True, forceAbsolute=True)
uri = resource.join(f"{name}.py", forceDirectory=False)
if uri.exists():
config.load(uri)

@staticmethod
def formatCollectionTimestamp(timestamp: str | datetime.datetime) -> str:
Expand Down
Loading