Skip to content

Conversation

@vanessavmac
Copy link
Collaborator

@vanessavmac vanessavmac commented Feb 22, 2025

Summary

Add an intermediate model to store the relationship between a project and a pipeline.

List of Changes

  • Added additional intermediate model ProjectPipelineConfig
  • Added an additional column to display whether a pipeline is enabled for a project

Related Issues

Detailed Description

...

How to Test the Changes

...

Screenshots

Screenshot 2025-02-22 at 2 54 47 AM

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.

@vanessavmac vanessavmac requested a review from mihow February 22, 2025 07:57
@vanessavmac vanessavmac self-assigned this Feb 22, 2025
@netlify
Copy link

netlify bot commented Feb 22, 2025

Deploy Preview for antenna-preview canceled.

Name Link
🔨 Latest commit f607c24
🔍 Latest deploy log https://app.netlify.com/sites/antenna-preview/deploys/67da126b31c5760008a640ce

@vanessavmac vanessavmac marked this pull request as ready for review March 10, 2025 03:48
f"Sending pipeline request using {config} from the project-pipeline config "
f"for Pipeline {pipeline} and Project {job.project}."
)
except Exception as e:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will you raise the specific Exception here? Should be ProjectPipelineConfig.NotFound or ObjectNotFound

if url
]

if job_id:
Copy link
Collaborator

@mihow mihow Mar 13, 2025

Choose a reason for hiding this comment

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

We should be able to get the pipeline config even if we are not in the context of a job. Is there another place to get the current project ID? We should add it to the process_images function arguments

)
projects = models.ManyToManyField("main.Project", related_name="pipelines", blank=True)
projects = models.ManyToManyField(
"main.Project", related_name="pipelines", blank=True, through="ml.ProjectPipelineConfig"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice work implementing our first through model!


pipeline.projects.add(*self.projects.all())
for project in self.projects.all():
project_pipeline_config, created = ProjectPipelineConfig.objects.get_or_create(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm curious if you have to create the ProjectPipelineConfig explicitly or if it will be created automatically when you create a pipeline with projects, since it is configured as a through model. Did you test that? You can set the default enabled=True in the model definition.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just tested, we have to create it explicitly. In the ami/ml/models/project_pipeline_config.py I've also set the default values like this:

enabled = models.BooleanField(default=True)
config = models.JSONField(default=dict, blank=True, null=True)

sortField: 'updated_at',
renderCell: (item: Pipeline) => <BasicTableCell value={item.updatedAt} />,
},
// {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can these comments be dropped or do you want to discuss?

@mihow
Copy link
Collaborator

mihow commented Mar 14, 2025

Great stuff @vanessavmac! I can't wait to put this one into action. I tested on a recent DB snapshot and updated the migration file. I left a few comments, the most important one is how we get the project-pipeline-config in the process_images function. You can get the project_id from one of the images in the collection, but I think we should pass Project or project_id to the process images function. It's already available in the parent function.

@vanessavmac
Copy link
Collaborator Author

@mihow Thanks for reviewing! I've made the requested changes. Let me know if there's any other changes I should make

Copy link
Collaborator

@mihow mihow left a comment

Choose a reason for hiding this comment

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

@vanessavmac I made one change and helped fix the circular imports by using string references to the Project & Pipeline models in the ProjectPipelineConfig class definition. I tested again on a real DB snapshot and all is well! Great work!

@mihow mihow merged commit 64d8d0c into main Mar 19, 2025
6 checks passed
@mihow mihow deleted the 695-ability-to-disable-a-pipeline-for-a-given-project branch March 19, 2025 00:56
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.

Ability to disable a pipeline for a given project

3 participants