Skip to content

Commit

Permalink
Merge pull request #1055 from lsst/tickets/DM-45767
Browse files Browse the repository at this point in the history
DM-45767: Move CollectionType definition up a level
  • Loading branch information
timj authored Aug 14, 2024
2 parents b716002 + 0885e05 commit 6ba7992
Show file tree
Hide file tree
Showing 36 changed files with 44 additions and 40 deletions.
2 changes: 2 additions & 0 deletions doc/changes/DM-45767.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Moved ``CollectionType`` to the top level of the package hierarchy.
There should be no change visible to external users but if previously you were using the deprecated ``from lsst.daf.butler.registry import CollectionType`` please change to ``from lsst.daf.butler import CollectionType`` (which has always worked).
9 changes: 2 additions & 7 deletions python/lsst/daf/butler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from ._butler_collections import *
from ._butler_config import *
from ._butler_repo_index import *
from ._collection_type import CollectionType
from ._column_categorization import *
from ._column_tags import *
from ._column_type_info import *
Expand Down Expand Up @@ -81,13 +82,7 @@

# Do not import or lift symbols from 'server' or 'server_models'.
# Import the registry subpackage directly for other symbols.
from .registry import (
CollectionType,
MissingCollectionError,
NoDefaultCollectionError,
Registry,
RegistryConfig,
)
from .registry import MissingCollectionError, NoDefaultCollectionError, Registry, RegistryConfig
from .transfers import RepoExportContext, YamlRepoExportBackend, YamlRepoImportBackend
from .version import *

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/_registry_shim.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from collections.abc import Iterable, Iterator, Mapping, Sequence
from typing import TYPE_CHECKING, Any

from ._collection_type import CollectionType
from ._dataset_association import DatasetAssociation
from ._dataset_ref import DatasetId, DatasetIdGenEnum, DatasetRef
from ._dataset_type import DatasetType
Expand All @@ -47,7 +48,6 @@
)
from .registry import Registry
from .registry._collection_summary import CollectionSummary
from .registry._collection_type import CollectionType
from .registry._defaults import RegistryDefaults
from .registry.queries import DataCoordinateQueryResults, DatasetQueryResults, DimensionRecordQueryResults

Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/cli/opt/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
from typing import Any

import click
from lsst.daf.butler.registry import CollectionType
from lsst.daf.butler import CollectionType

from ..cliLog import CliLog
from ..utils import MWOptionDecorator, MWPath, split_commas, split_kv, unwrap, yaml_presets
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/direct_butler/_direct_butler.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
from .._butler import Butler
from .._butler_config import ButlerConfig
from .._butler_instance_options import ButlerInstanceOptions
from .._collection_type import CollectionType
from .._dataset_existence import DatasetExistence
from .._dataset_ref import DatasetRef
from .._dataset_type import DatasetType
Expand All @@ -69,7 +70,6 @@
from ..progress import Progress
from ..queries import Query
from ..registry import (
CollectionType,
ConflictingDefinitionError,
DataIdError,
MissingDatasetTypeError,
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/daf/butler/direct_query_driver/_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import sqlalchemy

from .. import ddl
from .._collection_type import CollectionType
from .._dataset_type import DatasetType
from .._exceptions import InvalidQueryError
from ..dimensions import DataCoordinate, DataIdValue, DimensionGroup, DimensionUniverse
Expand All @@ -62,7 +63,7 @@
GeneralResultSpec,
ResultSpec,
)
from ..registry import CollectionSummary, CollectionType, NoDefaultCollectionError
from ..registry import CollectionSummary, NoDefaultCollectionError
from ..registry.interfaces import ChainedCollectionRecord, CollectionRecord
from ..registry.managers import RegistryManagerInstances
from ..registry.wildcards import CollectionWildcard
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/daf/butler/registry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from .._collection_type import CollectionType

# Re-export some top-level exception types for backwards compatibility -- these
# used to be part of registry.
from .._exceptions import (
Expand All @@ -40,7 +42,6 @@
# Registry imports.
from . import interfaces, managers, queries, wildcards
from ._collection_summary import *
from ._collection_type import *
from ._config import *
from ._defaults import *
from ._exceptions import *
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/registry/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from types import EllipsisType
from typing import TYPE_CHECKING, Any, TypeAlias

from .._collection_type import CollectionType
from .._dataset_association import DatasetAssociation
from .._dataset_ref import DatasetId, DatasetIdGenEnum, DatasetRef
from .._dataset_type import DatasetType
Expand All @@ -51,7 +52,6 @@
DimensionUniverse,
)
from ._collection_summary import CollectionSummary
from ._collection_type import CollectionType
from ._defaults import RegistryDefaults
from .queries import DataCoordinateQueryResults, DatasetQueryResults, DimensionRecordQueryResults
from .wildcards import CollectionWildcard
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/registry/collections/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@

import sqlalchemy

from ..._collection_type import CollectionType
from ..._exceptions import CollectionCycleError, CollectionTypeError, MissingCollectionError
from ...timespan_database_representation import TimespanDatabaseRepresentation
from .._collection_record_cache import CollectionRecordCache
from .._collection_type import CollectionType
from ..interfaces import ChainedCollectionRecord, CollectionManager, CollectionRecord, RunRecord, VersionTuple
from ..wildcards import CollectionWildcard

Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/registry/collections/nameKey.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
import sqlalchemy

from ... import ddl
from ..._collection_type import CollectionType
from ...column_spec import COLLECTION_NAME_MAX_LENGTH
from ...timespan_database_representation import TimespanDatabaseRepresentation
from .._collection_type import CollectionType
from ..interfaces import ChainedCollectionRecord, CollectionRecord, RunRecord, VersionTuple
from ._base import (
CollectionTablesTuple,
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/registry/collections/synthIntKey.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

import sqlalchemy

from ..._collection_type import CollectionType
from ...column_spec import COLLECTION_NAME_MAX_LENGTH
from ...timespan_database_representation import TimespanDatabaseRepresentation
from .._collection_type import CollectionType
from ..interfaces import ChainedCollectionRecord, CollectionRecord, RunRecord, VersionTuple
from ._base import (
CollectionTablesTuple,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import sqlalchemy
from lsst.daf.relation import Relation, sql

from ...._collection_type import CollectionType
from ...._column_tags import DatasetColumnTag, DimensionKeyColumnTag
from ...._column_type_info import LogicalColumn
from ...._dataset_ref import DatasetId, DatasetIdFactory, DatasetIdGenEnum, DatasetRef
Expand All @@ -50,7 +51,6 @@
from ....direct_query_driver import QueryBuilder, QueryJoiner # new query system, server+direct only
from ....queries import tree as qt # new query system, both clients + server
from ..._collection_summary import CollectionSummary
from ..._collection_type import CollectionType
from ..._exceptions import ConflictingDefinitionError
from ...interfaces import DatasetRecordStorage
from ...queries import SqlQueryContext # old registry query system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
import sqlalchemy
from lsst.utils.iteration import chunk_iterable

from ...._collection_type import CollectionType
from ...._dataset_type import DatasetType
from ...._named import NamedKeyDict, NamedKeyMapping
from ....dimensions import GovernorDimension, addDimensionForeignKey
from ..._caching_context import CachingContext
from ..._collection_summary import CollectionSummary
from ..._collection_type import CollectionType
from ...interfaces import (
CollectionManager,
CollectionRecord,
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/registry/interfaces/_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@

import sqlalchemy

from ..._collection_type import CollectionType
from ..._timespan import Timespan
from .._collection_type import CollectionType
from ..wildcards import CollectionWildcard
from ._versioning import VersionedExtension, VersionTuple

Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/registry/queries/_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

from lsst.daf.relation import ColumnError, ColumnTag, Diagnostics, Relation, Sort, SortTerm

from ..._collection_type import CollectionType
from ..._column_tags import DatasetColumnTag, DimensionKeyColumnTag, DimensionRecordColumnTag
from ..._dataset_ref import DatasetRef
from ..._dataset_type import DatasetType
Expand All @@ -45,7 +46,6 @@
DimensionRecord,
DimensionRecordSet,
)
from .._collection_type import CollectionType
from ..wildcards import CollectionWildcard
from ._query_backend import QueryBackend
from ._query_context import QueryContext
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/registry/queries/_query_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
UnaryOperationRelation,
)

from ..._collection_type import CollectionType
from ..._column_tags import DatasetColumnTag, DimensionKeyColumnTag
from ..._dataset_type import DatasetType
from ..._exceptions import MissingDatasetTypeError
from ..._exceptions_legacy import DatasetTypeError
from ...dimensions import DimensionGroup, DimensionRecordSet, DimensionUniverse
from .._collection_type import CollectionType
from ..wildcards import CollectionWildcard
from ._query_context import QueryContext
from .find_first_dataset import FindFirstDataset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@

from lsst.daf.relation import ColumnError, ColumnExpression, ColumnTag, Join, Predicate, Relation

from ..._collection_type import CollectionType
from ..._column_categorization import ColumnCategorization
from ..._column_tags import DimensionKeyColumnTag, DimensionRecordColumnTag
from ..._dataset_type import DatasetType
from ..._exceptions import DataIdValueError
from ...dimensions import DimensionGroup, DimensionRecordSet, DimensionUniverse
from ...dimensions.record_cache import DimensionRecordCache
from .._collection_type import CollectionType
from ..interfaces import CollectionRecord, Database
from ._query_backend import QueryBackend
from ._sql_query_context import SqlQueryContext
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/registry/sql_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from lsst.resources import ResourcePathExpression
from lsst.utils.iteration import ensure_iterable

from .._collection_type import CollectionType
from .._column_tags import DatasetColumnTag
from .._config import Config
from .._dataset_association import DatasetAssociation
Expand Down Expand Up @@ -72,7 +73,6 @@
ArgumentError,
CollectionExpressionError,
CollectionSummary,
CollectionType,
CollectionTypeError,
ConflictingDefinitionError,
DatasetTypeError,
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/registry/tests/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import lsst.sphgeom
from lsst.daf.relation import Relation, RelationalAlgebraError, Transfer, iteration, sql

from ..._collection_type import CollectionType
from ..._dataset_association import DatasetAssociation
from ..._dataset_ref import DatasetIdFactory, DatasetIdGenEnum, DatasetRef
from ..._dataset_type import DatasetType
Expand All @@ -74,7 +75,6 @@
from ..._timespan import Timespan
from ...dimensions import DataCoordinate, DataCoordinateSet, SkyPixDimension
from .._collection_summary import CollectionSummary
from .._collection_type import CollectionType
from .._config import RegistryConfig
from .._exceptions import (
ArgumentError,
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/remote_butler/_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

from lsst.utils.iteration import ensure_iterable

from .._collection_type import CollectionType
from .._dataset_association import DatasetAssociation
from .._dataset_ref import DatasetId, DatasetIdGenEnum, DatasetRef
from .._dataset_type import DatasetType
Expand All @@ -49,7 +50,6 @@
from ..registry import (
CollectionArgType,
CollectionSummary,
CollectionType,
CollectionTypeError,
DatasetTypeError,
DatasetTypeExpressionError,
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/script/_associate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from collections.abc import Iterable

from .._butler import Butler
from ..registry import CollectionType
from .._collection_type import CollectionType
from .queryDatasets import QueryDatasets


Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/script/_pruneDatasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from typing import TYPE_CHECKING, Any

from .._butler import Butler
from ..registry import CollectionType
from .._collection_type import CollectionType
from .queryDatasets import QueryDatasets

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/script/certifyCalibrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import astropy.time

from .._butler import Butler
from .._collection_type import CollectionType
from .._timespan import Timespan
from ..registry import CollectionType


def certifyCalibrations(
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/daf/butler/script/collectionChain.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
from collections.abc import Iterable

from .._butler import Butler
from ..registry import CollectionType, MissingCollectionError
from .._collection_type import CollectionType
from ..registry import MissingCollectionError
from ..registry.wildcards import CollectionWildcard


Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/script/exportCalibs.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from astropy.table import Table

from .._butler import Butler
from ..registry import CollectionType
from .._collection_type import CollectionType

if TYPE_CHECKING:
from lsst.daf.butler import DatasetRef, DatasetType
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/daf/butler/script/queryCollections.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
from astropy.table import Table

from .._butler import Butler
from ..registry import CollectionType
from .._collection_type import CollectionType


def _getTable(
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/daf/butler/script/removeCollections.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
from astropy.table import Table

from .._butler import Butler
from ..registry import CollectionType, MissingCollectionError
from .._collection_type import CollectionType
from ..registry import MissingCollectionError


@dataclass
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/daf/butler/script/removeRuns.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
from functools import partial

from .._butler import Butler
from ..registry import CollectionType, MissingCollectionError
from .._collection_type import CollectionType
from ..registry import MissingCollectionError


@dataclass
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/daf/butler/tests/butler_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@
from lsst.sphgeom import Region

from .._butler import Butler
from .._collection_type import CollectionType
from .._dataset_type import DatasetType
from .._exceptions import InvalidQueryError
from .._timespan import Timespan
from ..dimensions import DataCoordinate, DimensionGroup, DimensionRecord
from ..direct_query_driver import DirectQueryDriver
from ..queries import DimensionRecordQueryResults
from ..queries.tree import Predicate
from ..registry import CollectionType, NoDefaultCollectionError, RegistryDefaults
from ..registry import NoDefaultCollectionError, RegistryDefaults
from ..registry.sql_registry import SqlRegistry
from ..transfers import YamlRepoImportBackend
from .utils import TestCaseMixin
Expand Down
3 changes: 2 additions & 1 deletion python/lsst/daf/butler/tests/hybrid_butler_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence
from typing import Any, cast

from .._collection_type import CollectionType
from .._dataset_association import DatasetAssociation
from .._dataset_ref import DatasetId, DatasetIdGenEnum, DatasetRef
from .._dataset_type import DatasetType
Expand All @@ -44,7 +45,7 @@
DimensionRecord,
DimensionUniverse,
)
from ..registry import CollectionArgType, CollectionSummary, CollectionType, Registry, RegistryDefaults
from ..registry import CollectionArgType, CollectionSummary, Registry, RegistryDefaults
from ..registry.queries import (
DataCoordinateQueryResults,
DatasetQueryResults,
Expand Down
Loading

0 comments on commit 6ba7992

Please sign in to comment.