Skip to content

Commit

Permalink
fix: delete pipeline config on pipeline delete
Browse files Browse the repository at this point in the history
  • Loading branch information
niross committed Nov 23, 2023
1 parent 0e9b6bf commit 11a9f7e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions dataworkspace/dataworkspace/apps/datasets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2975,6 +2975,10 @@ def save(self, force_insert=False, force_update=False, using=None, update_fields
super().save(force_insert, force_update, using, update_fields)
self.save_dataflow_pipeline_config()

def delete(self, using=None, keep_parents=False):
self.delete_dataflow_pipeline_config()
super().delete(using, keep_parents)

def get_config_file_path(self):
return f"{settings.DATAFLOW_PIPELINES_PREFIX}/pipeline-{self.id}.json"

Expand All @@ -2987,6 +2991,7 @@ def save_dataflow_pipeline_config(self):
Body=json.dumps(
{
"id": self.id,
"dag_id": self.dag_id,
"type": self.type,
"schedule": self.schedule,
"schema": schema_name,
Expand All @@ -2997,6 +3002,15 @@ def save_dataflow_pipeline_config(self):
),
)

def delete_dataflow_pipeline_config(self):
client = get_s3_client()
try:
client.delete_object(
Bucket=settings.AWS_UPLOADS_BUCKET, Key=self.get_config_file_path()
)
except ClientError:
pass


class PipelineVersion(TimeStampedModel):
pipeline = models.ForeignKey(Pipeline, on_delete=models.CASCADE)
Expand Down

0 comments on commit 11a9f7e

Please sign in to comment.