Coder Social home page Coder Social logo

Comments (5)

madhubandru avatar madhubandru commented on August 19, 2024

Hi, we have tested mongoDB connection and able to write cleaned raw data into database, which ensured that connection is established. You can have a look at test case under Tests>>Automate Test cases>>test_ai.py

Revert to us in case of any questions.

from dxc-industrialized-ai-starter.

Amarify avatar Amarify commented on August 19, 2024

I saw the code below in test_ai.py. It seems if for any reason the connection things didn't workout it will print mongodb connnection failed. I am looking for something to test api keys specifically.

Let's say before starting a project i want to ensure my keys are working. I import the ai library...i don't have the dataset yet. How do i test my keys in this scenraio.

Note : Assuming i understood below code correctly.

    try:
        wrt_raw_data = ai.write_raw_data(data_layer, raw_data, date_fields)
    except:
        print('----------MONGODB CONNECTION FAILED----------')

from dxc-industrialized-ai-starter.

kishorpulagam92 avatar kishorpulagam92 commented on August 19, 2024

Hello @Amar244. You can use below code snippet to check MongoDB connection.

from pymongo import MongoClient
client = MongoClient("mongodb://{user}:{password}@{host}:{port}")
db = client.{database}
try: db.command("serverStatus")
except Exception as e: print(e)
else: print("You are connected!")
client.close()

In our test cases we are focusing on complete end to end testing in MongoDB data insertion. When we run our tests then automatically it will take care about this connection string also.

If you have any doubts in using above code snippet, please reach out to me I can help you.

from dxc-industrialized-ai-starter.

Amarify avatar Amarify commented on August 19, 2024

Hi ,

If i understand correctly the above code works if you have a password and a username. However i do believe this AI Library takes api keys as input to connect to the server. i am looking for something like ai.test_keys() method or function to return True or False if my keys are working and able to reach the server.

from dxc-industrialized-ai-starter.

Amarify avatar Amarify commented on August 19, 2024

Hi @npulagam ,

The code you presented seems to provide a way for me to test to my connection.

Thank you.

from pymongo import MongoClient
client = MongoClient("mongodb://{user}:{password}@{host}:{port}")
db = client.{database}
try: db.command("serverStatus")
except Exception as e: print(e)
else: print("You are connected!")
client.close()

from dxc-industrialized-ai-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.