ISA-tools / mzml2isa

Parser to get meta information from mzML file and parse relevant information to a ISA-Tab structure
GNU General Public License v3.0
12 stars 6 forks source link

Failing on Windows Python 2.7 #15

Closed Tomnl closed 7 years ago

Tomnl commented 7 years ago

Hey,

Seems to be failing for Windows in Python 2.7

See https://ci.appveyor.com/project/Tomnl/mzml2isa/build/1.0.1/job/y6snhyr3k3liwxgq:

Looks like it is a 2 vs 3 compatibility issue.

Any ideas @althonos? ( I will look into as well)

mzml2isa\utils.py:274: UserWarning: Could not use latest online IMS ontology, using local (version [u'0.9.1'])
  "using local (version {})".format(obo.meta['version']))
Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\projects\mzml2isa\mzml2isa\__main__.py", line 5, in <module>
    parsing.main()
  File "mzml2isa\parsing.py", line 214, in main
    jobs=args.jobs, template_directory=args.template_dir
  File "mzml2isa\parsing.py", line 156, in convert
    metalist = [_parse_file([mzml_file, ontology, parser, pbar]) for mzml_file in sorted(mzml_files)]
  File "mzml2isa\utils.py", line 245, in new_func
    return func(*args[0])
  File "mzml2isa\parsing.py", line 77, in _parse_file
    meta = parser(filepath, ontology).meta
  File "mzml2isa\mzml.py", line 132, in __init__
    self._make_params()
  File "mzml2isa\mzml.py", line 524, in _make_params
    '{root}/s:referenceableParamGroupList/s:referenceableParamGroup')}
  File "mzml2isa\utils.py", line 197, in pyxpath
    return meta.tree.iterfind(query.format_map(meta.env), meta.ns)
AttributeError: 'str' object has no attribute 'format_map'
Command exited with code 1
althonos commented 7 years ago

Yup, I forgot that format_map was only available through Python3.

Two ways to fix that: 1) Replace query.format_map(meta.env) by query.format_map(**meta.env) in mzml2isa/utils.py 2) Use string module (in stdlib), and use string.Formatter.vformat

No idea which one is the most efficient though, I have no idea of python unpacking performance

althonos commented 7 years ago

Hi @Tomnl

Current fail on Windows is caused by the fact you try to call mzml2isa/parsing.py, which does relative imports.

Just overhaul our appveyor.yml mzml2isa testing command to use C:\\path-to-py\\python.exe -m mzml2isa [scripts arts]

althonos commented 7 years ago

(I've fixed the original format_map issue before releasing v0.5.0)

Tomnl commented 7 years ago

Hi Martin,

Thanks for the format_map update.

Sorry forgot to mention I was testing yesterday on another branch 'windows-test' that had the updated command line use.

I will merge now Cheers, Tom