Azure / Azure/azure-storage-python

Unable to load serialized object persisted on Azure Blob storage

オープン
#678 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
343
フォーク
243
PR マージ指標
30日以内にマージされた PR はありません

説明

We serialize the 'pipeline' object and store it on Azure Blob Storage.

```
with open("feg_pipeline.pkl", 'wb') as f:
dill.dump(pipeline, f, protocol=pickle.HIGHEST_PROTOCOL)
blob_service_client = BlobServiceClient.from_connection_string(conn_str=‘XXX’)
container_name = ‘YYY’
blob_service_client.create_container(container_name, public_access=PublicAccess.Container)
blob_client = blob_service_client.get_blob_client(
container=container_name, blob='feg_pipeline.pkl')
blob_client.upload_blob('feg_pipeline.pkl')
```

Later in a different function we read this from Blob storage as follows -
```

blob = BlobClient(account_url='https://fhghjhjh’,
container_name=‘YYY’,
blob_name='feg_pipeline.pkl’,
credential=‘XXX’)
feg_from_blob = None
with open("feg_pipeline.pkl”, "wb") as f:
data = blob.download_blob()
data.readinto(f)
with open("feg_pipeline.pkl”, "rb") as f:
feg_from_blob = dill.load(f)
```

For this we are getting

```
UnpicklingError: invalid load key, 'f'.

```
We have tried using -

Dill, Joblib, cPickle, CloudPickle and Pickle methods for serializing and deserializing, all of these gave keyerror while loading the object from the file downloaded from Blob.
Base64 encoding(while serializing) and decoding(while deserializing)..This gives a padding error while loading.

**What is the best way to persist and reuse such objects in Azure?**

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、issue に示されている Azure BlobClient の upload_blob および download_blob 呼び出しを確認し、続いて提供された dill の例を使ってシリアライズとダウンロードのフローを再現します。Blob Storage のラウンドトリップの前後で feg_pipeline.pkl に書き込まれたバイト列を比較し、UnpicklingError の原因を特定します。永続化フローを理解し、文書化された再現可能な修正が利用可能になれば完了です。

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

評価

技術スタック
azure, python
領域
cloud
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

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

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