-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
29 lines (23 loc) · 834 Bytes
/
setup.py
File metadata and controls
29 lines (23 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import certifi
import matlab.engine
from pymongo import MongoClient
import os
from dotenv import load_dotenv
def setup_resources():
# Load environment variables
load_dotenv()
# Database constants
MONGO_URI = os.getenv("mongodb_uri")
DATABASE_NAME = "matlab"
COLLECTION_NAME = "matlab"
# Create MongoDB client and get collection
mongo_client = MongoClient(MONGO_URI, tlsCAFile=certifi.where())
db = mongo_client[DATABASE_NAME]
collection = db[COLLECTION_NAME]
# Start MATLAB engine
matlab_engine = matlab.engine.start_matlab()
return matlab_engine, collection, mongo_client
if __name__ == "__main__":
matlab_engine, collection, mongo_client = setup_resources()
print("Resources set up successfully.")
print("Don't forget to close these resources when you're done!")