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

Upgrade check updates #34

Merged
merged 15 commits into from
Apr 11, 2012
Merged

Upgrade check updates #34

merged 15 commits into from
Apr 11, 2012

Conversation

melissalinkert
Copy link
Member

Moves the upgrade checking logic out of the loci-plugins component, so that anyone using Bio-Formats can use the upgrade check functionality.

There is a small command-line tool to demonstrate this (loci.formats.tools.UpgradeCheck), and the ImageJ plugin has been updated accordingly.

QA also correctly shows a new column ("Bio-Formats") in the statistics reports, and there are several starts recorded which suggests that the registry check is indeed working correctly.

In the very near future, it would be nice to be able to perform upgrade
checks from any Bio-Formats-enabled application (e.g. MATLAB).  So now
we do what should have been done from the beginning, and decouple the
actual upgrade checking logic from the ImageJ plugin that upgrades the
version of loci_tools.jar used by ImageJ.
@joshmoore
Copy link
Member

Looks good, Melissa. Obviously some of the URLs are in flux, but I'm sure that's on your radar. Which code paths will trigger this? The bf command line utilities? ImageReader usage?

@melissalinkert
Copy link
Member Author

At the moment, the only things that trigger the upgrade checks are opening a file in ImageJ using Bio-Formats, explicitly running the ImageJ update plugin, and using the little command line utility in c96950e.

I'm open to suggestions on where else to call the upgrade check, keeping in mind that it must be easy to turn off.

@joshmoore
Copy link
Member

I would think all of the command-line scripts could perform the check. In fact, since the script should know where the tools jar is, it would be possible to have it automatically upgrade which is what you often must suggest to users anyway. For each of the tools, it probably makes sense to also record the class that was used. The only issue I could see would be if there are any of the tool scripts which are used in tight loops.

bfopen.m is probably a similar location, but we could further make sure that invocation only takes place once per Matlab session (by setting a JVM property "bioformats_already_checked" etc.)

Use of bf as a library is more difficult. The only thing I can think of to prevent multiple calls for someone who keeps, say, re-creating ImageReader or whatever is to have a file on disk that is checked against the current timestamp.

And while we're at it, add a method that allows the caller to know
whether or not the upgrade check has been performed in the JVM session.
This is helpful for making sure that the upgrade check is not called
many times.
Auto-upgrading can be enabled by setting the 'autoDownload' flag; it is
turned off by default.
As with the "have we already done the upgrade check?" method, this just
boils down to getting/setting a system property.  By default, the
upgrade check is still enabled.
@melissalinkert
Copy link
Member Author

Above commits should largely address your points, @joshmoore. bfopen.m and the command line tools now call the upgrade checker, and the class will always be passed to the registry (as "bioformats.class").

A system property is set once the upgrade check has been performed for the first time in a JVM session; this is easily accessible to the caller, but it is the responsibility of the caller to decide whether or not to use it.

Similarly, a system property is available that can disable all upgrade checks in the current JVM session. This is primarily useful for people who have slow or no internet connections, or those who think that upgrade checks are inherently evil. By default, of course, the check is still enabled.

I still haven't added a check in ImageReader, as I'm still undecided as to whether I like that idea - it's helpful to a point, but awfully invasive.

How on earth did I manage to commit this?!
And while we're at it, fix a stupid typo in "loci.formats.UpgradeChecker".
@sbesson
Copy link
Member

sbesson commented Mar 20, 2012

Following the general idea of pull request #41, can we also convert doUpgradeCheck into a function (instead of a subfunction) to extend its usability scope?

@joshmoore
Copy link
Member

@sbesson: do you feel up to trying that? You can issue it as a PR on this PR?

sbesson and others added 2 commits March 20, 2012 13:46
Upgrade check: split MATLAB upgrade checking function into a separate .m file
@joshmoore
Copy link
Member

After refactoring, this is the current hit to the registry:

select creation_date, header from registry_hit where agent_id in (13) order by id desc limit 10;
...
 2012-03-12 09:47:06.673698+00 | {'AUTH_TYPE': None, 'SERVER_SOFTWARE': 'mod_python', 'SCRIPT_NAME': '', 'REQUEST_METHOD': 'GET', 'PATH_INFO': u'/registry/hit/', 'SERVER_PROTOCOL': 'HTTP/1.1', 'QUERY_STRING': 'version=4.4-DEV;os.name=Linux;os.version=2.6.32-37-generic;os.arch=i386;java.runtime.version=1.6.0_26-b03;java.vm.vendor=Sun+Microsystems+Inc.;bioformats.class=loci.formats.UpgradeChecker', 'CONTENT_LENGTH': 0L, 'REMOTE_USER': None, 'HTTP_CONNECTION': 'keep-alive', 'SERVER_NAME': 'qa.openmicroscopy.org.uk', 'REMOTE_ADDR': '76.118.20.70', 'PATH_TRANSLATED': None, 'SERVER_PORT': 80, 'HTTP_PRAGMA': 'no-cache', 'HTTP_USER_AGENT': 'OMERO.bioformats', 'HTTP_HOST': 'qa.openmicroscopy.org.uk', 'HTTP_CACHE_CONTROL': 'no-cache', 'HTTP_ACCEPT': 'text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2', 'GATEWAY_INTERFACE': 'CGI/1.1', 'REMOTE_IDENT': None, 'CONTENT_TYPE': None, 'REMOTE_HOST': None}

i.e. the class being posted is 'UpgradeChecker'.

...instead of always assuming that the stack element with index 1 is
what we want.
@melissalinkert
Copy link
Member Author

@joshmoore Above commit ought to fix the class name being sent to the registry. It seems to work for me, but is not so well tested.

@joshmoore
Copy link
Member

Sorry, Melissa, but now it's:

bioformats.class=java.lang.Thread

Would it be worth moving to just passing the value?

...instead of trying to guess which class called UpgradeChecker.
@melissalinkert
Copy link
Member Author

Well, 'java.lang.Thread' was what it was before. In any case, added a commit now to pass in a description of the caller - should be "ImageJ" for the ImageJ plugins, "MATLAB" for bfUpgradeCheck.m, and "Bio-Formats utilities" for the command-line tools.

Not tied to those names necessarily, so happy to change them if you prefer. Only downside that I can see is that it's now on the honor system as to whether a particular caller correctly sets a description (e.g. there is nothing preventing us or anyone else from setting "ImageJ" when calling from MATLAB).

@joshmoore
Copy link
Member

I'm not too terribly worried about the lack of prevention: all the other upgrade checkers are also spoofable.

@joshmoore
Copy link
Member

bioformats.caller=Bio-Formats+utilities 👍

@joshmoore
Copy link
Member

Doh. This no longer merges cleanly.

Conflicts:
	components/bio-formats/utils/bfopen.m
@melissalinkert
Copy link
Member Author

@joshmoore Should merge cleanly now.

As @sbesson noted, there was a conflict with bfopen.m, due to the refactoring that's been going on in other branches.

@sbesson sbesson mentioned this pull request Apr 10, 2012
@joshmoore
Copy link
Member

Melissa/Sebastien ok'd: merging.

joshmoore added a commit that referenced this pull request Apr 11, 2012
@joshmoore joshmoore merged commit 3e10eaf into ome:develop Apr 11, 2012
hflynn pushed a commit to hflynn/bioformats that referenced this pull request Oct 11, 2013
snoopycrimecop pushed a commit to snoopycrimecop/bioformats that referenced this pull request Mar 13, 2015
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.

None yet

3 participants