我训练有素的深度学习模型存在于一个文件夹中的几个文件中。因此,这与压缩数据帧无关。
我要压缩此文件夹(在Azure Blob存储中)。但是当我使用shutil时,这似乎不起作用:
import shutil
modelPath = "/dbfs/mnt/databricks/Models/predictBaseTerm/noNormalizationCode/2020-01-10-13-43/9_0.8147903598547376"
zipPath= "/mnt/databricks/Deploy/" (no /dbfs here or it will error)
shutil.make_archive(base_dir= modelPath, format='zip', base_name=zipPath)
有人知道如何执行此操作并将文件获取到Azure Blob存储(我从那里读取文件)吗?
最后,我自己弄清楚了。
无法使用Shutil直接写入dbfs(Azure Blob存储)。
您需要首先将文件放在这样的数据块的本地驱动程序节点上(在无法直接写入Blob存储的文档中读取该文件):
import shutil
modelPath = "/dbfs/mnt/databricks/Models/predictBaseTerm/noNormalizationCode/2020-01-10-13-43/9_0.8147903598547376"
zipPath= "/tmp/model"
shutil.make_archive(base_dir= modelPath, format='zip', base_name=zipPath)
然后可以将文件从本地驱动程序节点复制到Blob存储。请注意“文件:”以从本地存储中获取文件!
blobStoragePath = "dbfs:/mnt/databricks/Models"
dbutils.fs.cp("file:" +zipPath + ".zip", blobStoragePath)
我为此花了几个小时,如果这个答案对您有帮助,请投票!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句