Skip to content

Add APIs for inferring remote endpoint type from URL. - #982

Merged
rapids-bot[bot] merged 7 commits into
rapidsai:mainfrom
TomAugspurger:tom/remote-endpoint-type-apis
Jun 24, 2026
Merged

Add APIs for inferring remote endpoint type from URL.#982
rapids-bot[bot] merged 7 commits into
rapidsai:mainfrom
TomAugspurger:tom/remote-endpoint-type-apis

Conversation

@TomAugspurger

Copy link
Copy Markdown
Contributor

In NVIDIA/cudf#22739, cudf / cudf-polars needed to infer the remote endpoint type kvikio would use for some URL, without making the HTTP request that'd come from RemoteFile::open with the default AUTO mode.

To do this, I've added a new public infer_remote_endpoint_type method, along with a python binding.

In NVIDIA/cudf#22739, cudf / cudf-polars needed
to infer the remote endpoint type kvikio would use for some URL. This adds
public APIs to kvikio to do that.
@copy-pr-bot

copy-pr-bot Bot commented Jun 22, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@TomAugspurger

Copy link
Copy Markdown
Contributor Author

/ok to test 2ca7f25

@TomAugspurger TomAugspurger added improvement Improves an existing functionality non-breaking Introduces a non-breaking change labels Jun 22, 2026
@TomAugspurger
TomAugspurger marked this pull request as ready for review June 22, 2026 17:22
@TomAugspurger
TomAugspurger requested review from a team as code owners June 22, 2026 17:22
Comment thread cpp/src/remote_handle.cpp
if (probe_s3_connectivity && type == RemoteEndpointType::S3) {
// Check connectivity for the credential-based S3 endpoint and reuse this size in
// RemoteHandle::open to avoid a second HEAD request.
probed_nbytes = endpoint->get_file_size();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since the open() function is modified again, can we just cache the file size inside the endpoint as I suggested? That is, the first time the endpoint's file size gets called, HEAD (or whatever method necessary for the endpoint in question) is performed, result cached in a std::optional<std::size_t> _file_size, and subsequent file size query just reuses the cached value.

This way, this PR alone will reduce the cudf-polars per-file HEAD request to 1, if I'm not missing anything.

@TomAugspurger TomAugspurger Jun 22, 2026

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.

Personally, I'm not comfortable making something like size part of the data model for RemoteHandle without also including something like an etag to ensure that we aren't operating on a stale file. By using size, cudf-polars is accepting that risk, but it's unavoidable for now; and it's at least no than what would currently happen if a file changes mid-query. But putting it into the kvikio API is a bit riskier I think.

And, at least from the cudf-polars side, we'll temporarily use kvikio to get the file size exactly once per file. But in the medium term we'll be able to get that information from cudf-polars; either way, we'll be able to provide it the size in all subsequent operations.

Finally, I don't think this would directly help cudf-polars since in our current design we don't store RemoteHandle instances. We'll just store the plc.io.types.SourceInfo and FileMetadata.

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.

Does this sound OK @kingcrimsontianyu? I'd like to merge this today if possible, so we can use it in NVIDIA/cudf#22739

@madsbk madsbk left a comment

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.

Looks good

Comment thread cpp/src/remote_handle.cpp Outdated
Comment thread cpp/include/kvikio/remote_handle.hpp Outdated
Comment thread cpp/src/remote_handle.cpp Outdated
Comment thread cpp/src/remote_handle.cpp Outdated
*
* @param url The URL of the remote file.
* @return The inferred endpoint type.
*/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we need to document the difference between this utility function and the open function, that given a URL valid for both S3 private and public endpoints, this function will always return the private endpoint type, and that it is not possible for us to disambiguate S3 private and public endpoints from a URL alone.
Then in the cudf PR NVIDIA/cudf#22739, we may document that known file size + URL without S3 credential is not supported.

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.

I added a note in b752f5a.

But I'd like to get away from "public" vs. "private" URLs entirely. It'd much prefer to just deal with some URL and an authorization method (possibly a chained authorization method that tries multiple).

Comment thread cpp/src/remote_handle.cpp
Comment thread cpp/src/remote_handle.cpp

@kingcrimsontianyu kingcrimsontianyu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lgtm!
Nit: suggested using structured binding in place of tie.

@TomAugspurger

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 3d5af21 into rapidsai:main Jun 24, 2026
64 checks passed
@TomAugspurger
TomAugspurger deleted the tom/remote-endpoint-type-apis branch June 24, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improves an existing functionality non-breaking Introduces a non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants