sledilnik / data-api

Provides REST API to source CSV files
MIT License
6 stars 4 forks source link

Add supports for models #61

Open MihaMarkic opened 3 years ago

MihaMarkic commented 3 years ago

Support for posting and retrieving models

Specs Prikaz modelskih napovedi omogoča zajem in prikaz modelskih napovedi. Za posredovanje podatko sta na voljo dva API-ja:

API za zajem podatkov

Klienti pošljejo podatke s POST zahtevkom. Vsebina telesa zahtevka je modelska predikcija v CSV obliki, zahtevek pa mora biti opremljen še z naslednjimi query parametri:

Scenarij lahko zavzame naslednje vrednosti:

Stolpci (polja) v CSV datoteki so: date, deceased, deceasedLowerBound, deceasedUpperBound, deceasedToDate, deceasedToDateLowerBound, deceasedToDateUpperBound, icu, icuLowerBound, icuUpperBound, hospitalized, hospitalizedLowerBound, hospitalizedUpperBound

Če se za isti model, dan, scenarij, intervalType in intervalWidth pošlje ponovno napoved se stara napoved prepiše.

Če se bodo izvorni podatki shranjevali kot CSV datoteke mora biti direktorijska/imenska sktuktura dovolj bogata in fleksibilna, da podpre različne tipe in (potencialno) njihovo evolucijo. Na primer:

//////data.json

API za posredovanje podatkov

API ponuja tri endpointe:

Struktura API-ja:

MODELS endpoint vrača JSON podatke oblike (za točnapolja glej shemo):

[ { "id": "20540b1c-a7b6-4e45-bd57-9d60f1cdf28f", "name": "My precious model", "code": "https://github.com/zaplotnik/korona", "homepage": "https://arxiv.org/pdf/2005.13282.pdf" } ]

Podatki so lahko v JSON ali CSV obliki.

DATA endpoint vrača podatke oblike:

[ "modelId": "20540b1c-a7b6-4e45-bd57-9d60f1cdf28f", "date": "2020-11-04", "scenario": "(BREZ_NOVIH_OKUZB | ...)", "interval": { "intervalType": "(INTERVAL_ZAUPANJA | VERJETNOSTNI_INTERVAL) option", "intervalTypeWidth": "(50 | 95) option" } "data": [ { "date": "2020-08-01", "deceased": "int", "deceasedLowerBound": "int option", "deceasedUpperBound": "int option", "deceasedToDate": "int", "deceasedToDateLowerBound": "int option", "deceasedToDateUpperBound": "int option", "icu": "int", "icuLowerBound": "int option", "icuUpperBound": "int option", "hospitalized": "int", "hospitalizedLowerBound": "int option", "hospitalizedUpperBound": "int option" } ... ] ]

Podatki so lahko v JSON ali CSV obliki.

Predlog: v obliki CSV je telo odgovora data, metapodatki modelId, date ... pa se posredujejo kot response headers.

MihaMarkic commented 3 years ago

@joahim @overlordtm

  1. models_prediction created and updated fields are populated by code? _2. Is it possible to update models_prediction? And if yes, then what is the primary key in such case? Perhaps model_id, date, scenarioid? I guess not today through API, right?
  2. Do we have a test file with data?
joahim commented 3 years ago
  1. Yes, created and updated fields are managed by the API code.
  2. Yes, the predictions can always be updated. The composite key is: (date, model, scenario, interval_kind)
  3. Yes, prediction.csv.zip
MihaMarkic commented 3 years ago

Shall we then use POST for creating a new one and PUT for updating it?

MihaMarkic commented 3 years ago

@joahim What does modelprediction.code property map to? Perhaps description column on entity?