Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: store kingfisher process collection notes #384

Merged
merged 2 commits into from
Jan 17, 2025
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
7 changes: 7 additions & 0 deletions data_registry/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ class Media:
),
},
),
(
"Logs",
{
"fields": ("process_notes",),
},
),
(
"Overview",
{
Expand Down Expand Up @@ -299,6 +305,7 @@ class Media:
"active",
"archived",
"context",
"process_notes",
"start",
"end",
# Overview
Expand Down
21 changes: 21 additions & 0 deletions data_registry/migrations/0059_job_process_notes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.2.14 on 2024-12-18 19:20

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("data_registry", "0058_alter_collection_update_frequency"),
]

operations = [
migrations.AddField(
model_name="job",
name="process_notes",
field=models.JSONField(
blank=True,
default=dict,
help_text="The collection notes from Kingfisher Process.",
),
),
]
5 changes: 5 additions & 0 deletions data_registry/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class Status(models.TextChoices):
"<dd>The name of the dataset in Pelican</dd>"
"</dl>",
)
process_notes = models.JSONField(
blank=True,
default=dict,
help_text="The collection notes from Kingfisher Process.",
)

# Job logic
archived = models.BooleanField(
Expand Down
20 changes: 12 additions & 8 deletions data_registry/process_manager/task/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,23 @@ def run(self):
def get_status(self):
process_id = self.job.context["process_id"] # set in Collect.get_status()

response = self.request(
tree = self.request(
"GET",
url_for_collection(process_id, "tree"),
error_message=f"Unable to get status of collection {process_id}",
)

tree = response.json()
).json()

original_collection = next(c for c in tree if c["transform_type"] == "")
compiled_collection = next(c for c in tree if c["transform_type"] == "compile-releases")

if not compiled_collection["completed_at"]:
return Task.Status.RUNNING

response = self.request(
meta = self.request(
"GET",
url_for_collection(compiled_collection["id"], "metadata"),
error_message=f"Unable to get metadata of collection {compiled_collection['id']}",
)

meta = response.json()
).json()

# The metadata can be empty (or partial) if the collection contained no data.
if meta:
Expand All @@ -76,6 +72,13 @@ def get_status(self):
self.job.ocid_prefix = meta.get("ocid_prefix") or ""

self.job.context["process_id_pelican"] = compiled_collection["id"]

self.job.process_notes = self.request(
"GET",
url_for_collection(original_collection["id"], "notes"),
error_message=f"Unable to get notes of collection {original_collection['id']}",
).json()

self.job.save(
update_fields=[
"modified",
Expand All @@ -85,6 +88,7 @@ def get_status(self):
"license",
"publication_policy",
"ocid_prefix",
"process_notes",
]
)

Expand Down
Loading