Skip to content

Commit

Permalink
Rename ButlerRegistry to _ButlerRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-slac committed Jul 13, 2023
1 parent 020fe5b commit 6e3cf8a
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 56 deletions.
6 changes: 3 additions & 3 deletions python/lsst/daf/butler/_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
from .core.repoRelocation import BUTLER_ROOT_TAG
from .core.utils import transactional
from .registry import (
ButlerRegistry,
CollectionType,
ConflictingDefinitionError,
DataIdError,
Expand All @@ -88,6 +87,7 @@
RegistryConfig,
RegistryDefaults,
RegistryFactory,
_ButlerRegistry,
)
from .transfers import RepoExportContext

Expand Down Expand Up @@ -2649,9 +2649,9 @@ def dimensions(self) -> DimensionUniverse:
# Docstring inherited.
return self._registry.dimensions

_registry: ButlerRegistry
_registry: _ButlerRegistry
"""The object that manages dataset metadata and relationships
(`ButlerRegistry`).
(`_ButlerRegistry`).
Most operations that don't involve reading or writing butler datasets are
accessible only via `Registry` methods.
Expand Down
14 changes: 7 additions & 7 deletions python/lsst/daf/butler/registries/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@
QueryDatasetsModel,
QueryDimensionRecordsModel,
)
from ..registry import ButlerRegistry, CollectionSummary, CollectionType, RegistryConfig, RegistryDefaults
from ..registry import CollectionSummary, CollectionType, RegistryConfig, RegistryDefaults, _ButlerRegistry

if TYPE_CHECKING:
from .._butlerConfig import ButlerConfig
from ..registry._registry import CollectionArgType
from ..registry.interfaces import CollectionRecord, DatastoreRegistryBridgeManager


class RemoteRegistry(ButlerRegistry):
class RemoteRegistry(_ButlerRegistry):
"""Registry that can talk to a remote Butler server.
Parameters
Expand All @@ -91,8 +91,8 @@ def createFromConfig(
config: RegistryConfig | str | None = None,
dimensionConfig: DimensionConfig | str | None = None,
butlerRoot: ResourcePathExpression | None = None,
) -> ButlerRegistry:
"""Create registry database and return `ButlerRegistry` instance.
) -> _ButlerRegistry:
"""Create registry database and return `_ButlerRegistry` instance.
A remote registry can not create a registry database. Calling this
method will raise an exception.
Expand All @@ -106,7 +106,7 @@ def fromConfig(
butlerRoot: ResourcePathExpression | None = None,
writeable: bool = True,
defaults: RegistryDefaults | None = None,
) -> ButlerRegistry:
) -> _ButlerRegistry:
# Docstring inherited from lsst.daf.butler.registry.Registry
config = cls.forceRegistryConfig(config)
config.replaceRoot(butlerRoot)
Expand Down Expand Up @@ -162,8 +162,8 @@ def isWriteable(self) -> bool:
# Can be used to prevent any PUTs to server
return self._writeable

def copy(self, defaults: RegistryDefaults | None = None) -> ButlerRegistry:
# Docstring inherited from lsst.daf.butler.registry.ButlerRegistry
def copy(self, defaults: RegistryDefaults | None = None) -> _ButlerRegistry:
# Docstring inherited from lsst.daf.butler.registry._ButlerRegistry
if defaults is None:
# No need to copy, because `RegistryDefaults` is immutable; we
# effectively copy on write.
Expand Down
10 changes: 5 additions & 5 deletions python/lsst/daf/butler/registries/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
from ..core.utils import transactional
from ..registry import (
ArgumentError,
ButlerRegistry,
CollectionExpressionError,
CollectionSummary,
CollectionType,
Expand All @@ -76,6 +75,7 @@
RegistryConfig,
RegistryConsistencyError,
RegistryDefaults,
_ButlerRegistry,
queries,
)
from ..registry.interfaces import ChainedCollectionRecord, RunRecord
Expand All @@ -96,7 +96,7 @@
_LOG = logging.getLogger(__name__)


class SqlRegistry(ButlerRegistry):
class SqlRegistry(_ButlerRegistry):
"""Registry implementation based on SQLAlchemy.
Parameters
Expand All @@ -121,7 +121,7 @@ def createFromConfig(
config: RegistryConfig | str | None = None,
dimensionConfig: DimensionConfig | str | None = None,
butlerRoot: ResourcePathExpression | None = None,
) -> ButlerRegistry:
) -> _ButlerRegistry:
"""Create registry database and return `SqlRegistry` instance.
This method initializes database contents, database must be empty
Expand Down Expand Up @@ -168,7 +168,7 @@ def fromConfig(
butlerRoot: ResourcePathExpression | None = None,
writeable: bool = True,
defaults: RegistryDefaults | None = None,
) -> ButlerRegistry:
) -> _ButlerRegistry:
"""Create `Registry` subclass instance from `config`.
Registry database must be initialized prior to calling this method.
Expand Down Expand Up @@ -225,7 +225,7 @@ def isWriteable(self) -> bool:
# Docstring inherited from lsst.daf.butler.registry.Registry
return self._db.isWriteable()

def copy(self, defaults: RegistryDefaults | None = None) -> ButlerRegistry:
def copy(self, defaults: RegistryDefaults | None = None) -> _ButlerRegistry:
# Docstring inherited from lsst.daf.butler.registry.Registry
if defaults is None:
# No need to copy, because `RegistryDefaults` is immutable; we
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/registry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from . import interfaces, managers, queries, wildcards
from ._butler_registry import ButlerRegistry
from ._butler_registry import _ButlerRegistry
from ._collection_summary import *
from ._collectionType import *
from ._config import *
Expand Down
34 changes: 17 additions & 17 deletions python/lsst/daf/butler/registry/_butler_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from __future__ import annotations

__all__ = ("ButlerRegistry",)
__all__ = ("_ButlerRegistry",)

from abc import abstractmethod
from typing import TYPE_CHECKING
Expand All @@ -38,7 +38,7 @@
from .interfaces import CollectionRecord, DatastoreRegistryBridgeManager


class ButlerRegistry(Registry):
class _ButlerRegistry(Registry):
"""Registry interface extended with methods used by Butler implementation.
Each registry implementation can have its own constructor parameters.
Expand Down Expand Up @@ -84,8 +84,8 @@ def createFromConfig(
config: RegistryConfig | str | None = None,
dimensionConfig: DimensionConfig | str | None = None,
butlerRoot: ResourcePathExpression | None = None,
) -> ButlerRegistry:
"""Create registry database and return `ButlerRegistry` instance.
) -> _ButlerRegistry:
"""Create registry database and return `_ButlerRegistry` instance.
This method initializes database contents, database must be empty
prior to calling this method.
Expand All @@ -103,12 +103,12 @@ def createFromConfig(
Returns
-------
registry : `ButlerRegistry`
A new `ButlerRegistry` instance.
registry : `_ButlerRegistry`
A new `_ButlerRegistry` instance.
Notes
-----
This class will determine the concrete `ButlerRegistry` subclass to
This class will determine the concrete `_ButlerRegistry` subclass to
use from configuration. Each subclass should implement this method
even if it can not create a registry.
"""
Expand All @@ -122,8 +122,8 @@ def fromConfig(
butlerRoot: ResourcePathExpression | None = None,
writeable: bool = True,
defaults: RegistryDefaults | None = None,
) -> ButlerRegistry:
"""Create `ButlerRegistry` subclass instance from ``config``.
) -> _ButlerRegistry:
"""Create `_ButlerRegistry` subclass instance from ``config``.
Registry database must be initialized prior to calling this method.
Expand All @@ -141,12 +141,12 @@ def fromConfig(
Returns
-------
registry : `ButlerRegistry` (subclass)
A new `ButlerRegistry` subclass instance.
registry : `_ButlerRegistry` (subclass)
A new `_ButlerRegistry` subclass instance.
Notes
-----
This class will determine the concrete `ButlerRegistry` subclass to
This class will determine the concrete `_ButlerRegistry` subclass to
use from configuration. Each subclass should implement this method.
"""
# The base class implementation should trampoline to the correct
Expand All @@ -156,9 +156,9 @@ def fromConfig(
raise NotImplementedError()

@abstractmethod
def copy(self, defaults: RegistryDefaults | None = None) -> ButlerRegistry:
"""Create a new `ButlerRegistry` backed by the same data repository and
connection as this one, but independent defaults.
def copy(self, defaults: RegistryDefaults | None = None) -> _ButlerRegistry:
"""Create a new `_ButlerRegistry` backed by the same data repository
and connection as this one, but independent defaults.
Parameters
----------
Expand All @@ -169,8 +169,8 @@ def copy(self, defaults: RegistryDefaults | None = None) -> ButlerRegistry:
Returns
-------
copy : `ButlerRegistry`
A new `ButlerRegistry` instance with its own defaults.
copy : `_ButlerRegistry`
A new `_ButlerRegistry` instance with its own defaults.
Notes
-----
Expand Down
22 changes: 11 additions & 11 deletions python/lsst/daf/butler/registry/_registry_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from lsst.utils import doImportType

from ..core import Config, DimensionConfig
from ._butler_registry import ButlerRegistry
from ._butler_registry import _ButlerRegistry
from ._config import RegistryConfig
from ._defaults import RegistryDefaults

Expand Down Expand Up @@ -69,18 +69,18 @@ def __init__(self, config: ButlerConfig | RegistryConfig | Config | str | None):
# Default to the standard registry
registry_cls_name = config.get("cls", "lsst.daf.butler.registries.sql.SqlRegistry")
registry_cls = doImportType(registry_cls_name)
if not issubclass(registry_cls, ButlerRegistry):
if not issubclass(registry_cls, _ButlerRegistry):
raise TypeError(
f"Registry class obtained from config {registry_cls_name} is not a ButlerRegistry class."
f"Registry class obtained from config {registry_cls_name} is not a _ButlerRegistry class."
)
self._registry_cls = registry_cls

def create_from_config(
self,
dimensionConfig: DimensionConfig | str | None = None,
butlerRoot: ResourcePathExpression | None = None,
) -> ButlerRegistry:
"""Create registry database and return `ButlerRegistry` instance.
) -> _ButlerRegistry:
"""Create registry database and return `_ButlerRegistry` instance.
This method initializes database contents, database must be empty
prior to calling this method.
Expand All @@ -95,8 +95,8 @@ def create_from_config(
Returns
-------
registry : `ButlerRegistry`
A new `ButlerRegistry` instance.
registry : `_ButlerRegistry`
A new `_ButlerRegistry` instance.
"""
return self._registry_cls.createFromConfig(self._config, dimensionConfig, butlerRoot)

Expand All @@ -105,8 +105,8 @@ def from_config(
butlerRoot: ResourcePathExpression | None = None,
writeable: bool = True,
defaults: RegistryDefaults | None = None,
) -> ButlerRegistry:
"""Create `ButlerRegistry` subclass instance from ``config``.
) -> _ButlerRegistry:
"""Create `_ButlerRegistry` subclass instance from ``config``.
Registry database must be initialized prior to calling this method.
Expand All @@ -122,7 +122,7 @@ def from_config(
Returns
-------
registry : `ButlerRegistry` (subclass)
A new `ButlerRegistry` subclass instance.
registry : `_ButlerRegistry` (subclass)
A new `_ButlerRegistry` subclass instance.
"""
return self._registry_cls.fromConfig(self._config, butlerRoot, writeable, defaults)
4 changes: 2 additions & 2 deletions python/lsst/daf/butler/tests/_datasetsHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

if TYPE_CHECKING:
from lsst.daf.butler import Config, DatasetId, Datastore, Dimension, DimensionGraph
from lsst.daf.butler.registry import ButlerRegistry
from lsst.daf.butler.registry import _ButlerRegistry


class DatasetTestHelper:
Expand Down Expand Up @@ -102,7 +102,7 @@ class DatastoreTestHelper:
datastoreType: type[Datastore]
configFile: str

def setUpDatastoreTests(self, registryClass: type[ButlerRegistry], configClass: type[Config]) -> None:
def setUpDatastoreTests(self, registryClass: type[_ButlerRegistry], configClass: type[Config]) -> None:
"""Shared setUp code for all Datastore tests."""
self.registry = registryClass()
self.config = configClass(self.configFile)
Expand Down
6 changes: 3 additions & 3 deletions python/lsst/daf/butler/transfers/_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
DimensionRecord,
FileDataset,
)
from ..registry import ButlerRegistry, CollectionType
from ..registry import CollectionType, _ButlerRegistry
from ..registry.interfaces import ChainedCollectionRecord, CollectionRecord
from ._interfaces import RepoExportBackend

Expand All @@ -58,7 +58,7 @@ class RepoExportContext:
Parameters
----------
registry : `ButlerRegistry`
registry : `_ButlerRegistry`
Registry to export from.
datastore : `Datastore`
Datastore to export from.
Expand All @@ -73,7 +73,7 @@ class RepoExportContext:

def __init__(
self,
registry: ButlerRegistry,
registry: _ButlerRegistry,
datastore: Datastore,
backend: RepoExportBackend,
*,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_obscore.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
StorageClassFactory,
)
from lsst.daf.butler.registries.sql import SqlRegistry
from lsst.daf.butler.registry import ButlerRegistry, Registry, RegistryConfig, RegistryFactory
from lsst.daf.butler.registry import Registry, RegistryConfig, RegistryFactory, _ButlerRegistry
from lsst.daf.butler.registry.obscore import (
DatasetTypeConfig,
ObsCoreConfig,
Expand All @@ -64,7 +64,7 @@ class ObsCoreTests(TestCaseMixin):

def make_registry(
self, collections: list[str] | None = None, collection_type: str | None = None
) -> ButlerRegistry:
) -> _ButlerRegistry:
"""Create new empty Registry."""
config = self.make_registry_config(collections, collection_type)
registry = RegistryFactory(config).create_from_config(butlerRoot=self.root)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

import sqlalchemy
from lsst.daf.butler import Timespan, ddl
from lsst.daf.butler.registry import ButlerRegistry, RegistryFactory
from lsst.daf.butler.registry import RegistryFactory, _ButlerRegistry
from lsst.daf.butler.registry.databases.postgresql import PostgresqlDatabase, _RangeTimespanType
from lsst.daf.butler.registry.tests import DatabaseTests, RegistryTests
from lsst.daf.butler.tests.utils import makeTestTempDir, removeTestTempDir
Expand Down Expand Up @@ -236,7 +236,7 @@ def tearDownClass(cls):
def getDataDir(cls) -> str:
return os.path.normpath(os.path.join(os.path.dirname(__file__), "data", "registry"))

def makeRegistry(self, share_repo_with: ButlerRegistry | None = None) -> ButlerRegistry:
def makeRegistry(self, share_repo_with: _ButlerRegistry | None = None) -> _ButlerRegistry:
if share_repo_with is None:
namespace = f"namespace_{secrets.token_hex(8).lower()}"
else:
Expand Down
Loading

0 comments on commit 6e3cf8a

Please sign in to comment.