首页 > 解决方案 > 如何将数据从 Azure ML(笔记本)传输到存储容器

问题描述

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

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 文件已经在我的笔记本中。

任何帮助,将不胜感激

问候

标签: python-3.xazureazure-container-serviceazuremlazureml-python-sdk

解决方案


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

我相信,通过查看文档 - https://docs.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/子文件夹/folder1/output.csv'

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


推荐阅读