How to handle common, non-primitive data types
@jtc42 がすでに取り組んでいます。
2020年5月2日 から。
評価
この issue はまだ評価されていません。
説明
This is likely going to be an open question for a while, but there are my current thoughts. All input is welcome.
I feel like, by and large, data collected from lab instruments can sensibly be converted to primitive data types. The most common types I have in mind are Numpy arrays, and Pandas data frames. Both of these can be represented easily with primitive data types.
There are however cases where data will be collected that cannot be converted to a primitive type.
In the new cbor branch, I've added a section to the JSON encoder that will base64 encode bytes Python objects. I've correspondingly included a Marshmallow Bytes field to handle validating binary data in this format. It populates the documentation with information about the string values being a base64 encoded block of binary data. Everything is fine on that front.
However, as @rwb27 has mentioned in the past, sometimes the binary data collected will be big enough that the b64 encoding overhead could become problematic. To handle these cases, I've included support for clients to accept application/cbor responses instead of application/json.
CBOR has built in support for binary encoded data, so if a client requests a CBOR response, no encoding overhead is introduced. The data gets passed directly to the CBOR response, otherwise identical to the JSON response, but with the binary section unencoded.
This solution isn't perfect though. The Thing Description is required to be JSON. This is fine in most cases as it accurately describes the base64 encoded binary blobs. However, it means that the CBOR response will deviate from the Thing Description, receiving a bytes type value where the Description says a string will be returned.
I currently feel however that the cases where large, non-primitive data files are being collected with such high frequency that CBOR encoding is required are infrequent enough that, given proper documentation, this solution could still be fine.
Again, thoughts are welcome.
Note: The CBOR branch is useful even aside from this. It's a much more compact data format that JSON, so for many cases it may be beneficial to actually communicate over BSON even without needing to transfer bytes objects. It was easy to add support, and doesn't affect the JSON functionality at all.
- 主要言語
- Python
- スター
- 19
- フォーク
- 2
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
labthings/python-labthings のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
labthings/python-labthings#324 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
labthings/python-labthings#323 · コメント 3 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
labthings/python-labthings#302 · コメント 2 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
labthings/python-labthings#300 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
labthings/python-labthings#237 · コメント 3 件 ·
labthings/python-labthings の issue をすべて見る
似ている issue
-
新功能建议
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
Mai-with-u/MaiBot#2583 ·
メンテナーはふだん 1 日以内に返信
-
area-integrations
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
[New]: JambaオープンMatch Play
難易度 1/5 1時間未満 初心者へのやさしさ 63/100
privacyguides/verified-apps#9224 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: The docs check fails to install the Mintlify CLI when it runs right after a `mint` releaseオープンchore upstream
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
MemMachine/MemMachine#2032 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100