天蓝色机器学习 - Azure Blob存储

时间:2015-09-08 16:30:28

标签: azure module machine-learning azure-storage-blobs reader

如何使用天蓝色机器学习工作室“立即”从Azure Blob存储中存储的多个文件中读取数据?

我尝试使用Reader模块,它可以正常使用一个文件,它可以用于多个文件,还是我必须寻找其他解决方案?

感谢您的帮助!

3 个答案:

答案 0 :(得分:1)

如果没有那么多blob,你可以将每个地图的多个读者添加到一个输入blob中。然后使用"数据转换"下的模块。 - > "操纵"做像"添加行"或者"加入"。

答案 1 :(得分:0)

使用大量读取不同blob的读者,然后将它们连接到MetaData编辑器。

答案 2 :(得分:0)

虽然使用多个Reader模块的方法可行,但当输入很多或输入数量不同时,它变得非常困难。

相反,您可以使用Execute Python Script模块直接访问blob存储。但是,如果您以前从未这样做过,那么这样做会非常痛苦。以下是问题:

  1. 默认情况下,azure.storage.blob Python包未加载到Azure ML中。但是,这可以手动创建,也可以从下面的链接下载(截至2016年2月11日的正确版本)。
  2. azure.storage.blob.BlobService的默认用法使用HTTPS,Azure ML blob存储访问目前不支持HTTPS。为此,您可以在创建BlobService期间传递protocol='http'以强制使用HTTP:client = BlobService(STORAGE_ACCOUNT, STORAGE_KEY, protocol="http")
  3. 以下是让它运作的步骤:

    1. 下载azure.zip,其中提供了所需的azure.storage.*库:https://azuremlpackagesupport.blob.core.windows.net/python/azure.zip
    2. 将它们作为DataSet上传到Azure ML Studio
    3. 将它们连接到Execute Python Script模块上的Zip输入,这是第3个输入。
    4. 像往常一样编写脚本,确保使用BlobService
    5. 创建protocol='http'对象
    6. 运行实验 - 您现在应该能够读取和写入blob存储。
    7. 可在此处找到一些示例代码:https://gist.github.com/drdarshan/92fff2a12ad9946892df

      以下是使其适用于单个文件的代码。这可以扩展为通过访问容器和过滤来处理大量文件,但这取决于您的业务逻辑。

      from azure.storage.blob import BlobService
      
      def azureml_main(dataframe1 = None, dataframe2 = None):
          account_name = 'mystorageaccount'
          account_key='p8kSy3FACx...redacted...ebz3plQ=='
          container_name = "upload"
      
          blob_service = BlobService(account_name, account_key, protocol='http')
      
          file = blob_service.get_blob_to_text(container_name,'myfile.txt')
          # You can also get_blob_to_(bytes|file|path), if you need to do so.
      
          # Do stuff with your file here
          #   Logic, logic, logic
      
          # Execute Python Script requires that a dataframe is returned. It can be null.
          # Return value must be of a sequence of pandas.DataFrame
          return dataframe1,
      

      有关限制,HTTP原因和其他说明的详细信息,请参阅Access Azure blog storage from within an Azure ML experiment