feat!: adapt core and storage clients to the FLAME Hub 0.13.0 API - #129
Open
tada5hi wants to merge 1 commit into
Open
feat!: adapt core and storage clients to the FLAME Hub 0.13.0 API#129tada5hi wants to merge 1 commit into
tada5hi wants to merge 1 commit into
Conversation
The FLAME Hub renamed its entity/HTTP-API vocabulary from snake_case to camelCase (PrivateAIM/hub@de5770437, "refactor!: camelCase entity properties, domain types & HTTP API", #1806) and wrapped every entity record response in a data/meta envelope (PrivateAIM/hub@a509e932c, "feat!: record data/meta envelope, meta.schema discovery and dependency bump", #1801). Both ship in 0.13.0. Its database column names, permission names, OAuth2/OIDC parameters and token introspection payloads stay snake_case. camelCase Mirror the rename on the CoreClient and the StorageClient exactly as c356a64 did for the AuthClient: model fields, method keyword arguments and the rapiq filter/sort/field/include vocabulary move to camelCase (display_name -> displayName, realm_id -> realmId, master_image -> masterImage, build_status -> buildStatus, group_virtual_path -> groupVirtualPath, the *_realm_id fields -> *RealmId, ...). A pydantic field name is the wire key, so renaming the field is the whole change; there are no aliases. Four parameters deliberately keep snake_case because they name no hub field -- node_type, bucket_type and registry_project_type disambiguate a hub field called `type`, and is_entrypoint disambiguates one called `root`. So do the transport level ones (base_url, chunk_size, UploadFile's file_name/content_type) and the whole _auth_flows OAuth2 surface (client_id, client_secret, grant_type). Two hard-coded filter keys moved with the models: delete_analysis_logs and delete_analysis_node_logs built filter[analysis_id] / filter[node_id]. rapiq drops an unknown filter key silently rather than rejecting it, so against 0.13.0 the stale keys would have widened both DELETEs to an unfiltered selection. Record envelope Hub wraps records as {"data": ..., "meta": ...} but keeps a handful of endpoints flat, so unlike authup the envelope is per-endpoint rather than per-client. _create_resource, _get_single_resource and _update_resource take a new `envelope` keyword defaulting to True; the five credential routes (get_node_registry_credentials, get/update_node_client_credentials, get/update_analysis_client_credentials) pass envelope=False. send_analysis_command reads the body itself and now unwraps it too. CoreClient and StorageClient override _unwrap_single_resource. The three overrides now delegate to a shared unwrap_enveloped_resource() helper, which names the required service version in the ValueError so an outdated deployment is recognizable from the exception alone. BaseClient keeps returning the body unchanged. _delete_resource is unaffected: it never reads the body, and hub still answers DELETE with 202. Collection responses were already validated as an envelope by ResourceList, and the bucket upload endpoint answers with a collection rather than a record, so it stays as it is. BREAKING CHANGE: CoreClient and StorageClient require FLAME Hub 0.13.0 or newer. Their model attributes, method keyword arguments and rapiq filter/sort/field/include keys are now camelCase.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
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.
Adapts
CoreClientandStorageClientto FLAME Hub 0.13.0, which landed two breaking changes together:refactor!: camelCase entity properties, domain types & HTTP APIfeat!: record data/meta envelope, meta.schema discovery and dependency bumpStacked on #128, whose
_unwrap_single_resourcehook this builds on. Review/merge #117 → #128 → this.camelCase
Same treatment
AuthClientgot in #117: model fields, method keyword arguments and the rapiqfilter/sort/fields/includevocabulary all move to camelCase. A pydantic field name is the wire key, so renaming the field is the whole change — no aliases, no compatibility shim, matching hub, which shipped none either.What deliberately stays snake_case
node_type,bucket_type,registry_project_typetype— there is no hub field by these namesis_entrypointrootbase_url,chunk_size,UploadFile.file_name/content_type_auth_flows(client_id,client_secret,grant_type, …)ErrorResponse.status_codeAliasChoicesTwo filter keys that would have failed silently
delete_analysis_logsanddelete_analysis_node_logsbuiltfilter[analysis_id]/filter[node_id]as string literals. rapiq drops an unknown filter key rather than rejecting it, so against 0.13.0 these would not have raised — they would have widened bothDELETEs to an unfiltered selection. Renamed tofilter[analysisId]/filter[nodeId].Record envelope
Hub wraps records as
{"data": …, "meta": …}but keeps a handful of endpoints deliberately flat, so unlike authup the envelope is per-endpoint, not per-client. An unconditional client-level override would have broken the credential routes._create_resource,_get_single_resourceand_update_resourcetake a newenvelopekeyword, defaulting toTrue.envelope=False:get_node_registry_credentials,get/update_node_client_credentials,get/update_analysis_client_credentials. Verified against hub's controllers, which declarePromise<ClientCredentials>/Promise<RegistryCredentials>with no envelope.send_analysis_commandreads the body itself rather than going through the helpers;POST /analyses/:id/commandis enveloped (Promise<EntityRecordResponse<Analysis>>), so it now unwraps too.CoreClientandStorageClientoverride_unwrap_single_resource. All three overrides now delegate to a sharedunwrap_enveloped_resource()helper that names the required service version in theValueError, so an outdated deployment is recognizable from the exception alone.BaseClientstill returns the body unchanged._delete_resourceneeded no change — it never reads the body, and hub still answersDELETEwith202. Collection responses were already validated as an envelope byResourceList, andPOST /buckets/:id/uploadanswers with a collection rather than a record, so it is untouched.Downstream
PrivateAIM/node-hub-api-adapterpinsflame-hub-client==0.4.1and declares FastAPIresponse_model=list[Project]against these models, so bumping it propagates the camelCase field names to its own wire shape with no model changes on its side. That in turn is what letsPrivateAIM/node-uiconsume@privateaim/core-kittypes directly instead of generating them from a checked-inswagger.json.Testing
pytest -m "not integration"— 80 passed (10 new).ruff checkandruff format --checkclean. Integration tests need a live 0.13.0 Hub and have not been run here.New unit coverage in
tests/test_base_client.py: core/storage unwrapping across 200/201/202, rejection of a flat body with the version-namedValueError, the credential routes staying flat, list responses untouched, andsend_analysis_commandgoing through the hook.Not included
The models are missing some fields hub 0.13.0 returns —
Node.robotId,Project.clientId/robotId,AnalysisBucketFile.robotId. Pre-existing (pydantic ignores extras), unrelated to this rename, and left for a follow-up. One stalerobot_idline was dropped from the README dump, which theNodemodel never actually emitted.