Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

#### Changed

- V2: Change measurement and association DB indices to UUIDs [#844](https://github.com/askap-vast/vast-pipeline/pull/844)
- V2: Limit associations upload to using num_io_workers [#833](https://github.com/askap-vast/vast-pipeline/pull/833)
- V2: Allow user specification of dask dashboard paramters and add some further logging to dask setup [#829](https://github.com/askap-vast/vast-pipeline/pull/829)
- V2: Replace all source, measurement, run etc. IDs with UUID indices. [#803](https://github.com/askap-vast/vast-pipeline/pull/803)
Expand Down Expand Up @@ -58,6 +59,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

#### List of PRs

- [#844](https://github.com/askap-vast/vast-pipeline/pull/844): fix: V2: Change measurements and association DB indices to UUIDs
- [#843](https://github.com/askap-vast/vast-pipeline/pull/843): feat: V2: Enable specification of Dask worker memory limits
- [#833](https://github.com/askap-vast/vast-pipeline/pull/833): feat: V2: Limit associations upload to using num_io_workers
- [#829](https://github.com/askap-vast/vast-pipeline/pull/829): feat: V2: Allow user specification of dask dashboard paramters and add some further logging to dask setup
Expand Down
7 changes: 3 additions & 4 deletions vast_pipeline/image/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import logging
import numpy as np
import pandas as pd
import uuid

from django.conf import settings
from astropy.io import fits
Expand All @@ -18,9 +19,7 @@

from vast_pipeline import models
from vast_pipeline.survey.translators import tr_selavy
from vast_pipeline.utils.utils import (
generate_shortuuid, UUID_LEN_MEAS,
)

from vast_pipeline.image.utils import get_fits_header


Expand Down Expand Up @@ -341,7 +340,7 @@ def read_selavy(self, dj_image: models.Image) -> pd.DataFrame:
df[key["name"]] = df[key["name"]].astype(key["dtype"])

# Add id column
df["id"] = df.apply(lambda _: generate_shortuuid(UUID_LEN_MEAS), axis=1)
df["id"] = df.apply(lambda _: str(uuid.uuid4()), axis=1)

# do checks and fill in missing field for uploading sources
# in DB (see fields in models.py -> Source model)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.1.6 on 2025-03-30 23:19

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might be worth resetting the migrations rather than adding a new one at this stage since v2.0 will start a new database from scratch.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed, but I think we should do that as a final step of v2 just in case there's other tweaks that we need to make before the release


import uuid
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('vast_pipeline', '0002_q3c'),
]

operations = [
migrations.AlterField(
model_name='association',
name='id',
field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False),
),
migrations.AlterField(
model_name='measurement',
name='id',
field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False),
),
]
5 changes: 3 additions & 2 deletions vast_pipeline/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import uuid

from dataclasses import dataclass
from itertools import combinations
Expand Down Expand Up @@ -417,7 +418,7 @@ class Measurement(CommentableModel):
Essentially a source single measurement in time.
"""

id = ShortUUIDField(primary_key=True, editable=False, length=UUID_LEN_MEAS, alphabet=UUID_ALPHABET)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
image = models.ForeignKey(
Image, null=True, on_delete=models.CASCADE, to_field="id"
) # first image seen in
Expand Down Expand Up @@ -713,7 +714,7 @@ class Association(models.Model):
some parameters
"""

id = ShortUUIDField(primary_key=True, editable=False, length=UUID_LEN_MEAS, alphabet=UUID_ALPHABET)
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
source = models.ForeignKey(Source, on_delete=models.CASCADE, to_field="id")
meas = models.ForeignKey(Measurement, on_delete=models.CASCADE, to_field="id")

Expand Down
10 changes: 4 additions & 6 deletions vast_pipeline/pipeline/forced_extraction.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import logging
import datetime
import uuid

import numpy as np
import pandas as pd
import dask.dataframe as dd
Expand All @@ -20,11 +22,7 @@
from vast_pipeline.pipeline.loading import copy_upload_measurements

from forced_phot import ForcedPhot
from ..utils.utils import (
StopWatch,
generate_shortuuid,
UUID_LEN_MEAS
)
from ..utils.utils import StopWatch
from vast_pipeline.image.utils import open_fits

# NOTE: We check here to see if we're in a testing environment.
Expand Down Expand Up @@ -486,7 +484,7 @@ def _update_forced_measurements(df: pd.DataFrame) -> pd.DataFrame:
The forced extraction dataframe updated with defaults.
"""
df["name"] = df["name"] + f"_f_{p_run_id}"
df["id"] = df.apply(lambda _: generate_shortuuid(UUID_LEN_MEAS), axis=1)
df["id"] = df.apply(lambda _: str(uuid.uuid4()), axis=1)
default_pos_err = settings.POS_DEFAULT_MIN_ERROR / 3600.0
df["ra_err"] = default_pos_err
df["dec_err"] = default_pos_err
Expand Down
4 changes: 2 additions & 2 deletions vast_pipeline/pipeline/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from itertools import islice
from django.db import transaction, connection, models
from contextlib import closing
from uuid import uuid4

from vast_pipeline.image.main import SelavyImage
from vast_pipeline.pipeline.model_generator import (
Expand Down Expand Up @@ -36,7 +37,6 @@
deg2hms,
deg2dms,
generate_shortuuid,
UUID_LEN_MEAS,
UUID_LEN_SOURCE
)

Expand Down Expand Up @@ -432,7 +432,7 @@ def copy_upload_associations(
}

def upload(df, Association, mapping, batch_size):
df["db_id"] = df.apply(lambda _: generate_shortuuid(UUID_LEN_MEAS), axis=1)
df["db_id"] = df.apply(lambda _: str(uuid4()), axis=1)
copy_upload_model(df, Association, mapping=mapping, batch_size=batch_size)

associations_df = associations_df[columns_to_upload].map_partitions(upload,
Expand Down
8 changes: 8 additions & 0 deletions vast_pipeline/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def plot_lightcurve(

# lightcurve required cols: taustart_ts, flux, flux_err_upper, flux_err_lower, forced
lightcurve = pd.DataFrame(measurements_qs)
lightcurve['id'] = lightcurve['id'].astype(str)

# remap method values to labels to make a better legend
lightcurve["method"] = lightcurve.forced.map({True: "Forced", False: "Selavy"})
Expand Down Expand Up @@ -167,6 +168,13 @@ def plot_lightcurve(
)
.reset_index()
)

candidate_measurement_pairs_df = candidate_measurement_pairs_df.astype(
{'measurement_a_id': 'str',
'measurement_b_id': 'str',
}
)

g = nx.Graph()
for _row in candidate_measurement_pairs_df.itertuples(index=False):
g.add_edge(_row.measurement_a_id, _row.measurement_b_id)
Expand Down
2 changes: 1 addition & 1 deletion vast_pipeline/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Meta:


class MeasurementSerializer(serializers.ModelSerializer):
id = serializers.CharField(read_only=True)
id = serializers.UUIDField(read_only=True)
frequency = serializers.SerializerMethodField(read_only=True)

def get_frequency(self, obj):
Expand Down
5 changes: 5 additions & 0 deletions vast_pipeline/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
name="image_detail",
),
path("measurements/", views.MeasurementIndex, name="measurement_index"),
path(
"measurements/<uuid:id>/",
views.MeasurementDetail,
name="measurement_detail"
),
re_path(
fr"^measurements/(?P<id>[\w]{{{UUID_LEN_MEAS}}})(?:/(?P<action>[\w]+))?/$",
views.MeasurementDetail,
Expand Down