Add authentication support to URL fetcher for SDH-protected URLs#647
Merged
Add authentication support to URL fetcher for SDH-protected URLs#647
Conversation
Co-authored-by: sainivedh <39689508+sainivedh@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Runner utils doesn't support SDH protected url
Add authentication support to URL fetcher for SDH-protected URLs
Jun 25, 2025
Contributor
|
Fix the linting errors |
Co-authored-by: sainivedh <39689508+sainivedh@users.noreply.github.com>
Contributor
Author
Fixed linting errors by running ruff format to ensure code conforms to project style guidelines. All files now pass linting checks. (commit: 8c46e0e) |
sainivedh
reviewed
Jun 25, 2025
Contributor
sainivedh
left a comment
There was a problem hiding this comment.
This is still incomplete, we call ensure_urls_downloaded in model_runner.py, model_servicer.py
Co-authored-by: sainivedh <39689508+sainivedh@users.noreply.github.com>
Contributor
Author
Fixed the incomplete implementation by adding authentication support to both ModelRunner and ModelServicer. All ensure_urls_downloaded calls now pass the auth_helper parameter. (commit: a50027b) |
Minimum allowed line rate is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The URL fetcher in
clarifai/runners/utils/url_fetcher.pywas failing when downloading SDH-protected URLs because it didn't pass any authentication headers. This PR adds optional authentication support while maintaining full backward compatibility.Problem
When downloading URLs that require authentication (like SDH-protected URLs), the URL fetcher would fail because
fsspec.open()was called without any authorization headers:Solution
Added optional
auth_helperparameter to URL fetcher functions that converts Clarifai authentication metadata to HTTP headers compatible with fsspec:Changes Made
auth_helperparameter toensure_urls_downloaded(),download_input(), and_download_input_data()_get_auth_kwargs()helper that convertsClarifaiAuthHelper.metadatato fsspec-compatible HTTP headersfsspec.open()calls to include authentication headers when availableAuthentication Support
The implementation supports both authentication methods:
authorization: Key <token>x-clarifai-session-token: <token>Headers are properly formatted for fsspec's aiohttp backend using the
client_kwargs.headersstructure.Backward Compatibility
All existing code continues to work without changes:
Testing
Added comprehensive unit tests that verify:
Fixes #646.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
example.compython /tmp/test_auth_functionality.py(dns block)httpbin.orgpython /tmp/test_fsspec_headers.py(dns block)python -m pytest tests/REDACTEDs/test_url_fetcher.py::test_ensure_urls_downloaded_with_auth_backward_compatibility -v(dns block)python -m pytest tests/REDACTEDs/test_url_fetcher.py -v(dns block)public-url.compython /tmp/url_fetcher_auth_example.py(dns block)samples.clarifai.compython -m pytest tests/REDACTEDs/test_url_fetcher.py -v(dns block)your-sdh-protected-url.compython /tmp/url_fetcher_auth_example.py(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.