Skip to content

Some bugfixes#15

Merged
sbesson merged 6 commits intoome:masterfrom
dominikl:some_bugfixes
Jan 23, 2019
Merged

Some bugfixes#15
sbesson merged 6 commits intoome:masterfrom
dominikl:some_bugfixes

Conversation

@dominikl
Copy link
Member

@dominikl dominikl commented Nov 16, 2018

This PR fixes some bugs I noticed while trying to export ('render info') and apply ('render set') the rendering settings of idr0044:

  • The channel index was off by 1 (when setting the name and activate/deactivate)
  • 'info' command output used 0-based index, whereas the 'set' command expects 1-based index for the channels
  • start and end values specified in the yaml were ignored (when setting the rendering settings)
  • Instead of start/end the min/max values specified in the yaml were set as window start/end.
  • If a channel is not specified in the yaml it is deactivated by the the set_active_channels method. I added a workround earlier, which is not buggy (afaik) but I changed it a bit, so its clearer and safer.

Test: With this PR it should now be possible to adjust the rendering settings of an image in OMERO.web. Then export them with ./omero render info --style yaml Image:ID > renderingsettings.yml And then reapply them with ./omero render set Image:ID renderingsettings.yml. The renderings settings should then be the same.

This PR adds support for a 'version' field in the yml/json. If rendering settings specify start/end and min/max you have to add the version, otherwise it's not clear which values to use for the channel window start/end. Earlier versions used min/max, but with this version (version 2) start/end will be used.

@jburel
Copy link
Member

jburel commented Nov 16, 2018

./src/omero_cli_render.py:534:68: W291 trailing whitespace

@sbesson
Copy link
Member

sbesson commented Nov 19, 2018

With the last commit, the test_set_single_channel integration tests are now all failing probably due to the channel indexing changes introduced in this PR

Unrelated to this, the tests are quite slow to run which does not help troubleshooting. I might try to have a go at profiling where most of the time is spent to see if we can speed up things.

rangelist = []
colourlist = []
for (i, c) in newchannels.iteritems():
i += 1
Copy link
Member

@sbesson sbesson Jan 16, 2019

Choose a reason for hiding this comment

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

I am still unclear why this offset is necessary. Looking at IDR/idr0047-neuert-yeastmrna#11 (comment), could the confusion come from the assumption that the channels loaded from the YAML/JASON files are 0-indexed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, so that's why the export via 'info' command import via 'set' didn't work. Ok, maybe it's better in that case to not increase by one, but fix the output of the 'info' command.

@dominikl
Copy link
Member Author

Removed the +1 offset again. Also integration test needed some adjustment.

General remark: With this PR start and end need to specified for the set command, min and max are ignored (as this is the min/max pixel value, which cannot be set anyway). Have to check for potential consequences for older rendering settings definitions.

else:
cindices.append(i)
rangelist.append([c.min, c.max])
rangelist.append([c.start, c.end])
Copy link
Member Author

Choose a reason for hiding this comment

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

Addtionally checking here for c.min and c.max here, could make the changes of this PR backward compatible. The question then is, what should be done if min/max and start/end are specified:

  • min/max overrides start/end
  • start/end take precedence
  • throw an error

Copy link
Member

Choose a reason for hiding this comment

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

I think we will have to handle previous versions of the YML files especially since we extensively used this format in IDR.

My understanding is that below are the proposed behaviors for the two format versions:

  • version 1 (current): channel min/max sets the channel window start/end, channel start/end ignored (or maybe simply not part of the render YML/JSON specification?)
  • version 2 (current): channelstart/end sets the channel window start/end, min/max is now either a no-op or not present for the YML/JSON specification

One way we might consider to make this unambiguous would be to start introduce a version: 2 field in the YAML/JSON specification. The question now remains: what would happen when such version field is absent? Options are:

  • always default to version: 1. This means that a YML file with start/end without version: 2 would probably not behave as expeced.
  • as suggested above, detect and error if start/end and min/max are both found in the format. A potential implication is that a YML file with only start/end and no version should be auto-detected as version 2 while a YML file with only min/max and no version would be autodetected as version 1.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd vote for the last option. Add a version field. If it's not specified start/end implies version 2, min/max implies version 1, if both specified error.

@sbesson sbesson added this to the 0.4.0 milestone Jan 17, 2019
@dominikl
Copy link
Member Author

dominikl commented Jan 17, 2019

Shall I go ahead with option "Add a version field. If it's not specified start/end implies version 2, min/max implies version 1, if both specified error." ?
That would make the script backward compatible with older rendering setting definitions we have in idr. Just noticed for some of the recent idr project I used renderings settings with 0 channel indexing, will have to change these.
If we go ahead with that, I'd also change the 'info' command to add 'version: 2' to the output and also use 1 indexing for channels, so that the round trip render info --style yaml Image:123 > xyz.yml render set Image:123 xyz.yml works.

The 'version' field enables backwards compatibility;
1-indexed output makes a it possible to export via
info command and import via set command.
@dominikl
Copy link
Member Author

That is weird... if I move the failed test (which can't have anything to do with the PR actually) to the beginning, it passes.

@joshmoore
Copy link
Member

It's probably not critical yet, but moving forward if we want to do this more often, I'd imagine separating out the logic for each version into a helper will help us from breaking older versions (even at the cost of slightly higher duplication) cF hdfstorageV1 vs hdfstorageV2

Copy link
Member

@sbesson sbesson left a comment

Choose a reason for hiding this comment

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

A few inline comments. Happy to discuss them over voice. Otherwise, 👍 for integrating these changes as the tests are green.

Thinkinof the next steps before omero-cli-render 0.4.0 is released, we will need:

  • a freeze of the specification for version 2 of the rendering format
  • a review of the CLI command helps and the info/set round-tripping
  • possibly a review of the test coverage

"""

# Current version for specifying rendering settings
currentSpecVersion = 2
Copy link
Member

Choose a reason for hiding this comment

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

maybe capitalize this e.g. SPEC_VERSION


# Previously min/max was used to set the channel window start/end
# From version 2 on start/end will be used.
if 'version' not in data:
Copy link
Member

Choose a reason for hiding this comment

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

Up for discussion, the alternative to handling the versioning in the command would be to move this logic up to ChannelObject.init_from_dict() i.e. serialize to a unified ChannelObject representation independently of the input version.

This might lead us to considerations along the lines of #15 (comment) i.e. start have versioned loaders.

Copy link
Member

Choose a reason for hiding this comment

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

I can write json-schema if it's helpful ;)

@sbesson
Copy link
Member

sbesson commented Jan 23, 2019

Briefly discussed with @dominikl and @joshmoore. Merging this and tagging as 0.4.0a1 so that we can start consuming v2 and gaining experience on it. There are a few items reported above which should be reviewed before we tag 0.4.0 but this can be addressed as separate more specific PRs.

@sbesson sbesson merged commit 5595ded into ome:master Jan 23, 2019
@sbesson
Copy link
Member

sbesson commented Jan 23, 2019

Pre-release now available as https://pypi.org/project/omero-cli-render/0.4.0a1/

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.

4 participants