小编Ste*_*org的帖子

从Azure ML实验中访问Azure博客存储

Azure ML实验提供了通过ReaderWriter模块将CSV文件读取和写入Azure blob存储的方法.但是,我需要将一个JSON文件写入blob存储.由于没有模块可以这样做,我试图在一个Execute Python Script模块中这样做.

# Import the necessary items
from azure.storage.blob import BlobService

def azureml_main(dataframe1 = None, dataframe2 = None):
    account_name = 'mystorageaccount'
    account_key='mykeyhere=='
    json_string='{jsonstring here}'

    blob_service = BlobService(account_name, account_key)

    blob_service.put_block_blob_from_text("upload","out.json",json_string)

    # Return value must be of a sequence of pandas.DataFrame
    return dataframe1,
Run Code Online (Sandbox Code Playgroud)

但是,这会导致错误: ImportError: No module named azure.storage.blob

这意味着azure-storageAzure包上未安装Python包.

如何从Azure ML实验中写入Azure blob存储?

这是填充错误消息:

Error 0085: The following error occurred during script evaluation, please view the output log for more information: …
Run Code Online (Sandbox Code Playgroud)

python azure azure-machine-learning-studio cortana-intelligence

14
推荐指数
1
解决办法
3407
查看次数

如何在 Python 中使用 httpx(相对于 aiohttp)发出并行异步 HTTP 请求?

这是基于一个错字和简单的错误。

不删除,因为它有 httpx 的示例代码。

我正在尝试利用asyncio并行化几个长时间运行的 Web 请求。因为我是从requests库中迁移过来的,所以我想使用这个httpx库,因为它有类似的 API。我的环境是 Python 3.7.7 Anaconda 发行版,其中安装了所有必需的软件包(Windows 10)。

然而,尽管能够httpx用于同步 Web 请求(或用于串行执行一个接一个运行的异步请求),但我无法成功地一次运行多个异步请求,尽管使用aiohttp库很容易做到这一点.

这是在aiohttp: (请注意,我在 Jupyter 中运行,所以我已经有一个事件循环,因此缺少asyncio.run().

import aiohttp
import asyncio
import time
import httpx

async def call_url(session):
    url = "https://services.cancerimagingarchive.net/services/v3/TCIA/query/getCollectionValues"        
    response = await session.request(method='GET', url=url)
    #response.raise_for_status() 
    return response

for i in range(1,5):
    start = time.time() # start time for timing event
    async with aiohttp.ClientSession() as session: #use aiohttp
    #async with httpx.AsyncClient as …
Run Code Online (Sandbox Code Playgroud)

python asynchronous python-asyncio aiohttp

5
推荐指数
2
解决办法
4818
查看次数