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

Different environments, depending on path of execution #116

Open
Heerpa opened this Issue Aug 22, 2017 · 6 comments

Comments

Projects
None yet
2 participants
@Heerpa

Heerpa commented Aug 22, 2017

Hi,
When I call functions using the javabridge from terminal using nosetests, the behaviour is different to the execution of my code directly, as a module. In particular, I am calling the exact same function that uses
'

units = javabridge.JClassWrapper('ome.units.UNITS')
meter = units.METER

'
in the nosetest-case, the field METER exists, but not in the direct case (or from ipython). When calling units.field_names, different lists are returned (see below for a comparison). I find this curious and expect that the reason may be that I somehow end up in different environments of whatever kind (I am definitely in the same conda environment). It is fixable by using METRE instead of METER, NM instead of NANOMETER, etc.

A more pressing, but probably connected issue is that writing to file using
'

wrtr = javabridge.JClassWrapper('loci.formats.ImageWriter')()
wrtr.setMetadataRetrieve(meta)
wrtr.setId(path)
wrtr.saveBytes(0, np.frombuffer(image[:, :].flatten().tobytes(), dtype=np.uint8))
wrtr.close()

'
works when calling nosetests, but when called directly from ipython or execution of the code in module mode, the execution hangs during saveBytes(..) (the image being a 2D np.uint16 array)

printing bioformats.JARS yields the exact same result in either execution mode.

I am stuck here and can't think of how to proceed. Any help would be appreciated.
this is somewhat connected to issue #113, I am still trying to write ome.tiff files.

list of fields of units using ipython:
['RADIAN', 'VOLT', 'HERTZ', 'METRE', 'INCH', 'WATT', 'PASCAL', 'KELVIN', 'SECOND', 'YOTTAHZ', 'ZETTAHZ', 'EXAHZ', 'PETAHZ', 'TERAHZ', 'GIGAHZ', 'MEGAHZ', 'KHZ', 'HHZ', 'DAHZ', 'HZ', 'DHZ', 'CHZ', 'MHZ', 'MICROHZ', 'NHZ', 'PHZ', 'FHZ', 'AHZ', 'ZHZ', 'YHZ', 'YOTTAM', 'ZETTAM', 'EXAM', 'PETAM', 'TERAM', 'GIGAM', 'MEGAM', 'KM', 'HM', 'DAM', 'M', 'DM', 'CM', 'MM', 'MICROM', 'NM', 'PM', 'FM', 'AM', 'ZM', 'YM', 'ANGSTROM', 'THOU', 'LI', 'IN', 'FT', 'YD', 'MI', 'UA', 'LY', 'PC', 'PT', 'PIXEL', 'REFERENCEFRAME', 'YOTTAW', 'ZETTAW', 'EXAW', 'PETAW', 'TERAW', 'GIGAW', 'MEGAW', 'KW', 'HW', 'DAW', 'W', 'DW', 'CW', 'MW', 'MICROW', 'NW', 'PW', 'FW', 'AW', 'ZW', 'YW', 'YOTTAPA', 'ZETTAPA', 'EXAPA', 'PETAPA', 'TERAPA', 'GIGAPA', 'MEGAPA', 'KPA', 'HPA', 'DAPA', 'PA', 'DPA', 'CPA', 'MPA', 'MICROPA', 'NPA', 'PPA', 'FPA', 'APA', 'ZPA', 'YPA', 'BAR', 'MEGABAR', 'KBAR', 'DBAR', 'CBAR', 'MBAR', 'ATM', 'PSI', 'TORR', 'MTORR', 'MMHG', 'DEGREEC', 'K', 'DEGREER', 'DEGREEF', 'YOTTAS', 'ZETTAS', 'EXAS', 'PETAS', 'TERAS', 'GIGAS', 'MEGAS', 'KS', 'HS', 'DAS', 'S', 'DS', 'CS', 'MS', 'MICROS', 'NS', 'PS', 'FS', 'AS', 'ZS', 'YS', 'MIN', 'H', 'D', 'YOTTAV', 'ZETTAV', 'EXAV', 'PETAV', 'TERAV', 'GIGAV', 'MEGAV', 'KV', 'HV', 'DAV', 'V', 'DV', 'CV', 'MV', 'MICROV', 'NV', 'PV', 'FV', 'AV', 'ZV', 'YV', 'DEG', 'RAD', 'GON']

list of fields in units using nosetests:
['RADIAN', 'VOLT', 'HERTZ', 'METRE', 'INCH', 'WATT', 'PASCAL', 'KELVIN', 'SECOND', 'YOTTAHERTZ', 'ZETTAHERTZ', 'EXAHERTZ', 'PETAHERTZ', 'TERAHERTZ', 'GIGAHERTZ', 'MEGAHERTZ', 'KILOHERTZ', 'HECTOHERTZ', 'DECAHERTZ', 'DECIHERTZ', 'CENTIHERTZ', 'MILLIHERTZ', 'MICROHERTZ', 'NANOHERTZ', 'PICOHERTZ', 'FEMTOHERTZ', 'ATTOHERTZ', 'ZEPTOHERTZ', 'YOCTOHERTZ', 'YOTTAHZ', 'ZETTAHZ', 'EXAHZ', 'PETAHZ', 'TERAHZ', 'GIGAHZ', 'MEGAHZ', 'KHZ', 'HHZ', 'DAHZ', 'HZ', 'DHZ', 'CHZ', 'MHZ', 'MICROHZ', 'NHZ', 'PHZ', 'FHZ', 'AHZ', 'ZHZ', 'YHZ', 'YOTTAMETRE', 'ZETTAMETRE', 'EXAMETRE', 'PETAMETRE', 'TERAMETRE', 'GIGAMETRE', 'MEGAMETRE', 'KILOMETRE', 'HECTOMETRE', 'DECAMETRE', 'DECIMETRE', 'CENTIMETRE', 'MILLIMETRE', 'MICROMETRE', 'NANOMETRE', 'PICOMETRE', 'FEMTOMETRE', 'ATTOMETRE', 'ZEPTOMETRE', 'YOCTOMETRE', 'YOTTAMETER', 'ZETTAMETER', 'EXAMETER', 'PETAMETER', 'TERAMETER', 'GIGAMETER', 'MEGAMETER', 'KILOMETER', 'HECTOMETER', 'DECAMETER', 'METER', 'DECIMETER', 'CENTIMETER', 'MILLIMETER', 'MICROMETER', 'NANOMETER', 'PICOMETER', 'FEMTOMETER', 'ATTOMETER', 'ZEPTOMETER', 'YOCTOMETER', 'ANGSTROM', 'THOU', 'LINE', 'FOOT', 'YARD', 'MILE', 'ASTRONOMICALUNIT', 'LIGHTYEAR', 'PARSEC', 'POINT', 'PIXEL', 'REFERENCEFRAME', 'YOTTAM', 'ZETTAM', 'EXAM', 'PETAM', 'TERAM', 'GIGAM', 'MEGAM', 'KM', 'HM', 'DAM', 'M', 'DM', 'CM', 'MM', 'MICROM', 'NM', 'PM', 'FM', 'AM', 'ZM', 'YM', 'LI', 'IN', 'FT', 'YD', 'MI', 'UA', 'LY', 'PC', 'PT', 'YOTTAWATT', 'ZETTAWATT', 'EXAWATT', 'PETAWATT', 'TERAWATT', 'GIGAWATT', 'MEGAWATT', 'KILOWATT', 'HECTOWATT', 'DECAWATT', 'DECIWATT', 'CENTIWATT', 'MILLIWATT', 'MICROWATT', 'NANOWATT', 'PICOWATT', 'FEMTOWATT', 'ATTOWATT', 'ZEPTOWATT', 'YOCTOWATT', 'YOTTAW', 'ZETTAW', 'EXAW', 'PETAW', 'TERAW', 'GIGAW', 'MEGAW', 'KW', 'HW', 'DAW', 'W', 'DW', 'CW', 'MW', 'MICROW', 'NW', 'PW', 'FW', 'AW', 'ZW', 'YW', 'YOTTAPASCAL', 'ZETTAPASCAL', 'EXAPASCAL', 'PETAPASCAL', 'TERAPASCAL', 'GIGAPASCAL', 'MEGAPASCAL', 'KILOPASCAL', 'HECTOPASCAL', 'DECAPASCAL', 'DECIPASCAL', 'CENTIPASCAL', 'MILLIPASCAL', 'MICROPASCAL', 'NANOPASCAL', 'PICOPASCAL', 'FEMTOPASCAL', 'ATTOPASCAL', 'ZEPTOPASCAL', 'YOCTOPASCAL', 'BAR', 'MEGABAR', 'KILOBAR', 'DECIBAR', 'CENTIBAR', 'MILLIBAR', 'ATMOSPHERE', 'PSI', 'TORR', 'MILLITORR', 'MMHG', 'YOTTAPA', 'ZETTAPA', 'EXAPA', 'PETAPA', 'TERAPA', 'GIGAPA', 'MEGAPA', 'KPA', 'HPA', 'DAPA', 'PA', 'DPA', 'CPA', 'MPA', 'MICROPA', 'NPA', 'PPA', 'FPA', 'APA', 'ZPA', 'YPA', 'KBAR', 'DBAR', 'CBAR', 'MBAR', 'ATM', 'MTORR', 'CELSIUS', 'RANKINE', 'FAHRENHEIT', 'DEGREEC', 'K', 'DEGREER', 'DEGREEF', 'YOTTASECOND', 'ZETTASECOND', 'EXASECOND', 'PETASECOND', 'TERASECOND', 'GIGASECOND', 'MEGASECOND', 'KILOSECOND', 'HECTOSECOND', 'DECASECOND', 'DECISECOND', 'CENTISECOND', 'MILLISECOND', 'MICROSECOND', 'NANOSECOND', 'PICOSECOND', 'FEMTOSECOND', 'ATTOSECOND', 'ZEPTOSECOND', 'YOCTOSECOND', 'MINUTE', 'HOUR', 'DAY', 'YOTTAS', 'ZETTAS', 'EXAS', 'PETAS', 'TERAS', 'GIGAS', 'MEGAS', 'KS', 'HS', 'DAS', 'S', 'DS', 'CS', 'MS', 'MICROS', 'NS', 'PS', 'FS', 'AS', 'ZS', 'YS', 'MIN', 'H', 'D', 'YOTTAVOLT', 'ZETTAVOLT', 'EXAVOLT', 'PETAVOLT', 'TERAVOLT', 'GIGAVOLT', 'MEGAVOLT', 'KILOVOLT', 'HECTOVOLT', 'DECAVOLT', 'DECIVOLT', 'CENTIVOLT', 'MILLIVOLT', 'MICROVOLT', 'NANOVOLT', 'PICOVOLT', 'FEMTOVOLT', 'ATTOVOLT', 'ZEPTOVOLT', 'YOCTOVOLT', 'YOTTAV', 'ZETTAV', 'EXAV', 'PETAV', 'TERAV', 'GIGAV', 'MEGAV', 'KV', 'HV', 'DAV', 'V', 'DV', 'CV', 'MV', 'MICROV', 'NV', 'PV', 'FV', 'AV', 'ZV', 'YV', 'DEGREE', 'GRADIAN', 'DEG', 'RAD', 'GON']

@LeeKamentsky

This comment has been minimized.

Owner

LeeKamentsky commented Aug 22, 2017

I would print out your python path in both environments:

import sys
print sys.path

You might have a different version of Numpy than the one used to compile Javabridge.

@Heerpa

This comment has been minimized.

Heerpa commented Aug 22, 2017

sys.path yields the same in both cases:
['/Users/grabmayr/anaconda/envs/quantiplex_env/bin', '/Users/grabmayr/anaconda/envs/quantiplex_env/lib/python36.zip', '/Users/grabmayr/anaconda/envs/quantiplex_env/lib/python3.6', '/Users/grabmayr/anaconda/envs/quantiplex_env/lib/python3.6/lib-dynload', '/Users/grabmayr/anaconda/envs/quantiplex_env/lib/python3.6/site-packages', '/Users/grabmayr/GitLab/quantiplex', '/Users/grabmayr/anaconda/envs/quantiplex_env/lib/python3.6/site-packages/javabridge-1.0.14_27_g41bf79b-py3.6-macosx-10.7-x86_64.egg']

as for numpy:
'

 conda list

'
yields:
'

javabridge-1.0.14-27      g41bf79b                  <pip>
..
numpy                     1.12.1                   py36_0
numpy                     1.13.1                    <pip>

'

@LeeKamentsky

This comment has been minimized.

Owner

LeeKamentsky commented Aug 22, 2017

It could very well be that Javabridge was compiled against Numpy 1.12.1 and Python is importing 1.13.1 or vice versa. I would try uninstalling Javabridge and reinstalling it.

@Heerpa

This comment has been minimized.

Heerpa commented Aug 23, 2017

Numpy 1.13.1 came with javabridge. I pip uninstalled it (seeing no other dependencies were affected), then updated the remainig numpy 1.12.1 to 1.13.1 using conda, thereby also updating a few dependencies. after building javabridge from source (pip installation doesn't work as I am working with mac and it wouldn't find the JVM), I only have one numpy version in my environment, but the described issue remains the same.

@Heerpa

This comment has been minimized.

Heerpa commented Aug 23, 2017

I just tested on an ubuntu machine and saw that the issue doesn't come up there. Its environment has the same numpy version 1.13.1. Here I could test with javabridge installed from source as well as pip installed. Both options work.
Going back to the mac, I created a new conda environment from the same environment.yaml file as on ubuntu to make sure they are as similar as possible. Still, on mac, the issue remains.

@LeeKamentsky

This comment has been minimized.

Owner

LeeKamentsky commented Aug 23, 2017

I don't have a Mac to test on currently. I know there's some code that is specific to that platform. If I recall, there are issues regarding which version of Java is used on the Mac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment