Skip to content
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

Use cql2-json for pgstac #513

Merged
merged 3 commits into from
Nov 11, 2024
Merged

Use cql2-json for pgstac #513

merged 3 commits into from
Nov 11, 2024

Conversation

gadomski
Copy link
Member

@gadomski gadomski commented Nov 3, 2024

@hrodmn can you try out this branch on your side? pgstac doesn't accept cql2-text AFAICT so I added an auto-conversion to cql2-json.

Closes

Includes a sidecar stacrs pgstac load command.

@gadomski gadomski self-assigned this Nov 3, 2024
@gadomski gadomski marked this pull request as draft November 4, 2024 16:23
@gadomski gadomski marked this pull request as ready for review November 4, 2024 18:53
@hrodmn
Copy link

hrodmn commented Nov 10, 2024

@gadomski thanks for taking a look! I am having trouble setting up a local installation of this branch (see details below), but I think your diagnosis of the problem is correct. In stac-fastapi-pgstac all GET requests with cql2-text filters get converted to cql2-json before they are passed to the pgstac search function.

installation error

Sadly I don't know where to start on this error 😆

henry@quercus:~/workspace/stac-utils/stac-rs/python$ uv sync
Resolved 142 packages in 3ms
error: Failed to prepare distributions
  Caused by: Failed to build `stacrs @ file:///home/henry/workspace/stac-utils/stac-rs/python`
  Caused by: Build backend failed to build editable through `build_editable` (exit status: 1)

[stdout]
Running `maturin pep517 build-wheel -i /home/henry/.cache/uv/builds-v0/.tmp4OsYVt/bin/python --compatibility off --editable`

[stderr]
🔗 Found pyo3 bindings
🐍 Found CPython 3.12 at /home/henry/.cache/uv/builds-v0/.tmp4OsYVt/bin/python
📡 Using build options features from pyproject.toml
   Compiling pyo3-build-config v0.22.6
   Compiling geoarrow v0.3.0
   Compiling pyo3-macros-backend v0.22.6
   Compiling pyo3-ffi v0.22.6
   Compiling pyo3 v0.22.6
   Compiling pyo3-macros v0.22.6
   Compiling pythonize v0.22.0
error[E0275]: overflow evaluating the requirement `<impl GeometryTrait<T = f64> as geo_traits::geometry::GeometryTrait>::GeometryCollection<'_>: geo_traits::geometry_collection::GeometryCollectionTrait`
    |
    = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`geoarrow`)
note: required for `GeometryCollectionIterator<'_, f64, <... as GeometryCollectionTrait>::ItemType<'_>, ...>` to implement `Iterator`
   --> /home/henry/.cargo/registry/src/index.crates.io-6f17d22bba15001f/geoarrow-0.3.0/src/geo_traits/iterator.rs:39:15
    |
37  |                   ItemType: 'a + $item_trait<T = T>,
    |                                              ----- unsatisfied trait bound introduced here
38  |                   G: $self_trait<T = T, ItemType<'a> = ItemType>,
39  |               > Iterator for $struct_name<'a, T, ItemType, G>
    |                 ^^^^^^^^     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
109 | / impl_iterator!(
110 | |     GeometryCollectionIterator,
111 | |     GeometryCollectionTrait,
112 | |     GeometryTrait,
113 | |     geometry_unchecked
114 | | );
    | |_- in this macro invocation
    = note: required for `GeometryCollectionIterator<'_, f64, <... as GeometryCollectionTrait>::ItemType<'_>, ...>` to implement `IntoIterator`
    = note: the full name for the type has been written to '/home/henry/workspace/stac-utils/stac-rs/target/release/deps/geoarrow-cd11adfc937de9f7.long-type-10257270469153106537.txt'
    = note: consider using `--verbose` to print the full type name to the console
    = note: the full name for the type has been written to '/home/henry/workspace/stac-utils/stac-rs/target/release/deps/geoarrow-cd11adfc937de9f7.long-type-10257270469153106537.txt'
    = note: consider using `--verbose` to print the full type name to the console
    = note: this error originates in the macro `impl_iterator` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0275`.
error: could not compile `geoarrow` (lib) due to 1 previous error
💥 maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_ENVIRONMENT_SIGNATURE="cpython-3.12-64bit" PYO3_PYTHON="/home/henry/.cache/uv/builds-v0/.tmp4OsYVt/bin/python" PYTHON_SYS_EXECUTABLE="/home/henry/.cache/uv/builds-v0/.tmp4OsYVt/bin/python" "cargo" "rustc" "--features" "pyo3/extension-module" "--message-format" "json-render-diagnostics" "--manifest-path" "/home/henry/workspace/stac-utils/stac-rs/python/Cargo.toml" "--release" "--lib"`
Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/home/henry/.cache/uv/builds-v0/.tmp4OsYVt/bin/python', '--compatibility', 'off', '--editable'] returned non-zero exit status 1

@gadomski
Copy link
Member Author

I am having trouble setting up a local installation of this branch (see details below)

Try keeping your Rust at 1.81 or below, it's a bug in geoarrow-rs:

rustup override set 1.81  # to override for your project directory

@hrodmn
Copy link

hrodmn commented Nov 11, 2024

Try keeping your Rust at 1.81 or below, it's a bug in geoarrow-rs:

rustup override set 1.81  # to override for your project directory

That solved the installation problem!

As far as I can tell the communication with pgstac is working correctly now (based on pgstac logs in my docker network) but there is a new error coming from the stacrs side (I think). Whenever I provide a filter parameter I am getting a 500 response with the text "unsupported value".

I am serving the STAC API with:

$ cargo run -- serve --pgstac postgresql://username:password@localhost:5439/postgis -v

Is there a way to get more verbose logs to help trace the error?

@gadomski
Copy link
Member Author

Is there a way to get more verbose logs to help trace the error?

Yeah, you can provide more -vs, e.g. -vvv to get full debug logging. You can also set the RUST_LOG envvar, e.g.:

RUST_LOG=stac_server=debug cargo run -- serve

Apologies for none of this being documented. Happy to debug on my side as well if you want to provide your example query.

@hrodmn
Copy link

hrodmn commented Nov 11, 2024

I am seeing more logs with -vvv but I don't see the source of unsupported value.

Here is how I am setting up a query in Python (based on the new sentinel-2-l2a items):

import httpx

get_params = {
    "collection": "sentinel-2-l2a",
    "filter": "proj:epsg = 32613",
    "limit": 10,
}

get_stacrs = httpx.get(
    "http://localhost:7822/search",
    params=get_params,
)

Here is a plain ol` request URL:
http://localhost:7822/search?collection=sentinel-2-l2a&filter=proj:epsg=32613&limit=10

@gadomski
Copy link
Member Author

🙇🏼 thanks so much for kicking the tires here @hrodmn. Turns out I wasn't serializing filters correctly at all, and this helped catch that. Give it another spin — I added a bit more logging and tracing too.

@hrodmn
Copy link

hrodmn commented Nov 11, 2024

I pulled the latest changes and everything is working now! A few questions about the PR:

  • can we add the filter extension conformance class?
  • would it make sense to add some tests to the server crate or the pgstac crate?

@gadomski
Copy link
Member Author

can we add the filter extension conformance class?

Yup, good call ... I'll do that (and update the README) in another PR.

would it make sense to add some tests to the server crate or the pgstac crate?

Lol you bet ... there's some, but I hadn't been exercising filter at all.

@gadomski gadomski mentioned this pull request Nov 11, 2024
@gadomski gadomski linked an issue Nov 11, 2024 that may be closed by this pull request
@gadomski gadomski merged commit 3bd3192 into main Nov 11, 2024
17 checks passed
@gadomski gadomski deleted the server/filter branch November 11, 2024 14:57
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.

cql2 filter issues Add tracing to server, and maybe other crates
2 participants