none
Import MongoDB data to Azure ML from Python Script

    Question

  • Currently in Azure ML's while executing python script, I have following code. (Python 2.7.11) 
    In which results obtained from the mongoDB are trying to return in DataFrame using pyMongo. 

    I get an error like ::
    "C:\pyhome\lib\site-packages\pymongo\topology.py", line 97, in select_servers
        self._error_message(selector))
    ServerSelectionTimeoutError: ... ('The write operation timed out',)
    Please let me know if you know about the cause of the error and what to improve. 

    Source code :
    import pymongo as m
    import pandas as pd

    def azureml_main(dataframe1 = None, dataframe2 = None):

    uri = "mongodb://xxxxx:yyyyyyyyyyyyyyy@zzz.mongodb.net: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 Details:
    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



    • Edited by Pc Offer Friday, February 1, 2019 12:10 PM
    Friday, February 1, 2019 10:37 AM

All replies

  • Hi,

    I have seen one similar issue in MSDN. We'd like to work with you further on this issue. Can you please email us at azcommunity@microsoft.com? Please provide us with your subscription ID and the URL for this thread.

    Regards,

    Yutong

    Thursday, February 7, 2019 6:36 PM
    Moderator