Skip to content

Api wells#5047

Merged
jburel merged 34 commits intoome:developfrom
will-moore:api_wells
Feb 13, 2017
Merged

Api wells#5047
jburel merged 34 commits intoome:developfrom
will-moore:api_wells

Conversation

@will-moore
Copy link
Copy Markdown
Member

@will-moore will-moore commented Jan 18, 2017

What this PR does

Adds support for Wells to web api.
NB: Needs ome/omero-marshal#31. requirements.txt points to that branch of omero-marshal to allow testing of this PR. Once that is merged, we can revert requirements.txt.

Testing this PR

  1. Added tests in test_api_wells.py
  2. Browse to /plates/
    • List of /plates/ - each Plate will have link to 'url:wells': 'plates/:id/wells'
    • Single plate /plates/:id also links to 'wells'
    • Browse to plates/:id/wells (or /wells/?plate=:id ) to filter wells by Plate
    • /wells/ will be ordered by Column & Row and include WellSamples, PlateAcquisitions & Images.
    • plate/:id/wells/ will also include any Wells that have no WellSamples & Images
    • Each Well in /wells/ will link to a single /wells/:id/
    • /wells/:id shows single Well with WellSamples, Images and Pixels loaded.
    • Images listed at /wells/ and /wells/:id/ will have link to 'url:image': 'images/:id/'

Related reading

As discussed at ome/design#65 Wells are the next object we need to support. This now allows browsing Screen -> Plate -> Well -> Image starting at /api/.

Also tests ome/omero-marshal#31.

cc @chris-allan @jburel @aleksandra-tarkowska

To consider for follow-up:

  • Filter wells in plate by PlateAcquisition (only load images from single plateAcquisition)
  • Don't marshal separate PlateAcquisition for every WellSample. Normalize!
  • /plate/:id/ needs min/max wsIndex

@will-moore
Copy link
Copy Markdown
Member Author

Discussed in api meeting today:

  • Listing wells, load ws, image, plateAcquisition (NB: need plateAquisition support in omero-marshal)
  • Showing single Well, also load pixels.
  • When listing Wells, DO return wells with no images.

@will-moore
Copy link
Copy Markdown
Member Author

Tests failing because of requirement for Wells support in omero-marshal: https://ci.openmicroscopy.org/view/Failing/job/OMERO-DEV-merge-integration-Python27/437/testReport/

" left outer join fetch wellSamples.plateAcquisition"\
" as plateAcquisition"
if load_pixels or load_channels:
query += ' left outer join fetch image.pixels pixels' \
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 will add as pixels to match the rest of the query, easier to read

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.

The section to load pixels and channels is also in def _getQueryString(cls, opts=None): ( line 7159)
I think we should have helper method to generate part of the query instead of having the same code in various locations of the files
If we make a change to the query, we will certainly forget to update one query

from omero_marshal import get_encoder
from omero.model import DatasetI, ProjectI, ScreenI, PlateI, ImageI
from omero.rtypes import rstring, unwrap
from omero.model import DatasetI, ProjectI, ScreenI, PlateI, ImageI, \
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.

one per line and in alphabetical order

import pytest
from omero.gateway import BlitzGateway
from omero_marshal import get_encoder
from omero.model import PlateI, WellI, WellSampleI, ImageI, LengthI
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 and one per line

screen = get_update_service(user1).saveAndReturnObject(screen)
plate = get_update_service(user1).saveAndReturnObject(plate)

# Add well to first plate
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 will add a plate acquisition to the test data since it is what will happen by default with a plate import

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've added PlateAcquisition testing to test_api_wells.py but not duplicated this in test_api_containers.py because this test is really concerned with testing urls: Screen -> Plate -> Wells and we don't need to cover PlateAcquisitions twice. Also, it's nice to test that we can load Wells with NO Plate Acquisitions which we're not testing anywhere else now.

Copy link
Copy Markdown
Member

@jburel jburel Jan 25, 2017

Choose a reason for hiding this comment

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

I will check both cases to be on the safe side
i.e. with plate acquisitions and without

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 will update test_api_wells.py to test with & without PlateAcquisitions, but it doesn't make sense for every test to test everything. Otherwise we will never stop writing tests and all the tests will be so large that you can't understand them.

return connection


def cmp_name_insensitive(x, y):
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 time to have helper methods since this one for example is now in all the test files

@pytest.fixture()
def user1(self):
"""Return a new user in a read-annotate group."""
group = self.new_group(perms='rwra--')
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.

testing other permissions will be useful

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'm not sure what you're wanting here. Testing that queries still work in a read-only or private group? Tests in test_api_projects.py do various permissions & cross-group queries so I don't think we need to replicate this in other tests that are focussed on different objects?

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.

as far as I can tell only read-annotate and read-only are covered in test_api_projects.py
Also with the introduction of new roles, test with various levels of permissions need to be added (admin, owner etc).
This can be done in a follow up PR to solidify what is currently in place

We have seen previously problems when loading different objects i.e. what was true for projects
was not for, for example, image.

well.column = rint(col)
well.row = rint(row)
well.plate = PlateI(plate.id.val, False)
# Only wells in first Column have well-samples etc
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.

etc.


@pytest.fixture()
def small_plate(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.

same here: I will add plate acquisition to match reality

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.

Done in 84ad329

@jburel
Copy link
Copy Markdown
Member

jburel commented Jan 26, 2017

./components/tools/OmeroPy/src/omero/gateway/__init__.py:149:1: E302 expected 2 blank lines, found 1

@will-moore
Copy link
Copy Markdown
Member Author

@jburel - I don't understand that travis failure. I have the same version of flake8 locally but don't see any failure. Also the line 149 is 2 blank lines!

@will-moore
Copy link
Copy Markdown
Member Author

$ flake8 components/tools/OmeroPy/src/omero/gateway/__init__.py
$ pip freeze | grep flake8
flake8==2.4.0

@will-moore
Copy link
Copy Markdown
Member Author

That flake8 failure was fixed by the last commit: 78a5a94. Will try to re-run...

@will-moore will-moore closed this Jan 26, 2017
@will-moore will-moore reopened this Jan 26, 2017
@jburel
Copy link
Copy Markdown
Member

jburel commented Jan 26, 2017

The changes look good, waiting on travis now

@will-moore
Copy link
Copy Markdown
Member Author

@jburel Travis is good, but we really need the omero-marshal PR in since without it we still have failing tests etc.

@jburel
Copy link
Copy Markdown
Member

jburel commented Jan 26, 2017

of course we need to have the tests passing before we merge anything

@atarkowska
Copy link
Copy Markdown
Member

atarkowska commented Jan 26, 2017

why not to add omero-marshal merge build to CI and then pip install from snoopy? Exactly as we handle other web plugins

@snoopycrimecop
Copy link
Copy Markdown
Member

Conflicting PR. Removed from build OMERO-DEV-merge-push#576. See the console output for more details.
Possible conflicts:

@dominikl dominikl mentioned this pull request Jan 27, 2017
@will-moore
Copy link
Copy Markdown
Member Author

With requirements.txt now pointing at ome/omero-marshal#31 browsing of SPW is working on merge build, E.g. (user-3)
http://web-dev-merge.openmicroscopy.org/api/v0/m/plates/2077/wells/
and tests are passing at https://ci.openmicroscopy.org/view/Failing/job/OMERO-DEV-merge-integration-Python27/441/testReport/OmeroWeb.test.integration.test_api_wells/

return super(ApiView, self).dispatch(*args, **kwargs)

def add_data(self, marshalled, request, **kwargs):
def add_data(self, marshalled, request, urls={}, **kwargs):
Copy link
Copy Markdown
Member

@chris-allan chris-allan Jan 30, 2017

Choose a reason for hiding this comment

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

Watch out for argument constructs like this. urls={} does not create a new dictionary on every method invocation so if you modify it, add new keys, etc. they are going to get picked up and used in subsequent invocations. If you want to be on the safe side, set the default to None and create the dictionary in the method on None.

/cc @jburel

@will-moore will-moore closed this Jan 31, 2017
@will-moore will-moore reopened this Jan 31, 2017
This was referenced Feb 2, 2017
@dominikl
Copy link
Copy Markdown
Member

Is this PR going to be merged? Then I could rebase my annotation count PR #5023 (merge conflicts with this PR).

@chris-allan
Copy link
Copy Markdown
Member

Now that we have ome/omero-marshal#31 merged I think what we need to do here is revert the change to requirements-common (we can't really have hacks like in), ensure all the tests pass, and then go ahead and merge.

# Urls to add to marshalled object. See ProjectsView for more details
urls = {
'url:wells': {'name': 'api_plate_wells',
'kwargs': {'plate_id': 'OBJECT_ID'}}
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.

if that is placeholder why OBJECT_ID not just None ?

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.

OBJECT_ID is a unique identifier that this should be replaced with the ID of the current object. It's possible that other IDs could be used in future. Using None doesn't explicitly say what the placeholder should be replaced with.

@jburel
Copy link
Copy Markdown
Member

jburel commented Feb 13, 2017

tmp change has been reverted.
it is now pointing to the master branch

https://ci.openmicroscopy.org/view/Failing/job/OMERO-DEV-merge-integration-Python27/451/testReport/OmeroWeb.test.integration.test_api_wells/ is green
merging

@jburel jburel merged commit f9255a2 into ome:develop Feb 13, 2017
@jburel jburel added this to the 5.3.0 milestone Mar 29, 2017
@will-moore will-moore deleted the api_wells branch February 18, 2019 04:15
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.

7 participants