Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-43105: Add migration script for dimension universe 7 #38

Merged
merged 2 commits into from
Apr 8, 2024

Conversation

dhirving
Copy link
Contributor

@dhirving dhirving commented Mar 28, 2024

Checklist

  • added documentation for a new migration script

Pull out the _Context class from the dimension 6 migration to a separate file, since we need all the same stuff for the dimension 7 migration.
Copy link

codecov bot commented Mar 28, 2024

Codecov Report

Attention: Patch coverage is 44.44444% with 10 lines in your changes are missing coverage. Please review.

Project coverage is 55.66%. Comparing base (5bbff68) to head (0615730).

❗ Current head 0615730 differs from pull request most recent head 9e38d70. Consider uploading reports for the commit 9e38d70 to get more accurate results

Files Patch % Lines
...ython/lsst/daf/butler_migrate/migration_context.py 44.44% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #38      +/-   ##
==========================================
- Coverage   55.82%   55.66%   -0.16%     
==========================================
  Files          37       38       +1     
  Lines        1297     1315      +18     
  Branches      281      281              
==========================================
+ Hits          724      732       +8     
- Misses        536      546      +10     
  Partials       37       37              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dhirving dhirving force-pushed the tickets/DM-43105 branch 5 times, most recently from c6a1030 to 0615730 Compare April 5, 2024 23:14
@dhirving dhirving marked this pull request as ready for review April 5, 2024 23:34
Copy link
Collaborator

@andy-slac andy-slac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, few minor comments.


from .butler_attributes import ButlerAttributes

__all__ = ("MigrationContext",)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__all__ should be above all import (except __future__) according to our developers' manual.

from __future__ import annotations

import alembic
import sqlalchemy as sa
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we try not to shorten names to extremely short 2-character abbreviations. There are probably many examples for sa but we should try to avoid using it.

Comment on lines +33 to +35
"""Provides access to commonly-needed objects derived from the alembic
migration context.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add docstrings for attributes?

self.mig_context = alembic.context.get_context()
self.schema = self.mig_context.version_table_schema
bind = self.mig_context.bind
assert bind is not None, "Can't run offline -- need access to database to migrate data."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in the future we should try to provide better support for offline migrations. Some scripts already support it, maybe this context class should add some support for it too? Maybe something for the next ticket.

ctx.attributes.validate_dimensions_json(6)

_LOG.info("Adding can_see_sky column to exposure table")
op.add_column(_TABLE, sa.Column(_NEW_COLUMN, sa.Boolean, nullable=True), schema=ctx.schema)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this and everything below be done with batch migration, just in case we care about sqlite repos?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed -- all of these operations work and have been tested on sqlite already. They batch isn't needed because there is no alter column, foreign key changes, etc... just adding a column and some update queries.

# which is closely correlated with whether the sky is visible in the
# exposure.
#
# Any exposure types not in these lists are left null.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to think (not my usual activity) and parse many lines below to understand what "these lists" mean. Maybe define two lists explicitly?

)


def _find_unhandled_observation_types(ctx: MigrationContext) -> list[str]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstring would help me here.

@dhirving dhirving merged commit 9a81b3b into main Apr 8, 2024
10 checks passed
@dhirving dhirving deleted the tickets/DM-43105 branch April 8, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants