Skip to content

Test api project dataset update#4930

Merged
jburel merged 12 commits intoome:developfrom
will-moore:test_api_project_dataset_update
Mar 14, 2017
Merged

Test api project dataset update#4930
jburel merged 12 commits intoome:developfrom
will-moore:test_api_project_dataset_update

Conversation

@will-moore
Copy link
Copy Markdown
Member

@will-moore will-moore commented Nov 8, 2016

Tests saving of Project with linked Dataset.

Following discussion at ome/omero-marshal#26 (review)
These tests highlight the discussed bug: If we load a Project without child Datasets, then update
the Project and save, all Datasets will get unlinked.
To fix this, we need to call p.unloadDatasetLinks().

Similar tests and logic added for updating of Datasets and Screens.
This now covers all objects that we allow to Save via the json api.

cc @chris-allan @emilroz @joshmoore

@joshmoore
Copy link
Copy Markdown
Member

Mostly an informational comment here since I missed the original discussion: with Ice, there's no difference between None and [] so there is an explicit boolean to say that a particular field is unloaded:

      def unloadDatasetLinks(self, current = None):
          self._datasetLinksLoaded = False
          self._datasetLinksSeq = None;

I don't know if it's possible, but if there's a way to represent the difference between "empty set" and "missing set" then it would be possible to track the callers' intent.

@will-moore will-moore closed this Nov 9, 2016
@will-moore will-moore reopened this Nov 9, 2016
@jburel jburel added the develop label Nov 9, 2016
@will-moore will-moore force-pushed the test_api_project_dataset_update branch from 002d80a to 47ca063 Compare November 10, 2016 15:10
@will-moore
Copy link
Copy Markdown
Member Author

It may be that we decide that the web api never breaks links between objects when simply updating those objects. In webclient currently we use /webclient/api/links/ to DELETE or create links between some objects.

@will-moore
Copy link
Copy Markdown
Member Author

Adding an equivalent test for Project Annotation links (instead of Project-Dataset links). This seems to pass without needing to unloadAnnotationLinks() since they are already unloaded, unlike Project-Dataset links.

@will-moore will-moore closed this Nov 16, 2016
@will-moore will-moore reopened this Nov 16, 2016
@will-moore
Copy link
Copy Markdown
Member Author

@chris-allan Thoughts on this PR and how to address this issue for web api?
I think unloading the Datasets for a Project when saving is safest, to avoid breaking links.
Then we can provide other ways of creating/breaking links OR a flag to differentiate loaded from unloaded links in future PRs?

@chris-allan
Copy link
Copy Markdown
Member

I haven't really had time to devote to a holistic approach to dealing with unloaded OMERO model objects and am unlikely to for at least another week to ten days. Certainly unloading a collection is a solution to this particular problem, is safe and avoids breaking links. However, unloaded objects are also a problem with "member" objects such as enumerations. The Image-Pixels-Channel hierarchy is littered with examples of this. So, we're going to have to come up with an implementation wide solution to the round-trip problem.

@will-moore
Copy link
Copy Markdown
Member Author

It looks like we're not going to be able to support round-tripping for all the objects that we can read, at least for 5.3.0. I think this is OK as the majority of use-cases initially will be read-only.
Marking some objects (E.g. Images) as "Can't Save" will at least allow us to add support for reading them without exposing round-tripping bugs.

@will-moore
Copy link
Copy Markdown
Member Author

As discussed in meeting http://will-moore.github.io/presentations/2017/Web-Api-Update-Jan-2017/, omero-marshal will need to be smarter to handle decoding of unloaded data so that info is not lost on save.
So the 'fix' from this PR will not be needed but the tests will. This PR can be re-opened when needed.

@will-moore will-moore closed this Jan 10, 2017
@will-moore will-moore reopened this Feb 28, 2017
@will-moore will-moore closed this Mar 1, 2017
@will-moore will-moore reopened this Mar 1, 2017
@will-moore will-moore closed this Mar 2, 2017
@will-moore will-moore reopened this Mar 2, 2017
@will-moore will-moore closed this Mar 5, 2017
@will-moore will-moore reopened this Mar 5, 2017
screen_json['Name'] = 'renamed Screen'
_csrf_put_json(django_client, save_url, screen_json)

# Check screen has been updated and still has child Datasets
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo child Plates

import pytest
from omero.gateway import BlitzGateway
from omero.model import ProjectI, DatasetI
from omero.model import ProjectI, DatasetI, TagAnnotationI
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

alphabetical order

assert len(list(proj.listChildren())) == dataset_count

# Get Dataset, update and save back
dataset_url = reverse('api_dataset',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I split this test into 2
Projects/Datasets
Datasets/Images

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll use parametrize to split this into separate tests.

assert dataset.getName() == 'renamed Dataset'
assert len(list(dataset.listChildren())) == image_count

def test_project_tags_update(self, user1):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should be tested for other types too

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I assumed that Datasets and Screens behave the same way as Projects when being linked to Tags etc. But if we need to test them all, I can parametrize that test.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Better to parametrize, we had surprises before

@will-moore will-moore closed this Mar 6, 2017
@will-moore will-moore reopened this Mar 6, 2017
# Therefore we ignore any details for now:
obj.unloadDetails()

# Unlink children for Projects, Datasets and Screens to avoid
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably need a TODO so we can easily find it
and we need a card to review the graph round tripping since we will face it next round with image and roi saving for example

@will-moore
Copy link
Copy Markdown
Member Author

@jburel jburel merged commit 9f4eda3 into ome:develop Mar 14, 2017
@jburel jburel added this to the 5.3.0 milestone Mar 29, 2017
@will-moore will-moore deleted the test_api_project_dataset_update branch February 18, 2019 04:16
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.

4 participants