| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
This PR improves HTTP reliability across the client by centralizing request execution through a shared requests.Session, adding consistent timeout propagation, introducing a retry policy, and hardening error/exception handling (including binary downloads and multipart uploads).
Changes:
Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file| File | Description |
|---|---|
| rspace_client/tests/inv_attachment_fs_test.py | Updates mocks/expectations to patch requests.Session.* and validate timeout/streaming behavior. |
| rspace_client/tests/http_layer_test.py | Adds new unit tests covering session, retry policy, timeout propagation, exception mapping, multipart, downloads, streaming. |
| rspace_client/tests/exceptions_test.py | Adds unit tests for exception hierarchy and _handle_response robustness. |
| rspace_client/tests/eln_fs_test.py | Updates mocks/expectations to patch requests.Session.* and validate timeout/streaming behavior. |
| rspace_client/inv/inv.py | Routes inventory uploads/icons/barcode and a connectivity check through the shared HTTP helpers/session. |
| rspace_client/exceptions.py | Introduces module-level exception hierarchy for stable public API and deprecation path. |
| rspace_client/eln/eln.py | Routes multipart uploads/imports through the shared multipart helper. |
| rspace_client/client_base.py | Adds session construction, retry policy, timeout propagation, multipart and raw-response helpers, streaming downloads, and improved error handling. |
| rspace_client/init.py | Exposes __version__ and re-exports exception types from the package root. |
| pyproject.toml | Adds responses as a dev dependency for HTTP mocking in tests. |
| .gitignore | Ignores .claude/ directory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| @@ -123,14 +222,16 @@ | |||
| headers = self._get_headers(content_type) | |||
| url = endpoint | ||
| if not endpoint.startswith(self._get_api_url()): | ||
| url = self._get_api_url() + endpoint | ||
| try: |
| def test_default_timeout_passed_to_get(self): | ||
| client = ELNClient(RSPACE_URL, "fake-api-key") | ||
| with mock.patch.object( | ||
| client._session, "get", return_value=make_response(200, json_body={}) | ||
| ) as mocked_get: | ||
| client.retrieve_api_results("/status") | ||
| self.assertEqual(DEFAULT_TIMEOUT, mocked_get.call_args.kwargs["timeout"]) | ||
|
|
| def test_constructor_timeout_passed_to_non_get(self): | ||
| client = ELNClient(RSPACE_URL, "fake-api-key", timeout=(5, 120)) | ||
| with mock.patch.object( | ||
| client._session, "request", return_value=make_response(200, json_body={}) | ||
| ) as mocked_request: | ||
| client.retrieve_api_results("/forms", request_type="POST") | ||
| self.assertEqual((5, 120), mocked_request.call_args.kwargs["timeout"]) | ||
|
|
| Before version 2.8.0 these lived as nested classes on ClientBase | ||
| (e.g. ``ClientBase.ApiError``). Those names remain as aliases of the classes | ||
| defined here and will be removed in 3.0. |
There was a problem hiding this comment.
nothing to add/comment on from my side.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR improves the reliability of the ResearchSpace Python client by strengthening error handling, introducing configurable HTTP retries/timeouts, and standardizing request handling across the library.
Changes
Why
These changes make the client more resilient to transient network failures, provide a consistent error model across all request paths, reduce memory usage during downloads, and improve the public API for consumers.
Testing