[Feat] temporal: simplify usage with an open method or function

Aperta
#8,161 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start by reading the temporal framework documentation and the open_stds module, especially _open_old_stds, _open_new_stds, and _check_open_new_. Review the linked draft pull request for context on the proposed API. Done means a replacement covers space time datasets and map datasets, handles setup and compatibility checks, and documents the recommended usage.

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

Descrizione

enhancement

Is your feature request related to a problem? Please describe.

Using the temporal framework appears to be relatively complicated for users. It requires them to initialize TGIS, maybe create a database and database interface, check the dataset input (id) to be qualified, ...

Describe the solution you'd like

I would like to have an open method for SpaceTimeDatasets that simplifies the usage of the temporal framework. Opening should not require users to do several things in the right order and execute several checks, unless they have specific requirements themselfs.
Furthermore, I would want it to be more similar to what people are used to in Python otherwise, including context manager. Thus, I would like to propose a file-like open method or function for SpaceTimeDatasets.

Here is how a file-like open function may look like:

import grass.temporal as tgis
stds = tgis.open(
    "my_series@my_mapset",
    "w",
    stds_type="stvds",
    **{
        "title": "stds_title",
        "description": "stds description",
        "temporal_type": "absolute"
    }
)
stds = tgis.open("my_series@my_mapset", "r", stds_type="stvds")
stds = tgis.open("my_series@my_mapset", "r+", stds_type="stvds")

# or
with tgis.open("my_series@my_mapset", "r", stds_type="stvds") as input_stds:
    input.stds.get_registered_maps()

The idea is that it also sets up stuff for the user if needed and that it also execute reasonable checks (like does the TGIS DB exist, does the STDS exist, is it compatible with the open request (writeable, appropriate temporal type, ...).

Describe alternatives you've considered

An alternative would be to have a class / instance method like e.g. for vector or raster in pygrass:

import grass.temporal as tgis

# Create or modify a dataset
stds = SpaceTimeVectorDataset("my_series@my_mapset")
mode = "r+" if stds.exists() else "w"
with stds.open(
        mode,
        **{
            "title": "stds_title",
            "description": "stds description",
            "temporal_type": "absolute"
        }
    ) as stds:
    stds.get_registered_maps()

Additional context

The temporal framework already offers several different ways to create or open space time datasets, while the documentation is not clear what is "best-practice". The new functionality should replace the content in the open_stds module (open_old_stds, open_new_stds, check_open_new). The new implementation has to cover also map datasets to be a full replacement.

The database interface would be dataset specific, if not provided as keyword argument, and gets closed when the dataset object is destroyed.

I have an AI assisted draft implementation here: https://github.com/ninsbl/grass/pull/56 and would be happy about any feedback, but esp. about the suggested alternatives, before I make a more comprehensive implementation plan.

Lingua principale
C
Stelle
1.2k
Fork
447
Merge medio
2g 10h
PR unite (30g)
86

Preparare l'ambiente

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 OSGeo/grass

Tutte le issue di OSGeo/grass

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.