-
Notifications
You must be signed in to change notification settings - Fork 203
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
initial support for geopackage metatata #715
Conversation
Strange, it says here that the metadata has been supported since GDAL 1.11, but that seems to be the only one failing. |
Hmmm, any ideas on this error:
|
2 similar comments
GDAL 1.11 is the only one that fails to get/set metadata correctly. How would you like that handled? |
Despite the documentation it seems to me that GDAL 1.x doesn't support GPKG metadata: >>> from osgeo import ogr
>>> driver = ogr.GetDriverByName("GPKG")
>>> ds = driver.CreateDataSource("new.gpkg")
>>> ds.SetMetadataItem("foo", "bar")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/osgeo/ogr.py", line 577, in <lambda>
__getattr__ = lambda self, name: _swig_getattr(self, DataSource, name)
File "/usr/lib/python3/dist-packages/osgeo/ogr.py", line 74, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
File "/usr/lib/python3/dist-packages/osgeo/ogr.py", line 69, in _swig_getattr_nondynamic
return object.__getattr__(self, name)
AttributeError: type object 'object' has no attribute '__getattr__' |
That's unfortunate. Maybe adding the decorator |
0230222
to
002daed
Compare
fiona/env.py
Outdated
@@ -538,7 +538,6 @@ def some_func(foo=None): | |||
reason = '\n{0}'.format(reason) if reason else reason | |||
|
|||
def decorator(f): | |||
@wraps(f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a shame to make the experience on Python 3 worse in order to support Python 2, which is EOL this year.
We don't have a formal plan for what we're doing with Python 2 yet. Thoughts @sgillies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wraps
wasn't breaking anything before. Can you explain what has changed @snowman2 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference here is that it is being used on a class method instead of a function. It works fine for functions. However, when being applied to a class method, it breaks in Python 2 see build logs This issue was resolved in Python 3.2 see here. Definitely open to ideas for a better solution.
I've finally made some time to get to this! Here's a test that was failing before the
The method returns I think it would be fine to remove the decorator and let this method raise an exception with GDAL 1.11. We'll document the situation and will be leaving 1.x behind sooner or later. It shouldn't block us from moving ahead. @snorfalorpagus @snowman2 Yes? No? |
Sounds like a good plan to me. |
@sgillies I removed the commits with the decorators. |
Should I add the env block in the tests? |
@snowman2 yes, please. And, if you like: catch the exception coming from fiona.ogrext with GDAL 1.11 and xfail the test inside the except clause using pytest.xfail. |
xfail coming after I the next tests fail so I have the specific exception it raises. |
@sgillies, it does not seem to raise an exception. How would you like to proceed? |
@snowman2 I'm surprised at the lack of an exception, but for now, let's test the dict and xfail if it is empty and if the GDAL version is less than 2.0. |
Congratulations @snowman2 ! I'm going to give this a little more review on the weekend, focusing on what to return or raise when the collection isn't open (no session or whatever). Generally, this is great stuff. |
Just squashed it. 👍 |
* Add model module and tests model.Object is the dict with deprecation warnings class. * Reformat, give up on dict instance checks
Is there still interest in this PR? I can take a stab at continuing it. |
@joehuanguf yes, this is just held up by a refactor and my involvement in GDAL 3 fallout. We're still going to do this. |
* Add shim module and support for GDAL 3 * Add GDAL 2.4 and 3.0 to build matrix * Don't upgrade deps * Don't use setup.py directly * Add PROJ to the build matrix * Add proj build script * Update GDAL build script * Allow travis to wait for GDAL build * Wait 30 on GDAL build * Increase wait to 40 and make jobs to 4 * Remove wait so we can see what the problem is * Unsilence make * Remove proj apt package * set PROJ_LIB correctly * Call OSRFixup for GDAL 1 and 2 * Cast open options for GDALOpenEx * Add missing OSRFixup declarations
""" | ||
if isinstance(self.session, WritingSession): | ||
return self.session.set_tags(tags, ns=ns) | ||
raise RuntimeError("Unable to set tags as not in writing mode.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@snowman2 here I think we should begin with
if not isinstance(self.session, WritingSession):
raise ...
and then I think we should consider a custom error. If we open a Python (3) file to read and then call its write method we get an io.UnsupportedOperation. We should add something like that to fiona.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a preference for the exception name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a couple changes to suggest. Also, would you be willing to re-target this at the maint-1.9 branch?
Finally getting back to this. It's still relevant and good and I think it should be able to merge fairly cleanly with maint-1.9. |
Didn't see dropdown to change branches. Moved to #821 |
issue #713
@sgillies here is the first iteration.