From 3770808f2a27bfcbc117065f0fbe4d3f980da98f Mon Sep 17 00:00:00 2001 From: nazarfil Date: Fri, 12 Jul 2024 09:44:51 +0200 Subject: [PATCH] chore: renamed snapshot to file_metadata --- docker-compose.yaml | 6 +++--- .../commands/dataset_snapshot_worker.py | 4 ++-- ...shotjob.py => 0005_datasetfilemetadatajob.py} | 6 +++--- hexa/datasets/models.py | 4 ++-- hexa/datasets/queue.py | 16 +++++++++------- hexa/datasets/schema/mutations.py | 6 +++--- 6 files changed, 22 insertions(+), 20 deletions(-) rename hexa/datasets/migrations/{0005_datasetsnapshotjob.py => 0005_datasetfilemetadatajob.py} (89%) diff --git a/docker-compose.yaml b/docker-compose.yaml index 78b2f25cd..bc141366f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -88,12 +88,12 @@ services: depends_on: - db - dataset_snapshot: + dataset_file_metadata: <<: *common - command: "manage dataset_snapshot_worker" + command: "manage dataset_file_metadata_worker" restart: unless-stopped profiles: - - "dataset_snapshot" + - "dataset_file_metadata" depends_on: - db diff --git a/hexa/datasets/management/commands/dataset_snapshot_worker.py b/hexa/datasets/management/commands/dataset_snapshot_worker.py index 0c6578270..d7389ccaf 100644 --- a/hexa/datasets/management/commands/dataset_snapshot_worker.py +++ b/hexa/datasets/management/commands/dataset_snapshot_worker.py @@ -1,7 +1,7 @@ from dpq.commands import Worker -from hexa.datasets.queue import dataset_snapshot_queue +from hexa.datasets.queue import dataset_file_metadata_queue class Command(Worker): - queue = dataset_snapshot_queue + queue = dataset_file_metadata_queue diff --git a/hexa/datasets/migrations/0005_datasetsnapshotjob.py b/hexa/datasets/migrations/0005_datasetfilemetadatajob.py similarity index 89% rename from hexa/datasets/migrations/0005_datasetsnapshotjob.py rename to hexa/datasets/migrations/0005_datasetfilemetadatajob.py index eb2969718..fe50b4e26 100644 --- a/hexa/datasets/migrations/0005_datasetsnapshotjob.py +++ b/hexa/datasets/migrations/0005_datasetfilemetadatajob.py @@ -1,4 +1,4 @@ -# Generated by Django 5.0.3 on 2024-07-04 12:08 +# Generated by Django 5.0.3 on 2024-07-12 08:14 import django.contrib.postgres.functions from django.db import migrations, models @@ -11,7 +11,7 @@ class Migration(migrations.Migration): operations = [ migrations.CreateModel( - name="DatasetSnapshotJob", + name="DatasetFileMetadataJob", fields=[ ("id", models.BigAutoField(primary_key=True, serialize=False)), ( @@ -37,7 +37,7 @@ class Migration(migrations.Migration): ("args", models.JSONField()), ], options={ - "db_table": "catalog_datasetsnapshotjob", + "db_table": "datasets_filemetadatajob", }, ), ] diff --git a/hexa/datasets/models.py b/hexa/datasets/models.py index 7dd91b2cb..628fa1079 100644 --- a/hexa/datasets/models.py +++ b/hexa/datasets/models.py @@ -294,6 +294,6 @@ class Meta: unique_together = ("dataset", "workspace") -class DatasetSnapshotJob(BaseJob): +class DatasetFileMetadataJob(BaseJob): class Meta: - db_table = "catalog_datasetsnapshotjob" + db_table = "datasets_filemetadatajob" diff --git a/hexa/datasets/queue.py b/hexa/datasets/queue.py index cb1b0fe8e..fd122d4d5 100644 --- a/hexa/datasets/queue.py +++ b/hexa/datasets/queue.py @@ -2,24 +2,26 @@ from dpq.queue import AtLeastOnceQueue -from hexa.datasets.models import DatasetSnapshotJob +from hexa.datasets.models import DatasetFileMetadataJob logger = getLogger(__name__) -def create_dataset_snnapshot_task(queue: AtLeastOnceQueue, job: DatasetSnapshotJob): +def create_dataset_file_metadata_task( + queue: AtLeastOnceQueue, job: DatasetFileMetadataJob +): # TODO: imlpement ticket PATHWAYS-98 - extract data in background task dataset_version_file_id = job.args["fileId"] logger.info(f"Creating dataset version file {dataset_version_file_id}") -class DatasetSnapshotQueue(AtLeastOnceQueue): - job_model = DatasetSnapshotJob +class DatasetsFileMetadataQueue(AtLeastOnceQueue): + job_model = DatasetFileMetadataJob -dataset_snapshot_queue = DatasetSnapshotQueue( +dataset_file_metadata_queue = DatasetsFileMetadataQueue( tasks={ - "create_snapshot": create_dataset_snnapshot_task, + "generate_file_metadata": create_dataset_file_metadata_task, }, - notify_channel="dataset_snapshot_queue", + notify_channel="dataset_file_metadata_queue", ) diff --git a/hexa/datasets/schema/mutations.py b/hexa/datasets/schema/mutations.py index 843d39394..5a22fa8a3 100644 --- a/hexa/datasets/schema/mutations.py +++ b/hexa/datasets/schema/mutations.py @@ -7,7 +7,7 @@ from ..api import generate_download_url, generate_upload_url, get_blob from ..models import Dataset, DatasetLink, DatasetVersion, DatasetVersionFile -from ..queue import dataset_snapshot_queue +from ..queue import dataset_file_metadata_queue mutations = MutationType() @@ -206,9 +206,9 @@ def resolve_create_version_file(_, info, **kwargs): content_type=mutation_input["contentType"], ) upload_url = generate_upload_url(file) - dataset_snapshot_queue.enqueue( + dataset_file_metadata_queue.enqueue( { - "create_snapshot", + "generate_file_metadata", { "file_id": str(file.id), },