目前在Azure中ML的同时执行python脚本,用下面的代码。在这导致从得到的MongoDB(Python的2.7.11)尝试使用pyMongo在数据帧返回。
我得到了一个错误,如::
"C:\pyhome\lib\site-packages\pymongo\topology.py", line 97, in select_servers
self._error_message(selector))
ServerSelectionTimeoutError: ... ('The write operation timed out',)
请让我知道,如果你知道错误的原因和如何改进。
我的源代码:
import pymongo as m
import pandas as pd
def azureml_main(dataframe1 = None, dataframe2 = None):
uri = "mongodb://xxxxx:[email protected]:xxxxx/?ssl=true&replicaSet=globaldb"
client = m.MongoClient(uri,connect=False)
db = client['dbName']
coll = db['colectionName']
cursor = coll.find()
df = pd.DataFrame(list(cursor))
return df,
错误详情:
Error 0085: The following error occurred during script evaluation, please view the output log for more information:
---------- Start of error message from Python interpreter ----------
Caught exception while executing function: Traceback (most recent call last):
File "C:\server\invokepy.py", line 199, in batch
odfs = mod.azureml_main(*idfs)
File "C:\temp\55a174d8dc584942908423ebc0bac110.py", line 32, in azureml_main
result = pd.DataFrame(list(cursor))
File "C:\pyhome\lib\site-packages\pymongo\cursor.py", line 977, in next
if len(self.__data) or self._refresh():
File "C:\pyhome\lib\site-packages\pymongo\cursor.py", line 902, in _refresh
self.__read_preference))
File "C:\pyhome\lib\site-packages\pymongo\cursor.py", line 813, in __send_message
**kwargs)
File "C:\pyhome\lib\site-packages\pymongo\mongo_client.py", line 728, in _send_message_with_response
server = topology.select_server(selector)
File "C:\pyhome\lib\site-packages\pymongo\topology.py", line 121, in select_server
address))
File "C:\pyhome\lib\site-packages\pymongo\topology.py", line 97, in select_servers
self._error_message(selector))
ServerSelectionTimeoutError: xxxxx-xxx.mongodb.net:xxxxx: ('The write operation timed out',)
Process returned with non-zero exit code 1
正如我知道,有Execute Python Scripts
的限制,这将导致该问题,请参阅部分Limitations
知道它,如下图所示。
限制
在执行Python脚本目前有以下限制:
- 沙盒执行。 Python运行时正在沙箱和,因此,不允许在一个持续的方式访问网络或本地文件系统。本地保存的所有文件都是孤立的,一旦模块完成删除。 Python的代码无法访问的机器上大多数目录在其上运行,唯一的例外是在当前目录及其子目录。
由于上述原因,你不能直接在网上通过在pymongo
模块Execute Python Script
驱动程序导入从Azure的宇宙数据库中的数据。但是你可以使用Import Data
模块的连接和参数的Azure的宇宙DB的信息和它的输出连接到Execute Python Script
的输入来获取数据,如下图所示。
欲了解更多信息网上的数据导入,请参考官方文档Import from online data sources
的部分Import your training data into Azure Machine Learning Studio from various data sources
。