Skip to content

Commit

Permalink
Rename RegistryFactory to _RegistryFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-slac committed Jul 13, 2023
1 parent 6e3cf8a commit 5b07c4d
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 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 @@ -86,8 +86,8 @@
Registry,
RegistryConfig,
RegistryDefaults,
RegistryFactory,
_ButlerRegistry,
_RegistryFactory,
)
from .transfers import RepoExportContext

Expand Down Expand Up @@ -225,7 +225,7 @@ def __init__(
butlerRoot = self._config.configDir
if writeable is None:
writeable = run is not None
self._registry = RegistryFactory(self._config).from_config(
self._registry = _RegistryFactory(self._config).from_config(
butlerRoot=butlerRoot, writeable=writeable, defaults=defaults
)
self._datastore = Datastore.fromConfig(
Expand Down Expand Up @@ -463,7 +463,7 @@ def makeRepo(
# Create Registry and populate tables
registryConfig = RegistryConfig(config.get("registry"))
dimensionConfig = DimensionConfig(dimensionConfig)
RegistryFactory(registryConfig).create_from_config(
_RegistryFactory(registryConfig).create_from_config(
dimensionConfig=dimensionConfig, butlerRoot=root_uri
)

Expand Down
6 changes: 3 additions & 3 deletions python/lsst/daf/butler/registry/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ def createFromConfig(
Notes
-----
This method is for backward compatibility only, until all clients
migrate to use new `~lsst.daf.butler.registry.RegistryFactory` factory
migrate to use new `~lsst.daf.butler.registry._RegistryFactory` factory
class. Regular clients of registry class do not use this method, it is
only used by tests in multiple packages.
"""
from ._registry_factory import RegistryFactory
from ._registry_factory import _RegistryFactory

Check warning on line 113 in python/lsst/daf/butler/registry/_registry.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/daf/butler/registry/_registry.py#L113

Added line #L113 was not covered by tests

return RegistryFactory(config).create_from_config(dimensionConfig, butlerRoot)
return _RegistryFactory(config).create_from_config(dimensionConfig, butlerRoot)

Check warning on line 115 in python/lsst/daf/butler/registry/_registry.py

View check run for this annotation

Codecov / codecov/patch

python/lsst/daf/butler/registry/_registry.py#L115

Added line #L115 was not covered by tests

@abstractmethod
def isWriteable(self) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/daf/butler/registry/_registry_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from __future__ import annotations

__all__ = ("RegistryFactory",)
__all__ = ("_RegistryFactory",)

from typing import TYPE_CHECKING

Expand All @@ -37,7 +37,7 @@
from .._butlerConfig import ButlerConfig


class RegistryFactory:
class _RegistryFactory:
"""Interface for creating and initializing Registry instances.
Parameters
Expand Down
4 changes: 2 additions & 2 deletions tests/test_dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
TimespanDatabaseRepresentation,
YamlRepoImportBackend,
)
from lsst.daf.butler.registry import RegistryConfig, RegistryFactory
from lsst.daf.butler.registry import RegistryConfig, _RegistryFactory

DIMENSION_DATA_FILE = os.path.normpath(
os.path.join(os.path.dirname(__file__), "data", "registry", "hsc-rc2-subset.yaml")
Expand All @@ -64,7 +64,7 @@ def loadDimensionData() -> DataCoordinateSequence:
# data and retreive it as a set of DataCoordinate objects.
config = RegistryConfig()
config["db"] = "sqlite://"
registry = RegistryFactory(config).create_from_config()
registry = _RegistryFactory(config).create_from_config()
with open(DIMENSION_DATA_FILE) as stream:
backend = YamlRepoImportBackend(stream, registry)
backend.register()
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 Registry, RegistryConfig, RegistryFactory, _ButlerRegistry
from lsst.daf.butler.registry import Registry, RegistryConfig, _ButlerRegistry, _RegistryFactory
from lsst.daf.butler.registry.obscore import (
DatasetTypeConfig,
ObsCoreConfig,
Expand Down Expand Up @@ -67,7 +67,7 @@ def make_registry(
) -> _ButlerRegistry:
"""Create new empty Registry."""
config = self.make_registry_config(collections, collection_type)
registry = RegistryFactory(config).create_from_config(butlerRoot=self.root)
registry = _RegistryFactory(config).create_from_config(butlerRoot=self.root)
self.initialize_registry(registry)
return registry

Expand Down
6 changes: 3 additions & 3 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 RegistryFactory, _ButlerRegistry
from lsst.daf.butler.registry import _ButlerRegistry, _RegistryFactory
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 @@ -245,9 +245,9 @@ def makeRegistry(self, share_repo_with: _ButlerRegistry | None = None) -> _Butle
config["db"] = self.server.url()
config["namespace"] = namespace
if share_repo_with is None:
return RegistryFactory(config).create_from_config()
return _RegistryFactory(config).create_from_config()
else:
return RegistryFactory(config).from_config()
return _RegistryFactory(config).from_config()


class PostgresqlRegistryNameKeyCollMgrUUIDTestCase(PostgresqlRegistryTests, unittest.TestCase):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_quantumBackedButler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
RegistryConfig,
StorageClass,
)
from lsst.daf.butler.registry import RegistryFactory
from lsst.daf.butler.registry import _RegistryFactory
from lsst.daf.butler.tests.utils import makeTestTempDir, removeTestTempDir
from lsst.resources import ResourcePath

Expand All @@ -55,7 +55,7 @@ def setUp(self) -> None:

# Make a butler and import dimension definitions.
registryConfig = RegistryConfig(self.config.get("registry"))
RegistryFactory(registryConfig).create_from_config(butlerRoot=self.root)
_RegistryFactory(registryConfig).create_from_config(butlerRoot=self.root)
self.butler = Butler(self.config, writeable=True, run="RUN")
self.butler.import_(filename=os.path.join(TESTDIR, "data", "registry", "base.yaml"))

Expand Down
4 changes: 2 additions & 2 deletions tests/test_query_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import re
import unittest

from lsst.daf.butler.registry import MissingSpatialOverlapError, RegistryConfig, RegistryFactory, queries
from lsst.daf.butler.registry import MissingSpatialOverlapError, RegistryConfig, _RegistryFactory, queries
from lsst.daf.butler.transfers import YamlRepoImportBackend

TESTDIR = os.path.abspath(os.path.dirname(__file__))
Expand All @@ -52,7 +52,7 @@ class TestQueryRelationsTests(unittest.TestCase):
def setUpClass(cls) -> None:
config = RegistryConfig()
config["db"] = "sqlite://"
cls.registry = RegistryFactory(config).create_from_config()
cls.registry = _RegistryFactory(config).create_from_config()
# We need just enough test data to have valid dimension records for
# all of the dimensions we're concerned with, and we want to pick
# values for each dimension that correspond to a spatiotemporal
Expand Down
4 changes: 2 additions & 2 deletions tests/test_simpleButler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

import astropy.time
from lsst.daf.butler import Butler, ButlerConfig, CollectionType, DatasetId, DatasetRef, DatasetType, Timespan
from lsst.daf.butler.registry import RegistryConfig, RegistryDefaults, RegistryFactory
from lsst.daf.butler.registry import RegistryConfig, RegistryDefaults, _RegistryFactory
from lsst.daf.butler.tests import DatastoreMock
from lsst.daf.butler.tests.utils import makeTestTempDir, removeTestTempDir

Expand Down Expand Up @@ -71,7 +71,7 @@ def makeButler(self, **kwargs: Any) -> Butler:

# have to make a registry first
registryConfig = RegistryConfig(config.get("registry"))
RegistryFactory(registryConfig).create_from_config()
_RegistryFactory(registryConfig).create_from_config()

butler = Butler(config, **kwargs)
DatastoreMock.apply(butler)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import sqlalchemy
from lsst.daf.butler import ddl
from lsst.daf.butler.registry import RegistryFactory, _ButlerRegistry
from lsst.daf.butler.registry import _ButlerRegistry, _RegistryFactory
from lsst.daf.butler.registry.databases.sqlite import SqliteDatabase
from lsst.daf.butler.registry.tests import DatabaseTests, RegistryTests
from lsst.daf.butler.tests.utils import makeTestTempDir, removeTestTempDir
Expand Down Expand Up @@ -204,9 +204,9 @@ def makeRegistry(self, share_repo_with: _ButlerRegistry | None = None) -> _Butle
config = self.makeRegistryConfig()
config["db"] = f"sqlite:///{filename}"
if share_repo_with is None:
return RegistryFactory(config).create_from_config(butlerRoot=self.root)
return _RegistryFactory(config).create_from_config(butlerRoot=self.root)
else:
return RegistryFactory(config).from_config(butlerRoot=self.root)
return _RegistryFactory(config).from_config(butlerRoot=self.root)


class SqliteFileRegistryNameKeyCollMgrUUIDTestCase(SqliteFileRegistryTests, unittest.TestCase):
Expand Down Expand Up @@ -247,7 +247,7 @@ def makeRegistry(self, share_repo_with: _ButlerRegistry | None = None) -> _Butle
return None
config = self.makeRegistryConfig()
config["db"] = "sqlite://"
return RegistryFactory(config).create_from_config()
return _RegistryFactory(config).create_from_config()

def testMissingAttributes(self):
"""Test for instantiating a registry against outdated schema which
Expand All @@ -258,7 +258,7 @@ def testMissingAttributes(self):
config = self.makeRegistryConfig()
config["db"] = "sqlite://"
with self.assertRaises(LookupError):
RegistryFactory(config).from_config()
_RegistryFactory(config).from_config()


class SqliteMemoryRegistryNameKeyCollMgrUUIDTestCase(unittest.TestCase, SqliteMemoryRegistryTests):
Expand Down

0 comments on commit 5b07c4d

Please sign in to comment.