Skip to content

Commit

Permalink
chore: renamed snapshot to file_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarfil committed Jul 12, 2024
1 parent 748019f commit 3770808
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions hexa/datasets/management/commands/dataset_snapshot_worker.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,7 +11,7 @@ class Migration(migrations.Migration):

operations = [
migrations.CreateModel(
name="DatasetSnapshotJob",
name="DatasetFileMetadataJob",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
(
Expand All @@ -37,7 +37,7 @@ class Migration(migrations.Migration):
("args", models.JSONField()),
],
options={
"db_table": "catalog_datasetsnapshotjob",
"db_table": "datasets_filemetadatajob",
},
),
]
4 changes: 2 additions & 2 deletions hexa/datasets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
16 changes: 9 additions & 7 deletions hexa/datasets/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
6 changes: 3 additions & 3 deletions hexa/datasets/schema/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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),
},
Expand Down

0 comments on commit 3770808

Please sign in to comment.