Ordered fields for Add-Ons

Ouverte
#185 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
25/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
python
Domaine
backend

Piste de recherche

Start by reading addons/models.py and tracing how Add-On config.yaml parameters are loaded and stored, including the python-documentcloud library path mentioned in the issue. Check whether ordering is lost during JSONField storage or later serialization; done means identifying a supported way to preserve field order through to the front end.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

addons enhancement

Disclose brought up the fact that fields aren't ordered in Add-Ons, which is something we have noted before and is a not ideal.

From my understanding, the front-end loads the JSON parameters that are pulled from addons/models.py from the originating config.yaml file for the Add-On.

Currently in our addons/models.py and in our python-documentcloud library we use the standard pyyaml (import yaml).
The YAML spec doesn't traditionally support ordering- but it also doesn't prohibit it. It gets loaded into a dict, which before Python 3.7, was unordered. Python >= 3.7, dicts maintain order.

In Python 3.7+, the dict we get from running yaml.safe_load returns a dictionary with order preserved.
https://medium.com/@reorx/tips-that-may-save-you-from-the-hell-of-pyyaml-572cde7e1d6f

This is also noted in this discussion on PyYaml's official issues here:
https://github.com/yaml/pyyaml/issues/110#issuecomment-500882817

For a sanity check, I even tested safe_load on PII detector's config.yaml file locally and confirmed that order, even within properties, was preserved:
Order preserved

I think the issue here is JSON not maintaining order in parameters

parameters = models.JSONField(
("parameters"),
default=dict,
help_text=
("The user supplied parameters to run the add-on with"),
)

Is there some other way we could preserve order?

Langage dominant
Python
Étoiles
55
Forks
10
Merge moyen
1 j 13 h
PR mergées (30 j)
22

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de MuckRock/documentcloud

Toutes les issues de MuckRock/documentcloud

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.