Ordered fields for Add-Ons

オープン
#185 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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?

主要言語
Python
スター
55
フォーク
10
平均マージ
1日 13時間
マージ済み PR(30日)
22

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

MuckRock/documentcloud のほかの issue

MuckRock/documentcloud の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。