diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 9473aee..93c81fe 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -7,9 +7,15 @@ jobs: name: Build and publish Python distribution to PyPI runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.9' + - uses: actions/setup-node@v4 + - name: Run flake8 + run: | + python -mpip install flake8 + flake8 . - name: Build a binary wheel and a source tarball run: | python -mpip install wheel diff --git a/README.rst b/README.rst index 10493a8..182d5a4 100644 --- a/README.rst +++ b/README.rst @@ -1,5 +1,13 @@ +.. image:: https://github.com/German-BioImaging/omero-autotag/workflows/PyPI/badge.svg + :target: https://github.com/German-BioImaging/omero-autotag/actions + +.. image:: https://badge.fury.io/py/omero-autotag.svg + :target: https://badge.fury.io/py/omero-autotag + + OMERO.autotag -================ +============= + OMERO.autotag is a plugin for `OMERO.web `_ that automates the application of tags to images based on the original filename, path, and extensions of the images. @@ -12,9 +20,9 @@ As Python 2 has now reached end-of-life, OMERO 5.6 now requires Python 3. With release 3.1.0 of autotag, the following are now required. To use autotag on older OMERO systems (running Python 2), please use versions older than 3.1.0. -* Python 3.5 or later +* Python 3.8 or later * omero-web 5.6 or later -* django 1.11 or later +* django 4.2 or later User Documentation ================== @@ -122,14 +130,14 @@ Harvard Medical School, then later extended by DPWR Consulting Ltd. These plugins were developed originally with the -support of [Micron Advanced Bioimaging Unit](https://micronoxford.com/) +support of `Micron Advanced Bioimaging Unit `_ funded by the Wellcome Trust Strategic Award 091911, -and [Open Microscopy](https://www.openmicroscopy.org/). +and `Open Microscopy `_. -Continued development was supported by [The Laboratory -of Systems Pharmacology, Harvard Medical School](https://hits.harvard.edu/the-program/laboratory-of-systems-pharmacology/research-program/) and -[Research Computing, Harvard Medical School](https://it.hms.harvard.edu/our-services/research-computing). +Continued development was supported by `The Laboratory +of Systems Pharmacology, Harvard Medical School `_ and +`Research Computing, Harvard Medical School `_. Continued development was sponsored by -[Micron Advanced Bioimaging Unit](https://micronoxford.com/) +`Micron Advanced Bioimaging Unit `_ funded by the Wellcome Trust Strategic Award 107457. diff --git a/omero_autotag/utils.py b/omero_autotag/utils.py index b1af6f9..bd1aced 100644 --- a/omero_autotag/utils.py +++ b/omero_autotag/utils.py @@ -3,7 +3,7 @@ from omero.rtypes import rlong -def createTagAnnotationsLinks(conn, additions=[], removals=[]): +def create_tag_annotations_links(conn, additions=[], removals=[]): """ Links or unlinks existing Images with existing Tag annotations @@ -11,31 +11,32 @@ def createTagAnnotationsLinks(conn, additions=[], removals=[]): @param additions: List of tags to remove from images """ - newLinks = [] + new_links = [] # Create a list of links to apply for addition in additions: link = omero.model.ImageAnnotationLinkI() link.parent = omero.model.ImageI(addition[0], False) link.child = omero.model.TagAnnotationI(addition[1], False) - newLinks.append(link) + new_links.append(link) # Apply the links failed = 0 - savedLinks = [] + saved_links = [] + svc = conn.getUpdateService() try: # will fail if any of the links already exist - savedLinks = conn.getUpdateService().saveAndReturnArray( - newLinks, conn.SERVICE_OPTS + saved_links = svc.saveAndReturnArray( + new_links, conn.SERVICE_OPTS ) except omero.ValidationException: # This will occur if the user has modified the tag landscape outside # of the auto-tagger while using the auto-tagger. Not likely to often # happen, but very possible. - for link in newLinks: + for link in new_links: try: - savedLinks.append( - conn.getUpdateService().saveAndReturnObject(link, conn.SERVICE_OPTS) + saved_links.append( + svc.saveAndReturnObject(link, conn.SERVICE_OPTS) ) except omero.ValidationException: failed += 1 @@ -43,7 +44,7 @@ def createTagAnnotationsLinks(conn, additions=[], removals=[]): if len(removals) > 0: # Get existing links belonging to current user (all at once to save # on queries) - allImageIds, allTagIds = list(zip(*removals)) + all_image_ids, all_tag_ids = list(zip(*removals)) params = omero.sys.Parameters() params.theFilter = omero.sys.Filter() @@ -52,8 +53,8 @@ def createTagAnnotationsLinks(conn, additions=[], removals=[]): # tags, otherwise we'd have to get them individually. links = conn.getAnnotationLinks( "Image", - parent_ids=list(allImageIds), - ann_ids=list(allTagIds), + parent_ids=list(all_image_ids), + ann_ids=list(all_tag_ids), params=params, ) diff --git a/omero_autotag/views.py b/omero_autotag/views.py index f89a532..a9301de 100644 --- a/omero_autotag/views.py +++ b/omero_autotag/views.py @@ -13,7 +13,7 @@ import omero from omero.rtypes import rstring, unwrap from omeroweb.webclient import tree -from .utils import createTagAnnotationsLinks +from .utils import create_tag_annotations_links logger = logging.getLogger(__name__) @@ -30,19 +30,19 @@ def process_update(request, conn=None, **kwargs): removals = [] for image in images: - image_id = image["imageId"] + iid = image["imageId"] additions.extend( - [(int(image_id), int(addition),) for addition in image["additions"]] + [(int(iid), int(addition),) for addition in image["additions"]] ) removals.extend( - [(int(image_id), int(removal),) for removal in image["removals"]] + [(int(iid), int(removal),) for removal in image["removals"]] ) - # TODO Interface for createTagAnnotationsLinks is a bit nasty, but go + # TODO Interface for create_tag_annotations_links is a bit nasty, but go # along with it for now - createTagAnnotationsLinks(conn, additions, removals) + create_tag_annotations_links(conn, additions, removals) return HttpResponse("") diff --git a/setup.py b/setup.py index 37344c7..7ee3379 100644 --- a/setup.py +++ b/setup.py @@ -60,22 +60,23 @@ def run(self): description=DESCRIPTION, long_description=read_file("README.rst"), classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Web Environment", - "Framework :: Django", - "Intended Audience :: End Users/Desktop", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: GNU Affero General Public License v3", - "Natural Language :: English", - "Operating System :: OS Independent", - "Programming Language :: JavaScript", - "Programming Language :: Python :: 3", - "Topic :: Internet :: WWW/HTTP", - "Topic :: Internet :: WWW/HTTP :: Dynamic Content", - "Topic :: Internet :: WWW/HTTP :: WSGI", - "Topic :: Scientific/Engineering :: Visualization", - "Topic :: Software Development :: Libraries :: " "Application Frameworks", - "Topic :: Text Processing :: Markup :: HTML", + 'Development Status :: 5 - Production/Stable', + 'Environment :: Web Environment', + 'Framework :: Django', + 'Intended Audience :: End Users/Desktop', + 'Intended Audience :: Science/Research', + 'License :: OSI Approved :: GNU Affero General Public License v3', + 'Natural Language :: English', + 'Operating System :: OS Independent', + 'Programming Language :: JavaScript', + 'Programming Language :: Python :: 3', + 'Topic :: Internet :: WWW/HTTP', + 'Topic :: Internet :: WWW/HTTP :: Dynamic Content', + 'Topic :: Internet :: WWW/HTTP :: WSGI', + 'Topic :: Scientific/Engineering :: Visualization', + 'Topic :: Software Development :: Libraries :: ' + 'Application Frameworks', + 'Topic :: Text Processing :: Markup :: HTML' ], author=AUTHOR, author_email="dpwrussell@gmail.com",