31 lines
879 B
Python
31 lines
879 B
Python
from __future__ import annotations
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
from shared.docstore import connect_mongodb
|
|
from shared.docstore.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())
|