-
Notifications
You must be signed in to change notification settings - Fork 19
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
Wip/mongo #261
Conversation
@kalmarek it would be nice if we could support some advanced syntax for querying with other operators than
Can we do this via expressions or use some macro to parse this? edit: the result would be some json like dict |
The standard way of filtering collections/finding in collections is through
or
(the first argument is a predicate) so this syntax could become filter(PolymakeQuery(...), polymake_db) or if you have longer function you could use filtered_db = filter(polymake_db) do
( ... ) #the content of your PolymakeQuery
end of course a different option is to support the api of queryverse: https://github.com/queryverse/Query.jl to be honest I have no experience with databases, so I don't feel competent enough to have an opinion |
I don't think filter or findall is not applicable here, the collection is not a julia collection but just a reference to a collection on the database server. We would neet to transform the query into some JSON / BSON type (more or less a nested dict) and send this to the server via Mongoc.find. I need to read some more about Query.jl but the readme doesn't really look promising at the moment:
|
@benlorenz why not? we could add new methods to
to do what we want to; then the logic behind could be hidden in
constructs the appropriate as for Query.jl: I don't feel like implementing my own poor-mans query language (the db = Polymake.Polydb.get_db()
result = db |>
@select("Polytopes.Lattice.SmoothReflexive") |>
@filter(_.DIM == 3) |>
@filter(_.N_FACETS == 5) |>
@map(_.F_VECTOR) |>
collect looks clean and we don't have to reinvent the wheel. Of course if we can make it work ;) |
for my understanding it would optimal to construct a single |
Now it does make sense ... At the beginning I read your suggestions as we should use these functions but what you meant was probably that we should just use that syntax (which means that we still need to do most of the stuff ourselves but we have an API / Syntax to work along). The syntax of Query.jl looks nice, we need to investigate how we can overload these macros to construct the corresponding BSON dictionary and dispatch it when something like collect is called. |
@benlorenz @kalmarek do we want the objects returned by our iterator to still be the BSON document or should it already be parsed so wa have a |
I would prefer to hide the BSON from the user. We could/should keep some way to access it directly but default to convert. We might at some point store objects in the database that are not polymake objects (or not only polymake objects). |
we defer query language to #281; I'll try to have a look at the code today |
ok, I just tried this locally and i get: julia> a, s = iterate(results1.mcursor)
ERROR: BSONError: domain=15, code=13053, message=No suitable servers found (`serverSelectionTryOnce` set): [TLS handshake failed: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed calling ismaster on 'db.polymake.org:27017'] I guess it's a problem with julia not finding the correct certificates store? @benlorenz? |
Correct, one workaround might be to set SSL_CERT_FILE to a path containing a CA bundle before starting julia (or SSL_CERT_DIR to a directory with all the certificate files). There might be a bundle in I'm still looking for a better workaround. |
Another workaround is to run |
ok, the second workaround didn't work for me |
maybe the second one only works on gentoo when using the system libraries, not with the julia bundled ssl libraries. |
…i string should fix connection problems where the certificate cannot be validated
I added a fix for the certificate issue, please try without setting any environment variables. It turns out one can set the CA file via the uri and we can use the one from |
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.
in general there is still too much entanglement between getting actual data and transforming the data for the purpose of printing. get_[something]
should get it in a "lossless" format and only show
functions should produce nicely looking string out of the pieces you can get
tested it and it worked |
Co-authored-by: kalmarek <[email protected]>
Co-authored-by: kalmarek <[email protected]>
Co-authored-by: kalmarek <[email protected]>
Co-authored-by: kalmarek <[email protected]>
i just pushed a commit in which i completely re-built the our meta-info workflow. i tried to make better use of arrays and strings when generating the long info string, and replaced the recursive algorithm by another one which about does the following:
i still need to add a few comments, but otherwise every suggestion is now implemented. which leaves the following to be done: "Objects from the database know where they come from" julia> a.polyDB
ERROR: Exception occured at Polymake side:
unknown property Polytope<Rational>::polyDB at /home/jordan/.julia/dev/Polymake/deps/usr/share/polymake/perllib/Polymake/Core/BigObjectType.pm line 430.
Polymake::Core::BigObjectType::property(Polymake::Core::BigObjectType=ARRAY(0x8f4f0c8), "polyDB") called at /home/jordan/.julia/dev/Polymake/deps/usr/share/polymake/perllib/Polymake/Core/BigObjectType.pm line 710
Polymake::Core::BigObjectType::encode_descending_path(Polymake::Core::BigObjectType=ARRAY(0x8f4f0c8), "polyDB") called at /home/jordan/.julia/dev/Polymake/deps/usr/share/polymake/perllib/Polymake/Core/BigObjectType.pm line 753
Polymake::Core::BigObjectType::encode_read_request(Polymake::Core::BigObjectType=ARRAY(0x8f4f0c8), "polyDB") called at /home/jordan/.julia/dev/Polymake/deps/usr/share/polymake/perllib/Polymake/Core/BigObject.pm line 1551
Polymake::Core::BigObject::give_pv called at /home/jordan/.julia/dev/Polymake/deps/usr/share/polymake/perllib/Polymake/Core/BigObject.pm line 1568
Polymake::Core::BigObject::give(Polymake::polytope::Polytope__Rational=ARRAY(0xadf0410), "polyDB") called at -e line 0
eval {...} called at -e line 0 accessing the "_polyDB" field on a probably related, but i can not access julia> a.DIM
ERROR: Exception occured at Polymake side:
unknown property Polytope<Rational>::DIM at /home/jordan/.julia/dev/Polymake/deps/usr/share/polymake/perllib/Polymake/Core/BigObjectType.pm line 430.
Polymake::Core::BigObjectType::property(Polymake::Core::BigObjectType=ARRAY(0xaddd668), "DIM") called at /home/jordan/.julia/dev/Polymake/deps/usr/share/polymake/perllib/Polymake/Core/BigObjectType.pm line 710
Polymake::Core::BigObjectType::encode_descending_path(Polymake::Core::BigObjectType=ARRAY(0xaddd668), "DIM") called at /home/jordan/.julia/dev/Polymake/deps/usr/share/polymake/perllib/Polymake/Core/BigObjectType.pm line 753
Polymake::Core::BigObjectType::encode_read_request(Polymake::Core::BigObjectType=ARRAY(0xaddd668), "DIM") called at /home/jordan/.julia/dev/Polymake/deps/usr/share/polymake/perllib/Polymake/Core/BigObject.pm line 1551
Polymake::Core::BigObject::give_pv called at /home/jordan/.julia/dev/Polymake/deps/usr/share/polymake/perllib/Polymake/Core/BigObject.pm line 1568
Polymake::Core::BigObject::give(Polymake::polytope::Polytope__Rational=ARRAY(0xcc55f48), "DIM") called at -e line 0
eval {...} called at -e line 0
Stacktrace:
[1] give(::Polymake.BigObjectAllocated, ::String) at /home/jordan/.julia/dev/Polymake/src/perlobj.jl:45
[2] getproperty(::Polymake.BigObjectAllocated, ::Symbol) at /home/jordan/.julia/dev/Polymake/src/perlobj.jl:59 again, doing this with |
So both effects are as expected. |
Attachment support is in #288, but we will probably need to add support for the type which seems to be a plain perl hash:
In this case it can be converted to
I will think about a good way to map and convert |
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.
Other than the simple remark about types/default value argument it seems ready!
Thanks!
…otebook added to examples folder
basic support for polyDB
here a small example:
any ideas for easily resetting the iterator and how to use more complex BSON queries?