Skip to content

Commit

Permalink
Remove repo alias finding from multiple places
Browse files Browse the repository at this point in the history
Now works directly with ButlerConfig.
  • Loading branch information
timj committed Jun 7, 2023
1 parent 3bf75af commit c7a57fc
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
20 changes: 1 addition & 19 deletions python/lsst/daf/butler/_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,25 +229,7 @@ def __init__(
self.storageClasses = butler.storageClasses
self._config: ButlerConfig = butler._config
else:
# Can only look for strings in the known repos list.
if isinstance(config, str):
# Somehow ButlerConfig fails in some cases if config is a
# ResourcePath, force it back to string here.
try:
config = str(self.get_repo_uri(config, True))
except FileNotFoundError:
pass
try:
self._config = ButlerConfig(config, searchPaths=searchPaths)
except FileNotFoundError as e:
if known := self.get_known_repos():
aliases = f"(known aliases: {', '.join(known)})"
else:
failure_reason = ButlerRepoIndex.get_failure_reason()
if failure_reason:
failure_reason = f": {failure_reason}"
aliases = f"(no known aliases{failure_reason})"
raise FileNotFoundError(f"{e} {aliases}") from e
self._config = ButlerConfig(config, searchPaths=searchPaths)
try:
if "root" in self._config:
butlerRoot = self._config["root"]
Expand Down
3 changes: 0 additions & 3 deletions python/lsst/daf/butler/_quantum_backed.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from pydantic import BaseModel

from ._butlerConfig import ButlerConfig
from ._butlerRepoIndex import ButlerRepoIndex
from ._deferredDatasetHandle import DeferredDatasetHandle
from ._limited_butler import LimitedButler
from .core import (
Expand Down Expand Up @@ -332,8 +331,6 @@ def _initialize(
dataset_types: `Mapping` [`str`, `DatasetType`]
Mapping of the dataset type name to its registry definition.
"""
if isinstance(config, str):
config = ButlerRepoIndex.get_repo_uri(config, True)
butler_config = ButlerConfig(config, searchPaths=search_paths)
if "root" in butler_config:
butler_root = butler_config["root"]
Expand Down
4 changes: 1 addition & 3 deletions python/lsst/daf/butler/script/configDump.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from typing import IO

from .._butlerConfig import ButlerConfig
from .._butlerRepoIndex import ButlerRepoIndex


def configDump(repo: str, subset: str, searchpath: str, outfile: IO) -> None:
Expand All @@ -50,8 +49,7 @@ def configDump(repo: str, subset: str, searchpath: str, outfile: IO) -> None:
AttributeError
If there is an issue dumping the configuration.
"""
repo_path = ButlerRepoIndex.get_repo_uri(repo, True)
config = ButlerConfig(repo_path, searchPaths=searchpath)
config = ButlerConfig(repo, searchPaths=searchpath)
if subset is not None:
try:
config = config[subset]
Expand Down

0 comments on commit c7a57fc

Please sign in to comment.