Skip to content

Conversation

@carlosgjs
Copy link
Collaborator

@carlosgjs carlosgjs commented Dec 17, 2025

Summary

This pull request introduces a new API endpoint to support the registration of ML pipelines for a project, primarily for integration with V2 ML processing services. It also changes the ProcessingService.endpoint_url to be nullable.

New API endpoint for pipeline registration:

  • Added a new pipelines POST action to the project viewset in ami/main/api/views.py, allowing V2 ML processing services to register available pipelines for a project. The endpoint parses the payload using the AsyncPipelineRegistrationRequest.

Closes #1086

Checklist

  • I have tested these changes appropriately.
  • I have added and/or modified relevant tests.
  • I updated relevant documentation or comments.
  • I have verified that this PR follows the project's coding standards.
  • Any dependent changes have already been merged to main.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added pipeline registration endpoint to enable projects to register and manage pipelines.
    • Processing services now support pull mode operation (no endpoint URL required).
  • Bug Fixes

    • Improved handling when processing services lack endpoint URLs.
  • Tests

    • Added test coverage for pipeline registration workflows and pull mode scenarios.
  • Chores

    • Updated database schema to support optional endpoint configuration.

@netlify
Copy link

netlify bot commented Dec 17, 2025

Deploy Preview for antenna-preview canceled.

Name Link
🔨 Latest commit c426834
🔍 Latest deploy log https://app.netlify.com/projects/antenna-preview/deploys/698237a4fd1df00008b367ba

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

📝 Walkthrough

Walkthrough

This PR implements pipeline registration for asynchronous processing services by introducing a new POST /projects/{id}/pipelines API endpoint. The endpoint accepts pipeline configurations from service workers, creates or associates a ProcessingService with the project, and registers the pipelines. Supporting changes make ProcessingService.endpoint_url optional to enable pull-mode (worker-initiated) services without predefined endpoints.

Changes

Cohort / File(s) Summary
Pipeline Registration API Endpoint
ami/main/api/views.py
Added new pipelines method to ProjectViewSet handling POST requests with AsyncPipelineRegistrationRequest, creating/associating ProcessingService if needed, and invoking create_pipelines with project scope restriction. Returns PipelineRegistrationResponse with HTTP 400 on validation errors.
Authorization & Permissions
ami/main/models.py
Extended check_custom_permission to handle "pipelines" action, requiring ProjectManager role (or owner/superuser) before default fallback logic.
Data Model Updates
ami/ml/models/processing_service.py, ami/ml/migrations/0026_make_processing_service_endpoint_url_nullable.py
Made endpoint_url nullable and optional on ProcessingService. Added last_checked_latency field. Updated str, get_status, and get_pipeline_configs methods to handle None endpoint_url gracefully (pull-mode services).
Request/Response Schemas
ami/ml/schemas.py
Added AsyncPipelineRegistrationRequest model with processing_service_name and pipelines fields. Updated ProcessingServiceStatusResponse.endpoint_url to optional (str | None with default None).
Service Task Updates
ami/ml/tasks.py
Added guard in check_processing_services_online to skip services with null endpoint_url, logging a warning and continuing iteration.
API Integration Tests
ami/main/tests.py
Added TestProjectPipelinesAPI suite with 5 test methods validating pipeline creation with new/existing services, unauthorized access (403), and invalid payload handling (400).
Service Unit Tests
ami/ml/tests.py
Added 3 test methods to TestProcessingServiceAPI validating ProcessingService behavior with null endpoint_url: creation, status retrieval, and pipeline config listing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

backend, ml

Suggested reviewers

  • mihow

Poem

🐰 A new pathway opens bright,
Where workers whisper pipelines at night,
No endpoints need be set in stone,
Pull mode services call it home,
Async dreams now take their flight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'PSV2: endpoint to register pipelines' clearly and concisely summarizes the main change—adding a new endpoint for pipeline registration in the V2 processing service context.
Description check ✅ Passed The description includes a summary, list of changes, related issues, and a completed checklist. However, it lacks detailed description sections on how changes solve the issue, testing instructions, and deployment notes.
Linked Issues check ✅ Passed The PR successfully implements the objective from issue #1086: it adds a new POST endpoint at /projects/{id}/pipelines that allows V2 services to register supported pipelines, supporting the pull-model async processing service workflow.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the pipeline registration endpoint and supporting infrastructure. Making endpoint_url nullable aligns with supporting pull-model services without endpoints.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


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 and usage tips.

@carlosgjs carlosgjs changed the title RFC: V2 endpoint to register pipeliens RFC: V2 endpoint to register pipelines Jan 13, 2026
@carlosgjs carlosgjs requested a review from mihow January 13, 2026 18:09
@netlify
Copy link

netlify bot commented Jan 16, 2026

👷 Deploy request for antenna-ssec pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit c426834

@carlosgjs carlosgjs marked this pull request as ready for review January 21, 2026 22:46
Copilot AI review requested due to automatic review settings January 21, 2026 22:46
@carlosgjs carlosgjs changed the title RFC: V2 endpoint to register pipelines PSV2: endpoint to register pipelines Jan 21, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@ami/main/api/views.py`:
- Around line 240-262: The current logic in the view returns a 400 when a
ProcessingService (found via
ProcessingService.objects.filter(name=parsed.processing_service_name).first())
is already associated with the project, which prevents idempotent
re-registration; update the branch handling the existing processing_service so
that if project is already in processing_service.projects.all() you do not
return Response(status=400) but simply continue (no-op) and allow the endpoint
to proceed (e.g., log an info/debug message) — ensure you keep the
processing_service.projects.add(project)/save() when association is missing, and
remove the early return that blocks subsequent pipeline registration.

In `@ami/ml/schemas.py`:
- Around line 326-327: The endpoint_url annotation is optional but currently
still required because it has no default; update the schema so endpoint_url has
an explicit default (e.g., set endpoint_url to None or use Field(default=None)
if this is a Pydantic model) so parsing succeeds when senders omit it—modify the
endpoint_url declaration (near the latency: float field) to include the default
None.

In `@ami/ml/tasks.py`:
- Around line 112-114: The current check only skips when service.endpoint_url is
None but still allows empty strings; update the conditional around
service.endpoint_url in the loop (the block that calls logger.warning and
continue) to treat None, empty, or whitespace-only values as missing — e.g.,
ensure you test both falsy and stripped emptiness (safe-check to avoid calling
.strip() on None) so that logger.warning(f"Processing service {service} has no
endpoint URL, skipping.") is used and the loop continues for None/"", or
whitespace-only endpoint_url.
🧹 Nitpick comments (1)
ami/main/tests.py (1)

3457-3459: Consider disabling default fixtures for these API tests.
create_defaults=True builds extra related objects these tests don’t use; turning it off keeps setup lean.

♻️ Suggested change
-        self.project = Project.objects.create(name="Test Project", owner=self.user, create_defaults=True)
-        self.other_project = Project.objects.create(name="Other Project", owner=self.other_user, create_defaults=True)
+        self.project = Project.objects.create(name="Test Project", owner=self.user, create_defaults=False)
+        self.other_project = Project.objects.create(name="Other Project", owner=self.other_user, create_defaults=False)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request introduces a new API endpoint for V2 ML processing services to register pipelines with projects in "pull mode" (without requiring an endpoint URL). The changes enable processing services to push pipeline configurations to Antenna rather than Antenna pulling them from a service endpoint.

Changes:

  • Added a new POST endpoint /api/v2/projects/{id}/pipelines/ for pipeline registration
  • Made ProcessingService.endpoint_url nullable to support pull-mode services
  • Updated ProcessingService methods to handle null endpoint URLs gracefully

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
ami/main/api/views.py Added new pipelines action to ProjectViewSet for receiving pipeline registrations from V2 services
ami/main/models.py Added permission check for "pipelines" action requiring ProjectManager role
ami/ml/models/processing_service.py Made endpoint_url nullable and updated get_status() and get_pipeline_configs() to handle null values
ami/ml/schemas.py Made endpoint_url nullable in ProcessingServiceStatusResponse and added AsyncPipelineRegistrationRequest schema
ami/ml/migrations/0026_make_processing_service_endpoint_url_nullable.py Database migration to make endpoint_url nullable
ami/ml/tasks.py Added check to skip processing services without endpoint URLs in periodic status check
ami/ml/tests.py Added comprehensive tests for null endpoint_url handling
ami/main/tests.py Added test suite for the new pipelines API endpoint
requirements/base.txt Added explanatory comment about psycopg binary vs non-binary versions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@ami/ml/schemas.py`:
- Around line 339-345: Update the inaccurate docstring on
AsyncPipelineRegistrationRequest to reference AsyncPipelineRegistrationRequest
(not PipelineRegistrationResponse) and clearly state it represents the async
callback payload containing processing results; rename the output-oriented model
PipelineRegistrationResponse to a more generic name like
PipelineProcessingResult (or create a new PipelineProcessingResult model) and
adjust its fields (timestamp, success, error, pipelines_created,
algorithms_created) to be output/result-oriented (optional or excluded from
required input validation) so the
AsyncPipelineRegistrationRequest.pipeline_response type reflects a result object
rather than required caller-supplied output fields; update all references to
PipelineRegistrationResponse to the new name (or to the new model) including the
AsyncPipelineRegistrationRequest definition and related validation/serialization
logic.

carlosgjs and others added 3 commits January 21, 2026 15:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@ami/main/api/views.py`:
- Around line 232-233: Update the docstring in ami/main/api/views.py that
describes the AsyncPipelineRegistrationRequest payload: change the field name
from `pipelines_response` to the correct `pipeline_response` so it reads that
the list of PipelineConfigResponse objects is under the
`pipeline_response.pipelines` key; keep references to
AsyncPipelineRegistrationRequest and PipelineConfigResponse so readers can
locate the schema and adjust any adjacent wording to match the actual field
name.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@ami/main/api/views.py`:
- Around line 254-263: Replace the non-atomic filter().first() + create() flow
for ProcessingService with an atomic get_or_create using the
parsed.processing_service_name; call
ProcessingService.objects.get_or_create(name=parsed.processing_service_name,
defaults={...}) to obtain (processing_service, created) and then ensure the
project is associated (processing_service.projects.add(project)) regardless of
created, mirroring the get_or_create_default_processing_service() pattern to
avoid TOCTOU races.
♻️ Duplicate comments (1)
ami/main/api/views.py (1)

232-233: Docstring schema key is incorrect.

The request schema exposes pipelines directly, not pipelines_response.pipelines. Please update the docstring to match the actual payload structure.

📝 Proposed docstring fix
-        list of PipelineConfigResponse objects under the `pipelines_response.pipelines` key.
+        list of PipelineConfigResponse objects under the `pipelines` key.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@ami/main/api/views.py`:
- Around line 226-227: The pipelines view method currently defines an unused
parameter pk which triggers ARG002; update the method signature for def
pipelines(self, request, pk=None): to silence the lint warning by marking the
unused argument with a noqa (e.g., def pipelines(self, request, pk=None):  #
noqa: ARG002) or remove/rename if appropriate; ensure the change references the
pipelines method so the decorator `@action`(detail=True, methods=["post"],
url_path="pipelines") remains unchanged.

@mihow
Copy link
Collaborator

mihow commented Feb 2, 2026

@annavik it would be great to discuss the UX for pipeline registration this week while we have @carlosgjs

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.

PSv2: Pipeline registration for async processing services

3 participants