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

have OMERO server populate database with missing enumeration values #4837

Merged
merged 9 commits into from Sep 22, 2016

Conversation

mtbc
Copy link
Member

@mtbc mtbc commented Sep 12, 2016

What this PR does

When a new version of OMERO.server starts up (minor or major) it reviews the enumeration values defined in <enum> tags in components/model/resources/mappings/ and ensures that all those strings exist in the corresponding database tables.

Testing this PR

In an older version of OMERO delete a few enumeration values from the database. Upgrade to and start up the latest version of OMERO with this PR included and see if those values are added back.

Additionally the format table should continue to be populated with new image formats as reported by Bio-Formats readers whenever a new version of Bio-Formats is detected so in the above testing maybe also delete a few formats too that you know should be there (beyond just those listed in acquisition.ome.xml).

Related reading

https://trello.com/c/0zNp8HvU/167-enumerations-addition

to be used at server startup as a kind of upsert for enum values
to be superseded by use of the enumeration ensuring bean
@sbesson
Copy link
Member

sbesson commented Sep 13, 2016

With this commit, the following statements are executed at the server startup (DB upgraded from 5.2__0`):

2016-09-13 05:42:12,321 INFO  [           ome.services.util.BaseDBCheck] (      main) performed DB check DBEnumCheck: done for Bio-Formats revision bb58eb1577d2083f448f25ae3b827d35ed2158a2
2016-09-13 05:42:12,360 INFO  [        ome.services.util.ServiceHandler] (      main)  Executor.doWork -- ensure enum values
2016-09-13 05:42:12,360 INFO  [        ome.services.util.ServiceHandler] (      main)  Args:    [null, InternalSF@1034997834]
2016-09-13 05:42:12,364 INFO  [    ome.security.basic.BasicEventContext] (      main)  cctx:    group=1
2016-09-13 05:42:12,376 INFO  [         ome.security.basic.EventHandler] (      main)  Auth:    user=0,group=1,event=260232(Internal),sess=45ed22bf-458a-4194-a34a-cee0ac778b9c
2016-09-13 05:42:12,403 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value AcquisitionMode.BrightField
2016-09-13 05:42:12,405 INFO  [       ome.security.basic.CurrentDetails] (      main) Adding log:INSERT,class ome.model.enums.AcquisitionMode,22
2016-09-13 05:42:12,405 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value AcquisitionMode.SweptFieldConfocal
2016-09-13 05:42:12,406 INFO  [       ome.security.basic.CurrentDetails] (      main) Adding log:INSERT,class ome.model.enums.AcquisitionMode,23
2016-09-13 05:42:12,407 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value AcquisitionMode.SPIM
2016-09-13 05:42:12,410 INFO  [       ome.security.basic.CurrentDetails] (      main) Adding log:INSERT,class ome.model.enums.AcquisitionMode,24
2016-09-13 05:42:12,421 INFO  [                 org.perf4j.TimingLogger] (      main) start[1473741732361] time[60] tag[omero.call.success.ome.services.util.EnsureEnum$1.doWork]

And importing a file with a SPIM acquisition mode works as expected with the acquisition mode properly populated:

screen shot 2016-09-13 at 11 42 04

The logic looks sensible and certainly reduces the need for DB ugprade scripts making minor schema releases with enumeration additions potentially achievable in patch releases without too much impact. Having looked quickly at the code, I did not spot anything that raised a red flag to me although it might be good to know if there is some departure with the original intent of DBEnumCheck /cc @joshmoore

NB: the Blitz.log also shows the addition a couple of new companion formats as part of the DB check and I am not sure whether these are still useful. This can be addressed as a follow-up effort.

For the next steps, I would suggest we move this PR (and the companion #4820) out of the breaking queue. Is it required that the corresponding Bio-Formats PR should be migrated as well or is there a test case for having the mappings added only at the OMERO level (in which case I would expect no enumeration addition to the DB and normal startup)?

@mtbc
Copy link
Member Author

mtbc commented Sep 13, 2016

The companion formats are added on the basis of the reader's hasCompanionFiles() returning true.

Happy to move OMERO PRs out of breaking; of course this will add the new values to the normal DB. I can't see why not to take the Bio-Formats one out too but am happy to wait. The bigger question with that one is the strategy of the version number increment cf. recent weeks' namespace discussion on https://trello.com/c/0zNp8HvU/167-enumerations-addition.

@@ -513,7 +513,7 @@ implements java.io.Serializable, IObject
*
* will fail. Experimenter has no owner, for obvious reasons.
*
* Note: subclasses of this class will return a subclasse of
* Note: subclasses of this class will return a subclass of
Copy link
Member

Choose a reason for hiding this comment

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

could you get the typo fix out this PR?
since it is not related to this work

Copy link
Member Author

@mtbc mtbc Sep 16, 2016

Choose a reason for hiding this comment

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

sure, force-pushed away and put into #4847

Copy link
Member

Choose a reason for hiding this comment

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

thanks

@joshmoore
Copy link
Member

2 high-ish level thoughts:

  • In general, SqlAction is a valid extension point (even if in practice I don't think many are doing it), so removing method will be a breaking change.
  • What's the rationale for permitting the new companion types? i.e. for removing the omission list?

@mtbc
Copy link
Member Author

mtbc commented Sep 19, 2016

  1. Yes, I figured the chances of someone external using SqlAction to add formats to be pretty low. Could deprecate instead if preferred.
  2. The omission list has only "Fake" on it, unless we expect the list to grow much beyond one element than I figured it was nice to simplify the code.

@joshmoore
Copy link
Member

Yes, I figured the chances of someone external using SqlAction to add formats to be pretty low. Could deprecate instead if preferred.

I'm less worried about someone consuming the method than someone who has implemented SqlAction and now their @Override annotation will fail compilation.

The omission list has only "Fake" on it, unless we expect the list to grow much beyond one element than I figured it was nice to simplify the code.

Is that the only diff you were seeing, @sbesson ?

@mtbc
Copy link
Member Author

mtbc commented Sep 19, 2016

Ah, okay, can certainly add method back in then but deprecate.

@jburel jburel added the develop label Sep 20, 2016
@joshmoore
Copy link
Member

Thanks for the changes. The added values are:

OMERO.server-5.3.0-m4-253-43428df-ice35-b434 jamoore$ grep EnsureEnum var/log/Blitz-0.log | grep adding
2016-09-20 21:51:12,260 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/FilePattern
2016-09-20 21:51:12,398 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/SPC
2016-09-20 21:51:12,562 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/CellWorx
2016-09-20 21:51:12,615 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/Volocity
2016-09-20 21:51:12,654 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/AFI
2016-09-20 21:51:12,724 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/JEOL
2016-09-20 21:51:12,781 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/BD
2016-09-20 21:51:12,788 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/Unisoku
2016-09-20 21:51:12,796 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/PDS
2016-09-20 21:51:12,803 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/Fuji
2016-09-20 21:51:12,833 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/Inveon
2016-09-20 21:51:12,844 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/CellVoyager
2016-09-20 21:51:13,037 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/PCORAW
2016-09-20 21:51:13,130 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/Trestle
2016-09-20 21:51:13,151 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/ZeissTIFF
2016-09-20 21:51:13,282 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/Hitachi
2016-09-20 21:51:13,291 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value Format.Companion/Bruker
2016-09-20 21:51:13,571 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value AcquisitionMode.BrightField
2016-09-20 21:51:13,582 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value AcquisitionMode.SweptFieldConfocal
2016-09-20 21:51:13,587 INFO  [            ome.services.util.EnsureEnum] (      main) adding to database new enumeration value AcquisitionMode.SPIM

which makes sense. 👍

@sbesson
Copy link
Member

sbesson commented Sep 22, 2016

@mtbc I assume this can be merged independently of #4820 which should be coordinated with the 5.2.3 version bump?

@mtbc
Copy link
Member Author

mtbc commented Sep 22, 2016

Yes, it can.

@sbesson sbesson merged commit 6888b58 into ome:develop Sep 22, 2016
@mtbc mtbc deleted the enum-autopopulate branch September 22, 2016 09:24
String name = formatReader.getClass().getSimpleName();
if (name.endsWith("Reader")) {
name = name.substring(0, name.length() - 6);
if ("Fake".equals(name)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Should "FilePattern"(Reader) also be excluded?

@jburel jburel added this to the 5.3.0 milestone Mar 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants