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

DB 5.1__DEV11: unit support for time #3099

Merged
merged 25 commits into from Oct 28, 2014
Merged

DB 5.1__DEV11: unit support for time #3099

merged 25 commits into from Oct 28, 2014

Conversation

joshmoore
Copy link
Member

This commit introduces the ome.model.unit.Time class
which contains a double value and a string unit for
representing time durations. The only location which
makes use of this is PlaneInfo.exposureTime. "ms" is
hard-coded until the xsd-fu unit support is in place.


/cc @bpindelski @mtbc @qidane @rleigh-dundee

This commit introduces the ome.model.unit.Time class
which contains a double value and a string unit for
representing time durations. The only location which
makes use of this is PlaneInfo.exposureTime. "ms" is
hard-coded until the xsd-fu unit support is in place.
@mtbc
Copy link
Member

mtbc commented Oct 8, 2014

Travis isn't green.

@@ -1669,6 +1669,7 @@
id int8 not null,
deltaT float8,
permissions int8 not null,
exposureTimeUnit varchar(255),
Copy link

Choose a reason for hiding this comment

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

255 seems a bit wasteful; can't we use a much smaller size here given that most unit symbols and/or names will be very small?

Copy link

Choose a reason for hiding this comment

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

Another possibility on the db side would be to have a foreign key reference to a time units table to make it restricted to the model enum values.

Copy link
Member Author

Choose a reason for hiding this comment

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

Possibly, but that's something we should do across the board in another PR, since we don't have any support for that at the moment. More interesting to me would be whether or not this should actually be an enum.

Copy link

Choose a reason for hiding this comment

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

For any code to be able to robustly cope with units, I consider an enum as a necessity. This does constrain which units are possible to use of course, but the set Andrew has created covers all the SI system and then some, so I think the number of cases where this won't be sufficient is approaching zero.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed, this was mostly just to have an example of touching all the necessary pieces. Just chatted through the current ome.xml classes that are needed:

class PlaneInfo {
    Time exposureTime;
}

class Time {
   double value;
   UnitsTime unit;
}

class UnitsTime {
    String symbol;
    String measurementSystem.
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Note: what I'd really like would be to have:

enum UnitsTime {

}

but we don't currently have support for that in Hibernate and the DB. It might be worth it though.

@joshmoore
Copy link
Member Author

Grrr.....

components/blitz/generated/omero/model/UnitsTime.ice:36: constant `UnitsTimeps' differs only in capitalization from constant `UnitsTimePs'

Also adds the TimeI implementation for the Python and C++
language bindings, including object factories and IceMapper code.
The Java implementation is also an implementor of `ModelBased` so
that IceMapper can convert back and forth to ome.model.units
instances.

For the next unit implementation (i.e. `Length`), it will likely
be better to introduce code generation of the `ome.model.units`
implementations rather than hand-writing them.

Note: a workaround was needed for the generation of unique
constant names in Ice since constants must vary in more than just
capitalization which fails for SI prefixes like M and m.
@joshmoore
Copy link
Member Author

--depends-on ome/bioformats#1379

@joshmoore
Copy link
Member Author

Added dependency on the units work from @qidane, removed exclude and pushed the rest of the DB changes.

@joshmoore joshmoore force-pushed the dsl-units branch 2 times, most recently from 4d99186 to 48697b2 Compare October 14, 2014 11:17
This commit adds an implicit dependency on the updated schema.
Since there planeInfo.deltaT and pixels.timeIncrement have been
modified to type Time, that takes place here as well.

Note: this runs into an issue with hibernate (HHH-4329) in which
the nice foreign key naming for embedded objects has to be
removed. I'll attempt fixing that elsewhere.

--depends-on ome/bioformats#1265
The few unit types are now corrected by hand since there
is currently no way to code generate them. The map types
were also missing properly named FKs, but these could be
handled by the introduction of a new annotation.

Note: a check has now been added to travis-build which
should prevent generated FK constraint names from being
included in a schema.
@joshmoore joshmoore changed the title DB 5.1__DEV11: unit support for PlaneInfo.exposureTime DB 5.1__DEV11: unit support for time Oct 14, 2014
Java's FileReader and FileWriter use the default local
encoding which led to some .ice files being created with
latin1 encoding. Ice then understandably couldn't handle
the micro symbol failing the build.

See:
http://stackoverflow.com/questions/6998905/java-bufferedwriter-object-with-utf-8
Ant's `<copy>` task uses the default encoding as well,
meaning that the splitting of the combined file which
DSLTask created with UTF-8 converted back to LATIN1
when the locale was C or similar. Further, charAt was
not sufficient for detecting the micro symbol under C
and so codePointAt is now used.
@joshmoore
Copy link
Member Author

Restarted travis due to HDF5 weirdness.

For everyone's benefit, decision was to disable the tests for the moment (https://trac.openmicroscopy.org.uk/ome/ticket/12601) and look into this as a fix post m2.

@melissalinkert
Copy link
Member

This and ome/bioformats#1379 are no longer in the breaking queue.

@bpindelski
Copy link

This broke web on trout with

InternalException at /webclient/load_data/dataset/7751/
exception ::omero::InternalException
{
    serverStackTrace = ome.conditions.InternalException:  Wrapped Exception: (org.springframework.orm.hibernate3.HibernateSystemException):
Null value was assigned to a property of primitive type setter of ome.model.units.Time.value; nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of ome.model.units.Time.value
    at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:679)

@jburel
Copy link
Member

jburel commented Oct 21, 2014

deleted my comment. I was using an out-of-date client

@jburel
Copy link
Member

jburel commented Oct 21, 2014

I did not notice the web error when starting the tests with an empty DB
I have:

  • Imported images
  • Browse dataset
  • Open the image in Viewer
  • Check Exposure time (see error below)

@jburel
Copy link
Member

jburel commented Oct 21, 2014

breakingexposuretime

cc @will-moore

@mtbc
Copy link
Member

mtbc commented Oct 21, 2014

If you can see what the upgrade script is failing to do, I am happy to try to patch it.

@jburel
Copy link
Member

jburel commented Oct 22, 2014

The issue is with the update script: so far tested upgrade from patch 10 to patch 11
The following error occurs when loading a dataset containing images imported prior to patch


Caused by: omero.InternalException
    serverStackTrace = "ome.conditions.InternalException:  Wrapped Exception: (org.springframework.orm.hibernate3.HibernateSystemException):
                        Null value was assigned to a property of primitive type setter of ome.model.units.Time.value; nested exception is org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of ome.model.units.Time.value
                            at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:679)
                            at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)

No issue for images imported after applying the patch
This raises another issue: due to the way we use breaking (i.e. clean DB)
The upgrade scripts are never tested.

@jburel
Copy link
Member

jburel commented Oct 22, 2014

Pixels table:

  • images imported prior to the patch, have now a timeincrementunit value set to 11 (default second) even if the timeincrement value is null
    but the newly imported images (after patch) have null for both

PlaneInfo:

  • deltat: all values are transformed to 11 i.e. id of seconds in unitstime.
  • deltatunit is alway null
    • exposuretime is correctly preserved and exposuretimeunit correctly set to 11 (always) That might correct but will have to check later on with other images.

Error in the script for planeInfo

@jburel jburel mentioned this pull request Oct 22, 2014
@jburel
Copy link
Member

jburel commented Oct 22, 2014

Closing this PR so it can move out of the breaking queue.
Replaced by gh-3129

@jburel jburel closed this Oct 22, 2014
@joshmoore
Copy link
Member Author

Re-opening after closing gh-3129 so I can push a few more commits.

@joshmoore joshmoore reopened this Oct 27, 2014
@joshmoore
Copy link
Member Author

Note: @jburel's commits were tested by @mtbc in #3129

@sbesson
Copy link
Member

sbesson commented Oct 28, 2014

Thanks all. Merging.

sbesson added a commit that referenced this pull request Oct 28, 2014
DB 5.1__DEV11: unit support for time
@sbesson sbesson merged commit a746e72 into ome:develop Oct 28, 2014
@joshmoore
Copy link
Member Author

--no-rebase

@joshmoore joshmoore deleted the dsl-units branch October 29, 2014 08:56
@sbesson sbesson added this to the 5.1.0-m2 milestone Nov 26, 2014
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

6 participants