Skip to content

VO - #46

Merged
mdboom merged 40 commits into
astropy:masterfrom
mdboom:vo
Nov 11, 2011
Merged

VO#46
mdboom merged 40 commits into
astropy:masterfrom
mdboom:vo

Conversation

@mdboom

@mdboom mdboom commented Nov 3, 2011

Copy link
Copy Markdown
Contributor

This is an initial import of vo.table into astropy as astropy.io.vo.

This includes only the VOTABLE file format handling code. The VO networking (conesearch, ssa, image search etc.) stuff is still kind of half-baked and not ready -- that will live on a branch on my fork for a while.

There are some things left to do, but they are perhaps best left for after merging:

  • There are lots of general-purpose utilities here that should be moved into astropy.utils.
  • There are some local data files which should use the new data loading framework when that lands on master.
  • It has an optional dependency on "xmllint" for schema verification. We should add this to the forthcoming "check for optional dependencies" tool. At the moment, an exception is raised when calling the single function that depends upon "xmllint". The tests will pass without "xmllint" installed, but the output of the tests will not be verified against the schema.

Some points:

  • This includes all of expat verbatim in cextern. It does not build with a system copy of expat because at least on Ubuntu and Fedora, the system expat is built with UTF-8 strings rather than UCS2/4 strings which makes the conversion to Python Unicode strings much slower. In benchmarking I found this to have a factor of about 15% speedup. The Python expat wrappers perform even worse because they do a lot of unnecessary work. So, somehow, I suppose it should be documented that even though we are including expat in cextern, we don't want to create the option for the user to build against a system expat.

@astrofrog

Copy link
Copy Markdown
Member

It looks like astropy/io/vo/src is missing?

i686-apple-darwin10-gcc-4.2.1: astropy/io/vo/src/iterparse.c: No such file or directory
i686-apple-darwin10-gcc-4.2.1: no input files
error: command '/usr/bin/gcc-4.2' failed with exit status 1

@mdboom

mdboom commented Nov 3, 2011

Copy link
Copy Markdown
Contributor Author

Yes, indeed. I was foiled by the "*.c" in .gitignore again ;)

@astrofrog

Copy link
Copy Markdown
Member

Ok, I get further, but I cannot build this branch on MacOS 10.6 with Python 2.7:

/usr/bin/gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DHAVE_EXPAT_CONFIG_H=1 -DBYTEORDER=1234 -DHAVE_UNISTD_H -Iastropy/io/vo/src -Icextern/expat/lib -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c astropy/io/vo/src/iterparse.c -o build/temp.macosx-10.6-x86_64-2.7/astropy/io/vo/src/iterparse.o
astropy/io/vo/src/iterparse.c:1506: warning: ‘_state’ defined but not used
/usr/bin/gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DHAVE_EXPAT_CONFIG_H=1 -DBYTEORDER=1234 -DHAVE_UNISTD_H -Iastropy/io/vo/src -Icextern/expat/lib -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c cextern/expat/lib/xmlparse.c -o build/temp.macosx-10.6-x86_64-2.7/cextern/expat/lib/xmlparse.o
cextern/expat/lib/xmlparse.c:20:26: error: expat_config.h: No such file or directory
cextern/expat/lib/xmlparse.c:81:2: error: #error memmove does not exist on this platform, nor is a substitute available
cextern/expat/lib/xmlparse.c: In function ‘XML_Parse’:
cextern/expat/lib/xmlparse.c:1491: warning: enumeration value ‘XML_FINISHED’ not handled in switch
error: command '/usr/bin/gcc-4.2' failed with exit status 1

@mdboom

mdboom commented Nov 4, 2011

Copy link
Copy Markdown
Contributor Author

@astrofrog: Sorry. Again, it was a missing file. I just tested with a fresh clone and it seems to be working now, and passing all tests.

@astrofrog

Copy link
Copy Markdown
Member

It installs fine now and all tests run successfully.

@astrofrog

Copy link
Copy Markdown
Member

The documentation has some mentions of the networking capability (e.g. Note The network functionality in the conesearch, ssa and image modules is experimental and subject to change.) - maybe this should be removed for now?

@astrofrog

Copy link
Copy Markdown
Member

Minor: on the main documentation page, the headings for the WCS and VO stuff aren't consistent (astropy.wcs Documentation vs vo.table documentation. Also, are you planning on including the vo history?

@mdboom

mdboom commented Nov 4, 2011

Copy link
Copy Markdown
Contributor Author

Good catch. Yes. I think we should just remove those for now.

@mdboom

mdboom commented Nov 4, 2011

Copy link
Copy Markdown
Contributor Author

Will fix the documentation headers to match wcs.

I wasn't planning on including history -- after all the moves etc. it's not clear it would be directly useful. The SVN history will live on indefinitely as a resource in a bind.

@eteq

eteq commented Nov 5, 2011

Copy link
Copy Markdown
Member

About the included expat: I didn't entirely understand your last comment there - you're saying we don't want to let the user build against the system expat... is this just for the performance reasons? I think we should still allow the system expat (or even the python builtin expat) to be used if the user desires, as long as we make it clear that it will be slower. I can certainly imagine systems where something goes wrong with the astropy expat builds, but the user says "screw it, I'm fine with a 15% slowdown because I don't want to bother figuring out how to compile astropy." Is there any reason why these can't be left as options? (For now, feel free to just put it in as a constant or something in setup_package.py - we can update it after we have the extension cfg system working).

@eteq

eteq commented Nov 5, 2011

Copy link
Copy Markdown
Member

Oh, also, just so we're clear, the cextern expat is only statically linked to iterparser, right? So an expat library file is never actually generated?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if these are "data" in the sense we've been discussing in other contexts... they are data that is necessary for the source code to work, rather than data needed to do specific things in the source code (that is, they are more like code constants than, say, spectroscopic line lists or something). So should the XML-related "data" not be in the data-storing scheme that I'm working on in the config package?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ucd1p-words.txt is necessary to parse any VOTABLE 1.2 file. The other two are necessary only if one wishes to perform validation.

So yes, some of this could be moved to the new scheme once it's available.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, we can discuss it then. My thought is actually that these should not be data because validation is still nominally part of the code, rather than ancillary data that the code uses. But this is a rather blurry area...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eteq: I see what you're saying. I'm certainly open to reorganization. Here I mean data to mean "anything that isn't importable". You're right, though: it's not science data or anything of that sort.

@mdboom

mdboom commented Nov 5, 2011

Copy link
Copy Markdown
Contributor Author

I should have been more clear about the expat. Expat has a number of #defines that change how it is built, and different Linux distros build in different ways. The one that matters here is whether it returns utf-8 or ucs4 to the caller. To handle the system expat, we'd have to handle and test both cases, and also do extra work if it is built for utf-8. That's where the 15% comes in. vo.table also has a fallback to pure Python standard library for the XML parsing, but that is about 3x slower. So, IMO, it's preferable to build our own expat -- it's very simple to build -- and use that. And we have a pure Python fallback which could be selected using our forthcoming build configuration system in case building expat as part of astropy is a problem for some users (it seems very unlikely as it's very portable C code).

To answer your question -- no standalone expat library is built, it simply builds the 4 required C files as part of the iterparse extension.

@eteq

eteq commented Nov 7, 2011

Copy link
Copy Markdown
Member

Ah, that all makes sense re: expat. It's a bit annoying that we have to include it, but I see you point for why it's useful. We definitely want the option of a fallback to the python builtin version, but we can deal with that later (as you say).

@mdboom

mdboom commented Nov 7, 2011

Copy link
Copy Markdown
Contributor Author

@eteq: Just to clarify -- the pure Python fallback already exists and is tested as part of the unit tests. The only thing missing is an option for a user to choose not to build the C extension.

Comment thread astropy/setup_helpers.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this _build_mode being used for? Is it only for places where you're trying to import stuff at build-time? If so, it's safer (and more consistent with the other packages) to use try/except and catch ImportErrors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used in io/vo/__init__.py. It can not import anything under Python 3 in io.vo until 2to3 has been run on it. I'm worried about a blanket except ImportError: pass because that will hide any legitimate errors. I think this approach is more specific as to when we want to avoid importing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, something like python setup.py test will think it's in build mode, now, right? That's definitely not the correct behavior. I see your point about acidentally hiding ImportErrors, but in this case, the only way that could happen is if you didn't have the vo.exceptions module, right? Or were you planning on adding more sutuff to the vo __init__.py?

@iguananaut, do you have any thoughts on this matter, given that I think you wrote something like this in one of the other setup scripts? Is there a flag already built-in to distutils or distribute that we can use here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ImportError could be triggered by any error that happens at import time inside of exceptions.py or anything it includes. (This is the problem with ImportError -- it's a real blunt tool and can't be used to determine if a module can not be found or has an error -- and if there is an error, it becomes silently hidden).

setup.py test runs the tests in a separate process, so it doesn't inherit the __builtins__ from the parent. It has to do this because the build first imports things with C extensions missing, yet ignores that to complete the build, and then needs to get at those C extensions.

@iguananaut pointed out on the mailing list that Numpy uses a similar approach to this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I see your point here as a general problem.

One other thing to keep in mind, here, though: In the vision and at the meeting I thought we all agreed that importing should always work, even if actually doing anything with what you import might fail. So perhaps we want the blunt instrument here, because we want import astropy.io.vo to always work, even if import astropy.io.vo import parse or something like that fails. This isn't quite as relevant as in some other cases because the compilation is unnecessary if it falls back to the builtin expat, but we do want to leave the option open of having astropy be installed even when some of the compiled modules are not available.

@astrofrog, do you have any thoughts on this? I think we want to try to be consistent on this - either using the if is_in_build_mode() everywhere, or a except ImportError everywhere that we would otherwise use is_in_build_mode...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting...I was just playing around with a hack similar to this for pyfits. In my version it adds __ASTROPY_SETUP__ to builtins, a la numpy.

The tests aren't a problem because setup.py test runs the tests in a separate process, so __ASTROPY_SETUP__ won't be defined when the tests are run.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to add: In addition to __ASTROPY_SETUP__ I want to figure out if there's a way I can set a global variable that's only True if 2to3 has been run on the current code. That would allow even more flexibility: It would only prevent code from being imported if it's being run in Python 3 and is not Python 3-compatible. I just haven't looked into how that could be done yet.

@eteq

eteq commented Nov 7, 2011

Copy link
Copy Markdown
Member

I couldn't get github to show me all of the diffs, I think because this pull request has so many files in it. So the stuff above is inline comments that github isn't showing you the context for.

@eteq

eteq commented Nov 7, 2011

Copy link
Copy Markdown
Member

One other thing: when I run the tests on this, it modifies the file astropy/io/vo/tests/data/test_through_binary.xml, which is under git version control. I don't think we want the tests modifying anything under version control - maybe either have git forget it, or if it has a role in the test before the test is run, perhaps write to a temporary file?

@mdboom

mdboom commented Nov 7, 2011

Copy link
Copy Markdown
Contributor Author

Good catch about test_through_binary.xml. That should be in the tmp dir and was never intended to be checked in.

@eteq

eteq commented Nov 7, 2011

Copy link
Copy Markdown
Member

Does anyone know a way to make the diff's visible? I want to be able to look at the diffs for some of the files at the end of the list, but they're all hidden (I think because the page would be too big, otherwise)

@mdboom

mdboom commented Nov 7, 2011

Copy link
Copy Markdown
Contributor Author

Yeah -- it's annoying. You can of course look at the diff offline, but then there's no code review ;) I could take expat out of here for now, but then we'll have a branch that doesn't actually "work".

Comment thread astropy/io/vo/__init__.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to import a lot of stuff like sys and os that clutters up the namespace. maybe implement an _all__ = ... in exceptions.py?

Also, I think it might be good to do from .table import parse,parse_single_table so that the user doesn't have to figure out what module they're looking for in the most-common use case.

@mdboom

mdboom commented Nov 8, 2011

Copy link
Copy Markdown
Contributor Author

@eteq: I think this latest set of commits addresses everything you raised.

@eteq

eteq commented Nov 11, 2011

Copy link
Copy Markdown
Member

So is this good to go? I don't see anything else that needs changes that can't be post-merge - @astrofrom and @iguananaut?

Oh, and @mdboom - when it does get merged, can you create issues for the things we mentioned as "todo after merge"? Thanks.

@astrofrog

Copy link
Copy Markdown
Member

@eteq: it seems fine to me (disclaimer: I haven't checked it all line by line).

@embray

embray commented Nov 11, 2011

Copy link
Copy Markdown
Member

Yeah, I think it's the sort of thing where it's going to be best to go ahead and get things merged in order to start tweaking them more. In particular we need to work on centralizing some of the Py3K hacks.

@mdboom

mdboom commented Nov 11, 2011

Copy link
Copy Markdown
Contributor Author

Ok. Merging now... Will add some issues for various TODO list items as @eteq suggests.

mdboom added a commit that referenced this pull request Nov 11, 2011
@mdboom
mdboom merged commit f649481 into astropy:master Nov 11, 2011
keflavich pushed a commit to keflavich/astropy that referenced this pull request Oct 9, 2013
@bsipocz bsipocz mentioned this pull request Jun 2, 2014
embray pushed a commit to embray/astropy that referenced this pull request Jan 23, 2015
Allow for selecting the pkg-config executable
astrofrog pushed a commit to astropy/sphinx-astropy that referenced this pull request Jan 29, 2018
Cadair pushed a commit to Cadair/astropy that referenced this pull request Dec 19, 2022
Remove ZBLANK logic from data property since this is handled at a lower level
@saimn saimn mentioned this pull request Nov 6, 2023
1 task
@pllim pllim mentioned this pull request Mar 22, 2024
1 task
jeffjennings pushed a commit to jeffjennings/astropy that referenced this pull request Jul 2, 2025
jeffjennings pushed a commit to jeffjennings/astropy that referenced this pull request Jul 2, 2025
Fixes Issue astropy#46 Adds WCSAxes to the affiliated package repo
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.

5 participants