python-3.x - 如何将数据从 Azure ML(笔记本)传输到存储容器

标签 python-3.x azure azure-container-service azure-machine-learning-service azureml-python-sdk

我需要将文件从 Azure ML 工作区(笔记本文件夹)传输到存储容器。在 jupyter 笔记本中尝试过此操作;

import azureml.core
from azureml.core import Workspace, Datastore
import json

subscription_id = 'key1'
resource_group = 'rg_grp'
workspace_name = 'dev'

workspace = Workspace(subscription_id, resource_group, workspace_name)

# get the datastore to upload prepared data
    datastore = Datastore.get(workspace, datastore_name='input')  # using an existing mapped datastore in azure ML

# upload the local file from src_dir to the target_path in datastore

datastore.upload_files(['./folder1/output.csv'], relative_root='folder1', target_path='folder1', overwrite=True, show_progress=True)

一旦我运行要上传的代码块,我就会收到此错误消息,

UserErrorException: UserErrorException:
    Message: './folder1/output.csv' does not point to a file. Please upload the file to cloud-first if running in a cloud notebook.
    InnerException None
    ErrorResponse 
{
    "error": {
        "code": "UserError",
        "message": "'./folder1/output.csv' does not point to a file. Please upload the file to cloud first if running in a cloud notebook."
    }
}

CSV 文件已在我的笔记本中。

如有任何帮助,我们将不胜感激

问候

最佳答案

我最近遇到了类似的问题。

我相信,通过查看文档 - https://learn.microsoft.com/en-us/python/api/azureml-core/azureml.data.azure_storage_datastore.azureblobdatastore?view=azure-ml-py#upload-files-files--relative-root-none--target-path-none--overwrite-false--show-progress-true-

您需要引用文件存储位置的绝对路径,但在我看来,在开始时使用点表示法您正在使用无法与此方法一起使用的相对路径。

因此文件列表中的值应来自:

'./folder1/output.csv'

'/root/subfolder/folder1/output.csv'

显然要确保您的根文件夹和子文件夹命名正确!

关于python-3.x - 如何将数据从 Azure ML(笔记本)传输到存储容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67897947/

相关文章:

python - 无法使用scrapy从网页中获取不同列表的标题

c# - Azure功能与Servicebus如何不将消息标记为完成

azure - 从azure搜索中获取所有 `Facets`,没有项目结果

azure - 使用 swarm 部署 azure 容器服务后运行自定义脚本

python - 访问张量中各个元素的更好方法

python - 在 if 语句中使用 input() 是一种不好的做法吗?

python - 为什么 Selenium 在 Chrome 和 Firefox 中可以单击单选按钮,但在 IE 9 中却失败?

node.js - Azure 网站和 Sass

html - 转换为 HTML Azure Powershell "Get-VM"

kubernetes - AKS 群集上的主节点