feat!: hub v0.13.0 - #130
Conversation
authup wraps every single-record entity response in a data/meta envelope since 1.0.0-beta.57 (authup/authup@00f2f4c3a, "feat: query-capability discovery via meta.schema + entity record response envelope", #3332). getOne, create, update and delete of all entity controllers now respond with {"data": ..., "meta": ...} instead of the entity itself, mirroring the envelope that collection responses have always used. meta carries response-scoped extras such as the queryable schema of the endpoint. The OAuth2 protocol surface (token, introspect, revoke, ...) stays flat, so _auth_flows is unaffected. Add the _unwrap_single_resource hook to BaseClient, which returns the response body unchanged, and call it in _create_resource, _get_single_resource and _update_resource. AuthClient overrides the hook to return the data property and raises a ValueError naming the required authup version if the property is absent. The FLAME Hub core and storage services keep responding with the bare entity, so CoreClient and StorageClient are untouched. Collection responses were already validated as an envelope by ResourceList. BREAKING CHANGE: AuthClient requires authup 1.0.0-beta.57 or newer.
The Hub v0.13.0 API expects camel case attribute names and envelopes most of its responses like `{"data": ..., "meta": ...}`.
BREAKING CHANGE: Models are serialized with camel case attribute names.
📝 WalkthroughWalkthroughThe client now centralizes Pydantic camelCase configuration, supports wrapped single-resource responses with optional metadata, updates client return types, parses response data consistently, and aligns tests, fixtures, examples, and documentation with the Hub API. ChangesHub response and model handling
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant ClientCaller
participant BaseClient
participant HubAPI
ClientCaller->>BaseClient: request single resource
BaseClient->>HubAPI: send camelCase query parameters
HubAPI-->>BaseClient: return data/meta envelope or direct resource
BaseClient-->>ClientCaller: return resource or resource/metadata tuple
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
.env.test (1)
10-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReorder the new keys to satisfy
dotenv-linter.
dotenv-linterreportsUnorderedKeybecause both keys appear afterPYTEST_STORAGE_BASE_URL. Move them before that key to avoid lint warnings.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.env.test around lines 10 - 11, Move PYTEST_HUB_VERSION and PYTEST_RESPONSE_TIMEOUT before PYTEST_STORAGE_BASE_URL in the environment configuration, preserving their values and ensuring the keys follow dotenv-linter’s expected ordering.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/conftest.py`:
- Around line 347-358: Update the auth_client, core_client, and storage_client
fixtures to retain each created client, yield the corresponding wrapper, and
close the injected HTTP client in a finally block after yield. Apply identical
teardown handling to all three session-scoped fixtures.
---
Nitpick comments:
In @.env.test:
- Around line 10-11: Move PYTEST_HUB_VERSION and PYTEST_RESPONSE_TIMEOUT before
PYTEST_STORAGE_BASE_URL in the environment configuration, preserving their
values and ensuring the keys follow dotenv-linter’s expected ordering.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 5ada573b-69c5-4fb3-aea4-182f4a5a8c9d
📒 Files selected for processing (13)
.env.testREADME.mddocs/clients_api.rstdocs/user_guide.rstflame_hub/_auth_client.pyflame_hub/_base_client.pyflame_hub/_core_client.pyflame_hub/_storage_client.pyflame_hub/models.pyflame_hub/types.pytests/conftest.pytests/test_auth.pytests/test_core.py
| def auth_client(password_auth, auth_base_url, response_timeout): | ||
| yield AuthClient(client=httpx.Client(base_url=auth_base_url, auth=password_auth, timeout=response_timeout)) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def core_client(password_auth, core_base_url): | ||
| yield CoreClient(base_url=core_base_url, auth=password_auth) | ||
| def core_client(password_auth, core_base_url, response_timeout): | ||
| yield CoreClient(client=httpx.Client(base_url=core_base_url, auth=password_auth, timeout=response_timeout)) | ||
|
|
||
|
|
||
| @pytest.fixture(scope="session") | ||
| def storage_client(password_auth, storage_base_url): | ||
| yield StorageClient(base_url=storage_base_url, auth=password_auth) | ||
| def storage_client(password_auth, storage_base_url, response_timeout): | ||
| yield StorageClient(client=httpx.Client(base_url=storage_base_url, auth=password_auth, timeout=response_timeout)) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
rg -n -C 5 'class BaseClient|def close|client\.close|httpx\.Client' flame_hub testsRepository: PrivateAIM/hub-python-client
Length of output: 13337
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
# Inspect BaseClient client ownership/teardown and the relevant fixture code.
sed -n '460,560p' flame_hub/_base_client.py
printf '\n--- tests/conftest.py fixtures ---\n'
sed -n '330,365p' tests/conftest.py
# Behavioral model: show whether BaseClient stores injected httpx clients and whether it defines client/close hooks.
python3 - <<'PY'
import ast
from pathlib import Path
path = Path("flame_hub/_base_client.py")
tree = ast.parse(path.read_text())
for node in tree.body:
if isinstance(node, ast.ClassDef) and node.name == "BaseClient":
print("BaseClient methods:")
for m in node.body:
if isinstance(m, ast.FunctionDef):
print(f" {m.name} ({m.lineno}-{m.end_lineno})")
init = next((m for m in node.body if isinstance(m, ast.FunctionDef) and m.name == "__init__"), None)
if init:
print("BaseClient.__init__ relevant text:")
lines = path.read_text().splitlines()
for i in range(init.lineno-1, min(init.end_lineno, len(lines))):
if "client" in lines[i].lower() or "self._client" in lines[i] or "httpx.Client" in lines[i]:
print(f" {i+1}: {lines[i]}")
print("\nAll BaseClient methods named close/client/_close:")
for node in tree.body:
if isinstance(node, ast.ClassDef):
for m in node.body:
if isinstance(m, ast.FunctionDef) and m.name in {"close", "_close", "client"}:
print(f" {node.name}.{m.name} at {m.lineno}")
PYRepository: PrivateAIM/hub-python-client
Length of output: 5979
Close the injected session-scoped HTTP clients in fixture teardown.
auth_client, core_client, and storage_client each create httpx.Client instances and yield without cleanup. BaseClient stores the injected client in _client but does not close it, so close the fixture-created clients in finally blocks after yield.
Proposed teardown pattern
def auth_client(password_auth, auth_base_url, response_timeout):
- yield AuthClient(client=httpx.Client(base_url=auth_base_url, auth=password_auth, timeout=response_timeout))
+ http_client = httpx.Client(base_url=auth_base_url, auth=password_auth, timeout=response_timeout)
+ try:
+ yield AuthClient(client=http_client)
+ finally:
+ http_client.close()Apply the same pattern to core_client and storage_client.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/conftest.py` around lines 347 - 358, Update the auth_client,
core_client, and storage_client fixtures to retain each created client, yield
the corresponding wrapper, and close the injected HTTP client in a finally block
after yield. Apply identical teardown handling to all three session-scoped
fixtures.
Summary by CodeRabbit
New Features
Documentation
Chores