from __future__ import annotations import os from pathlib import Path from dotenv import load_dotenv from shared.mongodb import connect_mongodb from shared.mongodb.classes import VisualCommunication if __name__ == '__main__': # prepare env vars env_path = Path(__file__).parent.parent / 'local.env' assert env_path.exists() load_dotenv(env_path) os.environ['MONGO_HOST'] = 'localhost' # connect to database collection, db, client = connect_mongodb() print(client.server_info()) # download images data = None for data in collection.find().limit(3): if data is None: print('no document found') break vis_com: VisualCommunication = VisualCommunication.model_validate(data) print(repr(vis_com)) if data is not None: print(vis_com.image) print(vis_com.model_dump())