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

Extenstions to populate metadata 52 #4426

Merged
merged 97 commits into from Feb 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
6565de9
Revert "flake8: omero/util - populate_metadata"
joshmoore Jun 16, 2015
3e2980f
Better error handling when Plate column lookups fail
chris-allan Feb 6, 2015
6422333
Graceful skipping of unresolvable rows from source CSV
chris-allan Feb 6, 2015
29b9ddd
Expand populate_metadata to handle Images
emilroz Mar 26, 2015
e1349c3
Get plate id from the correct container
emilroz Mar 26, 2015
ff95b4d
Get plate id from the correct container part 2
emilroz Mar 26, 2015
13a8026
Adhere to variable naming convention
emilroz Mar 26, 2015
0c50a52
Add column sanity check
emilroz Mar 27, 2015
199b7eb
Fix image_name_column.size
emilroz Apr 17, 2015
a9abc40
Re-apply flake8
joshmoore Jun 16, 2015
00d89c6
populate_metadata: less strict about PlateColumns
joshmoore Jun 22, 2015
e7d336d
populate_metadata: don't close re-used sessions
joshmoore Jun 22, 2015
7b1728f
populate_metadata saves Column description as json
will-moore Jun 19, 2015
a16abef
populate_metadata name.strip() after parsing description
will-moore Jun 19, 2015
2614426
Don't replace '/' in Column headers
will-moore Jun 19, 2015
c78d98e
populate_metadata replaces '/' in Column names after parsing out desc…
will-moore Jun 19, 2015
2a3f5cb
Initial metadata.py plugin
joshmoore Jun 10, 2015
783c68c
test_metadata.py: first 'original' test
joshmoore Jun 10, 2015
50b5a73
New test at tablestest/test_populate_metadata.py
will-moore Jun 10, 2015
9a6f5cd
Rename test_populate_metadata.py for adding rois
joshmoore Jul 3, 2015
3018009
library.py: add importPlates method
joshmoore Jul 3, 2015
ebf3d04
test_populate.py Add ROI test
joshmoore Jul 6, 2015
328fb72
BinaryAccessPolicy: workaround for .txt
joshmoore Jul 6, 2015
0ebda96
fs.py: add ls command for listing files
joshmoore Jul 6, 2015
4726648
metadata.py: refactor and clean
joshmoore Jul 6, 2015
bfbf794
metadata.py: add populate method
joshmoore Jul 6, 2015
0b34a00
populate_roi.py: add support for OMERO 5 (Fix #12235)
joshmoore Jul 6, 2015
d4ab79b
Fix flake8
joshmoore Jul 6, 2015
81bbe17
metadata.py: error in missing measurements
joshmoore Jul 14, 2015
21bc3d1
library.py: fix importMIF series logic
joshmoore Jul 14, 2015
2d4fa8f
Add wrapper method for handling lists and singles
manics Aug 3, 2015
b54dad7
Output bulk annotations, optionally search parents
manics Aug 3, 2015
10e3af5
Flesh out `summary`, add `allanns` command
manics Aug 3, 2015
fcb96e0
Add method for formatting annotations. Add `mapanns` command
manics Aug 3, 2015
78b1b8b
Formatting improvements. `summary` shows annotation counts
manics Aug 3, 2015
fc59558
Use try-except blocks around each attribute in `summary`
manics Aug 3, 2015
a1b098c
Add BulkToMapAnnotationContext to create MapAnns from Bulk Anns
manics Aug 4, 2015
8f8ca60
Add basic usage information for BulkToMapAnnotationContext
manics Aug 4, 2015
14b414b
Only annotate Images and Well, ignore Screens and Plates
manics Aug 4, 2015
9a99cae
Fix typo in BulkToMapAnnotationContext file arg
manics Aug 5, 2015
7a8c9dc
Add context to delete MapAnnotations in the BulkAnns namespace
manics Aug 5, 2015
afec09d
Fix delete in DeleteMapAnnotationContext
manics Aug 5, 2015
8e77b00
`omero metadata populate` runs populate_metadata.py
manics Aug 5, 2015
c851bb5
Add namespace param to library.ITest annotations
manics Aug 6, 2015
ef1880d
Add tests for CLI Metadata wrapper
manics Aug 6, 2015
836ef55
Use --report for verbose output
manics Aug 10, 2015
872afbe
Split common methods into MetadataTestBase, add roi test
manics Aug 10, 2015
d7cf3bb
Fix library.ITest.new_tag to set Tag.textValue
manics Aug 10, 2015
f181975
Additional metadata annotation tests
manics Aug 10, 2015
e66e201
Make test_metadata tests without --report more general
manics Aug 11, 2015
f1b45c7
Add tests for BulkToMapAnnotationContext and DeleteMapAnnotationContext
manics Aug 11, 2015
145f30c
Always process plate file annotations
manics Aug 11, 2015
f91ea7f
Add populate_roi to CLI, also add roi list/delete commands
manics Aug 11, 2015
3cf5e9e
populate_metadata bulkanns searches for bulk-annosation file
manics Aug 14, 2015
7d1bce2
deleterois now uses the CLI delete command
manics Aug 14, 2015
e7e0a8a
Implement omero metadata measures, inc tests
manics Aug 14, 2015
b11d873
Allow parents to be recursively searched for ROIs
manics Aug 14, 2015
d16f4d7
Improve title of metadata help
manics Aug 17, 2015
29fae82
Add `--dry-run` option to `metadata rois delete`
manics Aug 17, 2015
c78103a
Bulk-annotations UI display utils
manics Aug 18, 2015
ee81da2
Add support for a yaml config file to control Bulk-MapAnnotations
manics Aug 18, 2015
5c11cc2
Ensure columns are included or not according to the default config
manics Aug 18, 2015
204bf34
Code cleanups, removed print statements
manics Aug 19, 2015
e0264bd
Unit tests for metadata_utils
manics Aug 19, 2015
72becb3
Attach populate config.yml file as an annotation on parent
manics Aug 19, 2015
6d20cef
All metadata *anns cmds support --parents and namespace filtering
manics Aug 19, 2015
a677c3e
Remove unnecessary list comprehension
manics Aug 19, 2015
21e659d
Ignore IDs <= 0 when linking bulk map annotations
manics Aug 20, 2015
cf6e7c8
Return the bulk-annotation-file with the highest ID if multiple
manics Sep 16, 2015
aa93cbb
Use python-2.6 compatible set initialisation
manics Sep 16, 2015
4a05666
Catch original metadata and object load exceptions
manics Sep 16, 2015
aa9809e
Use Python generators when loading annotations
manics Sep 16, 2015
68d9a66
Put import yaml in a try-catch block
manics Sep 24, 2015
d83be82
Fix incorrect indentation in for loop yield
manics Oct 2, 2015
4b334dc
Optionally attach source file for annotations
manics Oct 2, 2015
2474749
Not passing a file is only an error if the context needs it
manics Oct 2, 2015
25c6c4d
Move projection helper method into a base class
manics Oct 2, 2015
e21856f
Add advanced.well_to_images option to link well anns to images
manics Oct 2, 2015
3a78539
Read annotations generator earlier to catch NotImplementedError
manics Oct 2, 2015
4ebe07d
populate_metasdata:plates: if csv has plate column subselect rows
manics Oct 5, 2015
4047215
Make debug logging more useful
manics Oct 5, 2015
b6aeee2
Forgot to return the subselected rows
manics Oct 5, 2015
dc69643
Fail fast if empty header found in CSV
manics Oct 5, 2015
31d444a
BulkToMapAnnotationContext.create_map_annotation namespace can be ove…
manics Oct 6, 2015
c5c1bc9
Move definition of NSBULKANNOTATIONSCONFIG* into metadata_utils
manics Oct 14, 2015
d143aa5
Use sperate args for local/remote files. Improve bulkmap/deletemap.
manics Oct 14, 2015
dfe1e58
Create a new test/integration/metadata dir
manics Oct 14, 2015
9e145e7
Fix populate_metadata integration tests
manics Oct 14, 2015
93aff66
Add a test for substituting clientvalue when omitempty
manics Oct 14, 2015
d3a0b36
populate_metadata: simple UI workaround
joshmoore Oct 7, 2015
854680e
When populating with image.id don't use plate.ids in dicts
emilroz Nov 16, 2015
128ff60
Fix test_metadata.py after generator changes
joshmoore Jan 22, 2016
ce5000a
Skip test if PyYAML is not installed
joshmoore Feb 5, 2016
6fe13f7
Comment out constructor failing lines
emilroz Jan 26, 2016
893c067
Typos and minor corrections
joshmoore Feb 10, 2016
387c33e
Fix yaml import in test_populate.py
joshmoore Feb 10, 2016
affa152
Disable metadata.py with OMERO_DEV_PLUGINS
joshmoore Feb 16, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -102,6 +102,13 @@ public boolean isRestricted(IObject obj) {
// Possible performance impact!
if (obj instanceof OriginalFile) {
OriginalFile ofile = (OriginalFile) obj;

// Quick short-cut for necessary files
boolean isTxt = ofile.getName().endsWith(".txt");
if (isTxt) {
return false;
}

Iterator<FilesetEntry> it = ofile.iterateFilesetEntries();
while (it.hasNext()) {
FilesetEntry fe = it.next();
Expand Down
81 changes: 71 additions & 10 deletions components/tests/python/library/__init__.py
Expand Up @@ -301,31 +301,81 @@ def importSingleImageWithCompanion(self, name=None, client=None):
the file and then return the list of images.
"""

def importMIF(self, seriesCount=1, name=None, client=None,
def importMIF(self, seriesCount=0, name=None, client=None,
with_companion=False, skip="all", **kwargs):
if client is None:
client = self.client
if name is None:
name = "importMIF"

try:
globalMetadata = kwargs.pop("GlobalMetadata")
except:
globalMetadata = None
if globalMetadata:
with_companion = True

append = ""

# Only include series count if enabled; in the case of plates,
# this will be unused
if seriesCount >= 1:
append = "series=%d%s" % (seriesCount, append)

if kwargs:
for k, v in kwargs.items():
append += "&%s=%s" % (k, v)

query = client.sf.getQueryService()
fake = create_path(name, "&series=%d%s.fake" % (seriesCount, append))
fake = create_path(name, "&%s.fake" % append)
if with_companion:
open(fake.abspath() + ".ini", "w")
ini = open(fake.abspath() + ".ini", "w")
if globalMetadata:
ini.write("[GlobalMetadata]\n")
for k, v in globalMetadata.items():
ini.write("%s=%s\n" % (k, v))
ini.close()

pixelIds = self.import_image(
filename=fake.abspath(), client=client, skip=skip, **kwargs)
assert seriesCount == len(pixelIds)

if seriesCount >= 1:
assert seriesCount == len(pixelIds)

images = []
for pixIdStr in pixelIds:
pixels = query.get("Pixels", long(pixIdStr))
images.append(pixels.getImage())
return images

def importPlates(
self, client=None,
plates=1, plateAcqs=1,
plateCols=1, plateRows=1,
fields=1, **kwargs
):

if client is None:
client = self.client

kwargs["plates"] = plates
kwargs["plateAcqs"] = plateAcqs
kwargs["plateCols"] = plateCols
kwargs["plateRows"] = plateRows
kwargs["fields"] = fields
images = self.importMIF(client=client, **kwargs)
images = [x.id.val for x in images]

query = client.sf.getQueryService()
plates = query.findAllByQuery((
"select p from Plate p "
"join p.wells as w "
"join w.wellSamples as ws "
"join ws.image as i "
"where i.id in (:ids)"),
omero.sys.ParametersI().addIds(images))
return plates

def createTestImage(self, sizeX=16, sizeY=16, sizeZ=1, sizeC=1, sizeT=1,
session=None):
"""
Expand Down Expand Up @@ -802,12 +852,17 @@ def new_dataset(self, name=None, description=None):
"""
return self.new_object(DatasetI, name=name, description=description)

def new_tag(self, name=None):
def new_tag(self, name=None, ns=None):
"""
Creates a new tag object.
:param name: The tag name. If None, a UUID string will be used
:param ns: The namespace for the annotation. If None, do not set.
"""
return self.new_object(TagAnnotationI, name=name)
tag = self.new_object(TagAnnotationI, name=name)
tag.setTextValue(rstring(name))
if ns is not None:
tag.setNs(rstring(ns))
return tag

def make_image(self, name=None, description=None, date=0, client=None):
"""
Expand Down Expand Up @@ -846,15 +901,16 @@ def make_dataset(self, name=None, description=None, client=None):
dataset = self.new_dataset(name=name, description=description)
return client.sf.getUpdateService().saveAndReturnObject(dataset)

def make_tag(self, name=None, client=None):
def make_tag(self, name=None, client=None, ns=None):
"""
Creates a new tag instance and returns the persisted object.
:param name: The tag name. If None, a UUID string will be used
:param client: The client to use to create the object
:param ns: The namespace for the annotation. If None, do not set.
"""
if client is None:
client = self.client
tag = self.new_tag(name=name)
tag = self.new_tag(name=name, ns=ns)
return client.sf.getUpdateService().saveAndReturnObject(tag)

def createDatasets(self, count, baseName, client=None):
Expand All @@ -877,13 +933,14 @@ def createDatasets(self, count, baseName, client=None):
return update.saveAndReturnArray(dsets)

def make_file_annotation(self, name=None, binary=None, format=None,
client=None):
client=None, ns=None):
"""
Creates a new DatasetI instance and returns the persisted object.
If no name has been provided, a UUID string shall be used.

:param name: the name of the project
:param client: The client to use to create the object
:param ns: The namespace for the annotation
"""

if client is None:
Expand All @@ -895,9 +952,11 @@ def make_file_annotation(self, name=None, binary=None, format=None,
format = "application/octet-stream"
if binary is None:
binary = "12345678910"
if name is None:
name = str(self.uuid())

oFile = OriginalFileI()
oFile.setName(rstring(str(self.uuid())))
oFile.setName(rstring(name))
oFile.setPath(rstring(str(self.uuid())))
oFile.setSize(rlong(len(binary)))
oFile.hasher = ChecksumAlgorithmI()
Expand All @@ -914,6 +973,8 @@ def make_file_annotation(self, name=None, binary=None, format=None,

fa = FileAnnotationI()
fa.setFile(oFile)
if ns is not None:
fa.setNs(rstring(ns))
return update.saveAndReturnObject(fa)

def link(self, obj1, obj2, client=None):
Expand Down
8 changes: 7 additions & 1 deletion components/tools/OmeroPy/src/omero/cli.py
Expand Up @@ -296,7 +296,13 @@ def __init__(self, default=None):
self.default = default

def __call__(self, s):
return omero.proxy_to_instance(s, default=self.default)
try:
return omero.proxy_to_instance(s, default=self.default)
except omero.ClientError, ce:
raise ValueError(str(ce))

def __repr__(self):
return "proxy"


class NewFileType(FileType):
Expand Down
18 changes: 18 additions & 0 deletions components/tools/OmeroPy/src/omero/plugins/fs.py
Expand Up @@ -25,6 +25,7 @@

import sys

from collections import defaultdict
from collections import namedtuple

from omero import client as Client
Expand All @@ -34,6 +35,7 @@
from omero.cli import CmdControl
from omero.cli import CLI
from omero.cli import ProxyStringType
from omero.gateway import BlitzGateway

from omero.rtypes import rstring
from omero.rtypes import unwrap
Expand Down Expand Up @@ -259,6 +261,11 @@ def _configure(self, parser):
"--check", action="store_true",
help="checks each fileset for validity (admins only)")

ls = parser.add(sub, self.ls)
ls.add_argument(
"fileset",
type=ProxyStringType("Fileset"))

usage = parser.add(sub, self.usage)
usage.set_args_unsorted()
usage.add_login_arguments()
Expand Down Expand Up @@ -676,6 +683,17 @@ def sets(self, args):
tb.row(idx, *tuple(obj))
self.ctx.out(str(tb.build()))

def ls(self, args):
"""List all the original files contained in a fileset"""
client = self.ctx.conn(args)
gateway = BlitzGateway(client_obj=client)
gateway.SERVICE_OPTS.setOmeroGroup("-1")
fileset = gateway.getObject("Fileset", args.fileset.id.val)

defaultdict(list)
for ofile in fileset.listFiles():
print ofile.path + ofile.name

@admin_only
def set_repo(self, args):
"""Change configuration properties for single repositories
Expand Down