Datasets: a deleted Dataset's name is held while scenario bundles cite it

Aperta
#2,627 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
django, python, sql
Ambito
backend, databases

Direzione di ricerca

First check the blocking issue #2624 before starting. Read the Dataset delete path in the dataedit service and the name preview endpoint, plus oekg/graph_store.py for the ASK check; use the existing repair_oekg_shape_violations manage.py command as the template for drop_dead_dataset_links. Done means the acceptance criteria pass: hold written or not by citation state, held-name refusal without graph queries (assertNumQueries), dry-run vs --apply, migration dataedit.0059_datasetnamehold, and tests via Django's test client, call_command, and OekgGraphTestCase against real Fuseki.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

datasets Profile ready-for-agent

Parent

#2613 (spec: Profile dashboard datasets tab and the Dataset lifecycle)

What to build

A deleted Dataset's name stays free unless a scenario bundle cites it. While it is cited, the name is held, so nobody else's Dataset silently becomes the target of the citation. An operator command releases held names after 30 days.

  • DatasetNameHold: the name (primary key) and deleted_at. Only a Dataset delete writes one; only the cleanup command removes one.
  • At delete, the service asks the graph store in one ASK whether any ref: dataset link cites the name. It goes through the OEKG API's own client (oekg/graph_store.py), never factsheet/oekg/connection.py, which parses the OEO at import.
    • Not cited: the name is free at once.
    • Cited, or the store unreachable: a hold is written in the same transaction.
    • A delete never fails on the graph store.
  • While a hold exists, the service's create and the name preview refuse the name: "used by a deleted dataset that scenario bundles still cite; it becomes available once those links are gone." Both read the hold table, never the graph store. The preview gains its "held" state.
  • manage.py drop_dead_dataset_links, shaped like repair_oekg_shape_violations:
    • dry run by default, --apply to act, --older-than-days defaulting to 30;
    • for every older hold it removes each ref: dataset link to the name, one atomic update with a version bump per bundle, then deletes the hold;
    • its JSON record is written before the graph is touched, and it logs one line per link;
    • it writes no OEKG history entry;
    • an operator runs it on the host; there is no scheduler.
  • On the record: this is a deliberate, interim departure from two closed OEKG API decisions, never collect (Dataset links) and every write records (history). Say so in the command's docstring. The full fix is out of scope.
  • Until the command runs, a link to a deleted Dataset reads resolvable: false, as today.

Acceptance criteria

  • Delete with a citing link writes a hold; with no link it writes none and the name is free at once; with the store unreachable it writes a hold and the delete still succeeds
  • Create (dashboard and API) and the preview refuse a held name with the sentence above, without asking the graph store (assertNumQueries / no graph call)
  • The command's dry run changes nothing and lists what it would do; --apply removes every link to the name in one atomic update per bundle with a version bump, deletes the hold, and frees the name; holds younger than the threshold are left alone
  • An unwritable record path stops the run before the graph is touched
  • The graph parts run against a real Fuseki on OekgGraphTestCase (one named graph per test) and skip cleanly, with a reason, without one
  • If the selection ticket has merged, its delete ceiling is re-checked with the real ASK, and the result is stated in the PR
  • CONTEXT.md's Dataset link entry ("is never cleaned up") is amended (an untracked file: edit it locally and say so in the PR)
  • Tested through the spec's seams: HTTP through Django's test client for delete, create and the preview; call_command for the command

Migrations and deploy

  • Django migration dataedit.0059_datasetnamehold (number as expected today; take the next free one): one new table, nothing backfilled.
  • Deploy step: python manage.py migrate, in the next release's deploy checklist. The command is not a deploy step: an operator runs it on the host when holds are older than 30 days. Note it in the checklist as an operator tool.

Blocked by

  • #2624

🤖 Generated with Claude Code

Lingua principale
Python
Stelle
65
Fork
28
Merge medio
4g 7h
PR unite (30g)
25

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenEnergyPlatform/oeplatform

Tutte le issue di OpenEnergyPlatform/oeplatform

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.