Skip to content

Commit

Permalink
Merge pull request #31 from lsst-dm/tickets/DM-42509
Browse files Browse the repository at this point in the history
DM-42509: Extend output of show-current command
  • Loading branch information
andy-slac authored Jan 16, 2024
2 parents a19f4ec + 0aa4284 commit 2ea602a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.11.0
rev: 23.12.1
hooks:
- id: black
# It is recommended to specify the latest version of Python
Expand All @@ -15,12 +15,12 @@ repos:
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.11
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.7
rev: v0.1.13
hooks:
- id: ruff
14 changes: 7 additions & 7 deletions doc/lsst.daf.butler_migrate/typical-tasks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ If ``(head)`` is missing then newer revisions exist in the revision history, and
With the ``--butler`` option this command displays information from the ``butler_attributes`` table::

$ butler migrate show-current --butler $REPO
attributes: lsst.daf.butler.registry.attributes.DefaultButlerAttributeManager 1.0.0 -> f22a777cf382
collections: lsst.daf.butler.registry.collections.synthIntKey.SynthIntKeyCollectionManager 2.0.0 -> 8c57494cabcc
datasets: lsst.daf.butler.registry.datasets.byDimensions._manager.ByDimensionsDatasetRecordStorageManagerUUID 1.0.0 -> 2101fbf51ad3
datastores: lsst.daf.butler.registry.bridge.monolithic.MonolithicDatastoreRegistryBridgeManager 0.2.0 -> a07b3b60e369
dimensions: lsst.daf.butler.registry.dimensions.static.StaticDimensionRecordStorageManager 6.0.2 -> 035dcf13ef18
dimensions-config: daf_butler 3 -> c5ae3a2cd7c2
opaque: lsst.daf.butler.registry.opaque.ByNameOpaqueTableStorageManager 0.2.0 -> 77e5b803ad3f
attributes: lsst.daf.butler.registry.attributes.DefaultButlerAttributeManager 1.0.0 -> f22a777cf382 (head)
collections: lsst.daf.butler.registry.collections.synthIntKey.SynthIntKeyCollectionManager 2.0.0 -> 8c57494cabcc (head)
datasets: lsst.daf.butler.registry.datasets.byDimensions._manager.ByDimensionsDatasetRecordStorageManagerUUID 1.0.0 -> 2101fbf51ad3 (head)
datastores: lsst.daf.butler.registry.bridge.monolithic.MonolithicDatastoreRegistryBridgeManager 0.2.0 -> a07b3b60e369 (head)
dimensions: lsst.daf.butler.registry.dimensions.static.StaticDimensionRecordStorageManager 6.0.2 -> 035dcf13ef18 (head)
dimensions-config: daf_butler 3 -> c5ae3a2cd7c2 (head)
opaque: lsst.daf.butler.registry.opaque.ByNameOpaqueTableStorageManager 0.2.0 -> 77e5b803ad3f (head)

The output includes manager type name, its full class name (except for special ``dimensions-config`` manager), and its version number.
The revision number appearing here is calculated from those three items and it must match one of the revisions in ``alembic_version`` table.
Expand Down
3 changes: 0 additions & 3 deletions examples/SConscript

This file was deleted.

4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ dynamic = ["version"]
[project.optional-dependencies]
test = [
"pytest >= 3.2",
"flake8 >= 3.7.5",
"pytest-flake8 >= 1.0.4",
"pytest-openfiles >= 0.5.0"
]

Expand All @@ -49,7 +47,7 @@ zip-safe = true
license-files = ["COPYRIGHT", "LICENSE"]

[tool.setuptools.package-data]
"lsst.daf.butler_migrate" = []
"lsst.daf.butler_migrate" = ["py.typed", "cli/resources.yaml"]

[tool.setuptools.dynamic]
version = { attr = "lsst_versions.get_lsst_version" }
Expand Down
16 changes: 8 additions & 8 deletions python/lsst/daf/butler_migrate/script/migrate_current.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,24 @@ def migrate_current(repo: str, mig_path: str, verbose: bool, butler: bool, names
" stored dimensions configuration"
)

cfg: config.MigAlembicConfig | None = None
cfg = config.MigAlembicConfig.from_mig_path(mig_path, repository=repo, db=db)
if butler:
# Print current versions defined in butler.
script_info = scripts.Scripts(cfg)
heads = script_info.head_revisions()
manager_versions = db.manager_versions(namespace)
if manager_versions:
for manager, (klass, version, rev_id) in sorted(manager_versions.items()):
print(f"{manager}: {klass} {version} -> {rev_id}")
head = " (head)" if rev_id in heads else ""
print(f"{manager}: {klass} {version} -> {rev_id}{head}")
else:
print("No manager versions defined in butler_attributes table.")
else:
# Revisions from alembic
cfg = config.MigAlembicConfig.from_mig_path(mig_path, repository=repo, db=db)
# Revisions from alembic.
command.current(cfg, verbose=verbose)

# complain if alembic_version table is there but does not match manager
# versions
# Complain if alembic_version table is there but does not match manager
# versions.
if db.alembic_revisions():
if cfg is None:
cfg = config.MigAlembicConfig.from_mig_path(mig_path, repository=repo, db=db)
script_info = scripts.Scripts(cfg)
db.validate_revisions(namespace, script_info.base_revisions())
11 changes: 11 additions & 0 deletions python/lsst/daf/butler_migrate/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,14 @@ def base_revisions(self) -> list[str]:
migration tree.
"""
return list(self.scripts.get_bases())

def head_revisions(self) -> list[str]:
"""Return list of all head revisions, or tops of the migration trees.
Returns
-------
heads : `list` [`str`]
Head revisions, corresponding to the tops of the each migration
tree.
"""
return list(self.scripts.get_heads())

0 comments on commit 2ea602a

Please sign in to comment.