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-32138: Remove exposureId from VisitInfo #697

Merged
merged 2 commits into from Jul 6, 2023
Merged

Conversation

parejkoj
Copy link
Contributor

@parejkoj parejkoj commented Jul 5, 2023

No description provided.

@parejkoj parejkoj force-pushed the tickets/DM-32138 branch 2 times, most recently from 507d310 to 63e7640 Compare July 5, 2023 19:24
Copy link
Member

@kfindeisen kfindeisen left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this. Only substantial comment is that I think the support for reading old versions is going to be hard to maintain; obviously the commit cleanup will be hard to do if you're still aiming to merge today.

src/image/VisitInfo.cc Outdated Show resolved Hide resolved
src/image/VisitInfo.cc Show resolved Hide resolved
src/image/VisitInfo.cc Show resolved Hide resolved
src/image/ExposureInfo.cc Outdated Show resolved Hide resolved
// exposureId was removed in version 5, but we need to reserve space in the schema for old files.
// We don't save the field record, as we don't need to read into it.
schema.addField<table::RecordId>("exposureid", "exposure ID", "");
}
Copy link
Member

Choose a reason for hiding this comment

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

This seems... not very portable if there are more schema changes in the future; the logic for exactly which fields belong in which version could get quite twisty. You also have to sacrifice the benefits of one-time initialization to do it this way. And then there's the potential confusion from VisitInfoSchema acting like a singleton but not actually being one (a dualton?).

Why not just have separate classes for versions 0-4 and 5+, and make VisitInfoFactory responsible for initializing the correct schema? Then you could extend to future incompatibilities without worrying about accidentally changing the old stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd tried your latter approach, but ran into C++ compiler problems that I couldn't sort out. This approach was @TallJimbo 's suggest (on top of my initial attempt that forgot about the static members and had the "get which version" in the factory).

Line number no longer accurate, but this was the error (I had made a VisitInfoSchemaWithExposureId subclass):

src/image/VisitInfo.cc:322:39: error: member initializer 'schema' does not name a non-static data member or base class
    VisitInfoSchemaWithExposureId() : schema() {

Copy link
Member

Choose a reason for hiding this comment

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

🤦 Right, I've been working in Python for too long. But this version's also potentially unsafe re: its API (you're fine this time because you don't care about the expId key in either case), so maybe file a ticket to clean up the implementation later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm game to try another approach here, if you have a suggestion (or a way around the error above, which I think is due to static-ness of schema shared between the parent and child classes). I think CRTP would be one way around it.

Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why schema would be static (it's not so in the current or previous versions?), but I don't think this is a problem we can solve in <1 hour. The current code at least gives the desired behavior for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tests/test_visitInfo.py Show resolved Hide resolved
We have to preserve the schema order for older versions that don't
have exposureId.
@parejkoj parejkoj merged commit e482522 into main Jul 6, 2023
2 checks passed
@parejkoj parejkoj deleted the tickets/DM-32138 branch July 6, 2023 03:17
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.

None yet

2 participants