Skip to content

feat!: hub v0.13.0 - #130

Open
pbrassel wants to merge 3 commits into
mainfrom
hub-v0.13.0
Open

feat!: hub v0.13.0#130
pbrassel wants to merge 3 commits into
mainfrom
hub-v0.13.0

Conversation

@pbrassel

@pbrassel pbrassel commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added consistent camelCase field handling across API requests and responses.
    • Added support for resource metadata, including single-resource response details.
    • Improved single-resource retrieval and response handling across authentication, core, and storage APIs.
    • Added public access to shared resource and model types.
    • Bucket-file uploads now return the uploaded file details directly.
  • Documentation

    • Updated examples, API references, sample output, and coverage information.
  • Chores

    • Updated the test Hub version and configured a five-second response timeout.

tada5hi and others added 3 commits July 30, 2026 09:58
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.
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Hub response and model handling

Layer / File(s) Summary
Shared model contracts and exports
flame_hub/_base_client.py, flame_hub/_auth_client.py, flame_hub/_core_client.py, flame_hub/_storage_client.py, flame_hub/models.py, flame_hub/types.py
Shared model bases now apply camelCase aliases. Metadata, wrapped-resource, and SingleResourceResult types are defined and exported. Auth, core, and storage models use the shared bases.
Response envelope processing
flame_hub/_base_client.py
Include and field parameters use camelCase. Create, update, and single-resource responses handle data/meta envelopes. Single-resource methods can return metadata.
Client API result adoption
flame_hub/_auth_client.py, flame_hub/_core_client.py, flame_hub/_storage_client.py
Single-resource methods return SingleResourceResult. Analysis commands and bucket-file uploads parse response data directly.
Integration configuration and validation
.env.test, tests/conftest.py, tests/test_auth.py, tests/test_core.py
Tests use Hub version 0.13.0, a configurable five-second response timeout, and camelCase filter and label names.
Documentation and examples alignment
README.md, docs/clients_api.rst, docs/user_guide.rst
Examples and API documentation use camelCase fields and document _unwrap_single_resource. The coverage badge reports 97%.

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
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.20% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the v0.13.0 feature release and signals breaking changes, matching the pull request’s API and behavior updates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hub-v0.13.0

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.env.test (1)

10-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reorder the new keys to satisfy dotenv-linter.

dotenv-linter reports UnorderedKey because both keys appear after PYTEST_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

📥 Commits

Reviewing files that changed from the base of the PR and between 5712b68 and 920445e.

📒 Files selected for processing (13)
  • .env.test
  • README.md
  • docs/clients_api.rst
  • docs/user_guide.rst
  • flame_hub/_auth_client.py
  • flame_hub/_base_client.py
  • flame_hub/_core_client.py
  • flame_hub/_storage_client.py
  • flame_hub/models.py
  • flame_hub/types.py
  • tests/conftest.py
  • tests/test_auth.py
  • tests/test_core.py

Comment thread tests/conftest.py
Comment on lines +347 to +358
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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 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 tests

Repository: 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}")
PY

Repository: 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.

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.

2 participants