Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the clarifai model serve (local runner) flow to ensure the target app is PUBLIC when reusing an existing app, which is needed for serving public models without failing due to app visibility.
Changes:
- Import
service_pb2alongsideresources_pb2for additional gRPC request types. - When the app already exists, issue a patch request to set app visibility to PUBLIC before proceeding.
clarifai/cli/model.py
Outdated
| patch_req = service_pb2.PatchAppsRequest( | ||
| user_app_id=user.user_app_id, | ||
| apps=[resources_pb2.App(id=app_id, visibility=public_visibility)], | ||
| action='overwrite', | ||
| ) | ||
| user._grpc_request(user.STUB.PatchApps, patch_req) |
There was a problem hiding this comment.
This code manually constructs a PatchAppsRequest and calls user._grpc_request(user.STUB.PatchApps, ...), which ties the CLI to low-level gRPC details and private APIs. Since the SDK already provides User.patch_app(...), prefer calling that helper to avoid depending on the presence/signature of STUB.PatchApps and to keep request construction consistent with the rest of the client.
| patch_req = service_pb2.PatchAppsRequest( | |
| user_app_id=user.user_app_id, | |
| apps=[resources_pb2.App(id=app_id, visibility=public_visibility)], | |
| action='overwrite', | |
| ) | |
| user._grpc_request(user.STUB.PatchApps, patch_req) | |
| user.patch_app(app_id=app_id, visibility=public_visibility) |
clarifai/cli/model.py
Outdated
| apps=[resources_pb2.App(id=app_id, visibility=public_visibility)], | ||
| action='overwrite', | ||
| ) | ||
| user._grpc_request(user.STUB.PatchApps, patch_req) |
There was a problem hiding this comment.
New behavior is introduced here (patching an existing app to PUBLIC visibility) but the existing clarifai model serve CLI tests don’t assert that any patch call is made when resources already exist. Consider adding/adjusting the serve CLI unit tests to verify the app-visibility patch is invoked (and that failures are handled) to prevent regressions.
| user._grpc_request(user.STUB.PatchApps, patch_req) | |
| try: | |
| user._grpc_request(user.STUB.PatchApps, patch_req) | |
| except Exception as exc: | |
| logger.error( | |
| "Failed to update visibility to PUBLIC for app '%s': %s", | |
| app_id, | |
| exc, | |
| ) | |
| raise UserError( | |
| "Failed to update existing app visibility to PUBLIC. " | |
| "Please verify your permissions and try again." | |
| ) from exc |
Minimum allowed line rate is |
Pull request overview
This PR updates the
clarifai model serve(local runner) flow to ensure the target app is PUBLIC when reusing an existing app, which is needed for serving public models without failing due to app visibility.