pzmm.MLFlowModel.read_mlflow_model_file() failed with JSONDecodeError: Extra data
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 48/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- python
研究方向
從 sasctl/pzmm/mlflow_model.py 中的 MLFlowModel.read_mlflow_model_file() 開始,特別檢查 stack trace 中所示的 inputs_dict 和 outputs_dict 解析過程。使用所參照的 MLflow 模型目錄重現此範例,並檢查產生的模型中繼資料;當該方法在沒有 JSONDecodeError 的情況下回傳三個預期的字典時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Describe the issue
Trying to read mlflow model using pzmm.MLFlowModel.read_mlflow_model_file result in JSONDecodeError. I'm just using a simple example from here:
https://medium.com/@rehabreda/registering-mlflow-models-to-sas-model-manager-using-sasctl-a-comprehensive-guide-a47dbf183338
To Reproduce
The rest of the training code can be found on the above link. The code that perform the read mlflow model file is shown below:
## define randomforest model
model = RandomForestClassifier(n_estimators=300).fit(x_train, y_train)
##Model signature defines schema of model input and output
signature = infer_signature(x_train, model.predict(x_train))
## log model score to mlflow
score = model.score(x_test, y_test)
print("Score: %s" % score)
mlflow.log_metric("score", score)
### log model
mlflow.sklearn.log_model(model, "model", signature=signature)
print("Model saved in run %s" % mlflow.active_run().info.run_uuid)
mlPath = Path(f'./mlruns/1/{mlflow.active_run().info.run_uuid}/artifacts/model')
## get info aboud model variables ,input and output
varDict, inputsDict, outputsDict = pzmm.MLFlowModel.read_mlflow_model_file(mlPath)
Expected behavior
Getting the dictionary successfully from pzmm.MLFlowModel.read_mlflow_model_file().
Stack Trace
If you're experiencing an exception, include the full stack trace and error message.
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
Cell In[4], line 4
1 mlPath = Path(f'./mlruns/1/{mlflow.active_run().info.run_uuid}/artifacts/model')
3 ## get info aboud model variables ,input and output
----> 4 varDict, inputsDict, outputsDict = pzmm.MLFlowModel.read_mlflow_model_file(mlPath)
File ~\AppData\Local\miniconda3\envs\ml\Lib\site-packages\sasctl\pzmm\mlflow_model.py:56, in MLFlowModel.read_mlflow_model_file(cls, m_path)
53 outputs = m_lines[ind_out[0] : -1]
55 inputs_dict = json.loads("".join([s.strip() for s in inputs])[9:-1])
---> 56 outputs_dict = json.loads("".join([s.strip() for s in outputs])[10:-1])
57 else:
58 raise ValueError(
59 "Improper or unset signature values for model. No input or output "
60 "dicts could be generated. "
61 )
File ~\AppData\Local\miniconda3\envs\ml\Lib\json\__init__.py:346, in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
341 s = s.decode(detect_encoding(s), 'surrogatepass')
343 if (cls is None and object_hook is None and
344 parse_int is None and parse_float is None and
345 parse_constant is None and object_pairs_hook is None and not kw):
--> 346 return _default_decoder.decode(s)
347 if cls is None:
348 cls = JSONDecoder
File ~\AppData\Local\miniconda3\envs\ml\Lib\json\decoder.py:340, in JSONDecoder.decode(self, s, _w)
338 end = _w(s, end).end()
339 if end != len(s):
--> 340 raise JSONDecodeError("Extra data", s, end)
341 return obj
JSONDecodeError: Extra data: line 1 column 73 (char 72)
Version
1.10.0
- 主要語言
- Python
- 星號
- 52
- 分支
- 45
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
sassoftware/python-sasctl 的其他 Issue
-
enhancement
難度 4/5 3-5 天 新手友好度 35/100
sassoftware/python-sasctl#224 ·
-
enhancement
難度 4/5 3-5 天 新手友好度 25/100
sassoftware/python-sasctl#216 ·
-
bug
難度 4/5 3-5 天 新手友好度 35/100
sassoftware/python-sasctl#207 · 1 個 reaction ·
-
bug
難度 3/5 1-2 天 新手友好度 45/100
sassoftware/python-sasctl#202 ·
-
bug
難度 4/5 3-5 天 新手友好度 30/100
sassoftware/python-sasctl#193 ·
查看 sassoftware/python-sasctl 的全部 Issue
相似的 Issue
-
documentation good first issue
難度 1/5 1 小時以內 新手友好度 88/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 84/100
MarketSquare/robotframework-browser#5479 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
endoflife-date/endoflife.date#11561 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
OCA/l10n-brazil#5602 ·
維護者通常 1 天內回覆
-
documentation review-2.0.0
難度 2/5 1-3 小時 新手友好度 78/100
dkuenzel/meshcore-home-gateway#106 ·
維護者通常 1 天內回覆