-
Notifications
You must be signed in to change notification settings - Fork 0
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
Geopackage support #55
Conversation
…reate table afterwards
* Apply pre-conversion modifications to temporary database * Add docstring
…ma into margriet_45_geopackage
15a5144
to
21b0e85
Compare
Tests falen voor oude python en ubuntu
Gerelateerde problemen (allemaal qgis): |
21bf28c
to
fb892f0
Compare
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.
Overall: looks very good!
I've added some comments with some (minor) things to address/look at.
class ThreediDatabase: | ||
def __init__(self, path, echo=False): | ||
self.path = path | ||
self._path = path |
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.
self._path = path | |
self.path = path if isinstance(path, Path) else Path(path) |
Is shorter and allows to drop the path property and @path.setter property
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.
This breaks the current working of _path
and path
. I introduced the setter to control the type of ThreediDatabase.path
because it is set from multiple libraries, sometimes with a Path and sometimes with a string. With this implementation self._path
is always a string and self.path
will return a path; and setting ThreediDatabase.path
will ensure that both self._path
and self.path
are set properly.
It would be nicer to just have self.path
and make is a Path
(and add type hints). However, that also involves threedi-api; and I feel that this PR is complex enough as it is.
Note that self._path
is now also cast to a string in the constructor 9fd2fe6.
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.
Ok, I saw in the test that a Path instance was passed as parameter to ThreediDatabase(xxxx) # constructor
My suggestion also works if a string is passed. It's just converted into a Path.
The only thing that is not backwards-compatible is:
- db = ThreediDatabase("/tmp/blaat.gpkg") and directly getting db.path as a string. (note: same new behaviour as your property introduced)
- db = ThreediDatabase("/tmp/no_really_the.gpkg") ; db.path = "/tmp/the_real.gpkg". This is going to crash, but can be fixed by "path = self.path if isinstance(self.path, Path) else Path(self.path)" in the get_engine method.
Maybe 2 is actually the better solution. Convert it there to a Path instance if it not already the case:
path = self.path if isinstance(self.path, Path) else Path(self.path)
The property, setter and self._path can all be dropped and self.path stays exactly the same as what the user has put into the class constructor. And changing it after initialisation also works.
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.
Modified in d5f8545. Note that using a Path
in get_engine
is necessary to handle the in-memory sqlite. This is because str(Path(""))
and str("")
don't match, but Path("")
and Path(str(""))
do.
Co-authored-by: jpprins1 <jpprins1@gmail.com>
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.
👍
Support geopackage sqlite dialect:
.gpkg
) files, note that per specification geopackes are required to have this extensionschema.upgrade(convert_to_geopackage=True)
Note that the default settings is
schema.upgrade(convert_to_geopackage=False)
. Hence without any changes tothreedi-api
the geopackage will not be used.Note2 geopackage conversion requires
ogr2ogr
>= 3.4, which is part ofgdal-bin
. Ifogr2ogr
is not properly installed or a too old version is present, the conversion is not done and a warning is raised.Local tests can be done by installing
threedi-schema==0.219.2.dev1