updated to use new class
This commit is contained in:
@@ -2,10 +2,27 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from shared.database.classes import VisualCommunication
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
from shared.data_store import connect as connect_minio
|
||||||
|
from shared.database import connect as connect_mongo
|
||||||
|
from shared.database.classes import VisualCommunication
|
||||||
|
from shared.utils import check_env
|
||||||
|
from shared.utils import setup_logging
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# load in env file
|
||||||
|
env_path = Path(__file__).parent.parent / 'server.env'
|
||||||
|
assert env_path.exists()
|
||||||
|
load_dotenv(env_path)
|
||||||
|
# ensure env vars set
|
||||||
|
check_env()
|
||||||
|
# setup logging
|
||||||
|
setup_logging()
|
||||||
|
# connect to minIO
|
||||||
|
minio_client = connect_minio()
|
||||||
|
# connect to MongoDB
|
||||||
|
collection, db, client = connect_mongo()
|
||||||
# get list of image paths
|
# get list of image paths
|
||||||
test_dir = Path(__file__).parent
|
test_dir = Path(__file__).parent
|
||||||
img_dir = test_dir / 'imgs'
|
img_dir = test_dir / 'imgs'
|
||||||
@@ -13,7 +30,7 @@ if __name__ == '__main__':
|
|||||||
print(img_path_list)
|
print(img_path_list)
|
||||||
# instantiate data object
|
# instantiate data object
|
||||||
vis_com_list = [
|
vis_com_list = [
|
||||||
VisualCommunication.from_file(path)
|
VisualCommunication.from_file(path, minio_client=minio_client)
|
||||||
for path
|
for path
|
||||||
in img_path_list
|
in img_path_list
|
||||||
]
|
]
|
||||||
|
|||||||
+17
-11
@@ -1,15 +1,29 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from pymongo.errors import DuplicateKeyError
|
from pymongo.errors import DuplicateKeyError
|
||||||
|
|
||||||
from shared.database import connect
|
from shared.data_store import connect as connect_minio
|
||||||
|
from shared.database import connect as connect_mongo
|
||||||
from shared.database.classes import VisualCommunication
|
from shared.database.classes import VisualCommunication
|
||||||
|
from shared.utils import check_env
|
||||||
|
from shared.utils import setup_logging
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# load in env file
|
||||||
|
env_path = Path(__file__).parent.parent / 'server.env'
|
||||||
|
assert env_path.exists()
|
||||||
|
load_dotenv(env_path)
|
||||||
|
# ensure env vars set
|
||||||
|
check_env()
|
||||||
|
# setup logging
|
||||||
|
setup_logging()
|
||||||
|
# connect to minIO
|
||||||
|
minio_client = connect_minio()
|
||||||
|
# connect to MongoDB
|
||||||
|
collection, db, client = connect_mongo()
|
||||||
# get list of image paths
|
# get list of image paths
|
||||||
test_dir = Path(__file__).parent
|
test_dir = Path(__file__).parent
|
||||||
img_dir = test_dir / 'imgs'
|
img_dir = test_dir / 'imgs'
|
||||||
@@ -17,20 +31,12 @@ if __name__ == '__main__':
|
|||||||
print(img_path_list)
|
print(img_path_list)
|
||||||
# instantiate data object
|
# instantiate data object
|
||||||
vis_com_list = [
|
vis_com_list = [
|
||||||
VisualCommunication.from_file(path)
|
VisualCommunication.from_file(path, minio_client=minio_client)
|
||||||
for path
|
for path
|
||||||
in img_path_list
|
in img_path_list
|
||||||
]
|
]
|
||||||
for vis_com in vis_com_list:
|
for vis_com in vis_com_list:
|
||||||
print(repr(vis_com))
|
print(repr(vis_com))
|
||||||
# prepare env vars
|
|
||||||
env_path = test_dir.parent / 'local.env'
|
|
||||||
assert env_path.exists()
|
|
||||||
load_dotenv(env_path)
|
|
||||||
os.environ['MONGO_HOST'] = 'localhost'
|
|
||||||
# connect to database
|
|
||||||
collection, db, client = connect()
|
|
||||||
print(client.server_info())
|
|
||||||
# upload images
|
# upload images
|
||||||
for vis_com in vis_com_list:
|
for vis_com in vis_com_list:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -5,10 +5,25 @@ from pathlib import Path
|
|||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from pymongo.errors import DuplicateKeyError
|
from pymongo.errors import DuplicateKeyError
|
||||||
|
|
||||||
from shared.database import connect
|
from shared.data_store import connect as connect_minio
|
||||||
|
from shared.database import connect as connect_mongo
|
||||||
from shared.database import VisualCommunication
|
from shared.database import VisualCommunication
|
||||||
|
from shared.utils import check_env
|
||||||
|
from shared.utils import setup_logging
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# load in env file
|
||||||
|
env_path = Path(__file__).parent.parent / 'server.env'
|
||||||
|
assert env_path.exists()
|
||||||
|
load_dotenv(env_path)
|
||||||
|
# ensure env vars set
|
||||||
|
check_env()
|
||||||
|
# setup logging
|
||||||
|
setup_logging()
|
||||||
|
# connect to minIO
|
||||||
|
minio_client = connect_minio()
|
||||||
|
# connect to MongoDB
|
||||||
|
collection, db, client = connect_mongo()
|
||||||
# get list of image paths
|
# get list of image paths
|
||||||
ext_img_dir = Path('/Volumes/BW-PSSD/Mixed Methods/')
|
ext_img_dir = Path('/Volumes/BW-PSSD/Mixed Methods/')
|
||||||
assert ext_img_dir.exists()
|
assert ext_img_dir.exists()
|
||||||
@@ -20,19 +35,11 @@ if __name__ == '__main__':
|
|||||||
print(f"found {len(img_path_list)} images")
|
print(f"found {len(img_path_list)} images")
|
||||||
# create visual communication objects
|
# create visual communication objects
|
||||||
vis_com_list = [
|
vis_com_list = [
|
||||||
VisualCommunication.from_file(path)
|
VisualCommunication.from_file(path, minio_client=minio_client)
|
||||||
for path
|
for path
|
||||||
in img_path_list
|
in img_path_list
|
||||||
]
|
]
|
||||||
print(f"created {len(vis_com_list)} visual communication objects")
|
print(f"created {len(vis_com_list)} visual communication objects")
|
||||||
# prepare env vars
|
|
||||||
env_path = Path(__file__).parent.parent / 'server.env'
|
|
||||||
assert env_path.exists()
|
|
||||||
load_dotenv(env_path)
|
|
||||||
# connect to database
|
|
||||||
collection, db, client = connect()
|
|
||||||
assert client.server_info() is not None
|
|
||||||
print('connected to database')
|
|
||||||
# upload images
|
# upload images
|
||||||
for vis_com in vis_com_list:
|
for vis_com in vis_com_list:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1,46 +1,42 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
from shared.database import connect
|
from shared.data_store import connect as connect_minio
|
||||||
|
from shared.database import connect as connect_mongo
|
||||||
from shared.database import upsert_prediction
|
from shared.database import upsert_prediction
|
||||||
from shared.database.classes import VisualCommunication
|
from shared.database.classes import VisualCommunication
|
||||||
|
from shared.utils import check_env
|
||||||
|
from shared.utils import setup_logging
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# load in env file
|
||||||
|
env_path = Path(__file__).parent.parent / 'server.env'
|
||||||
|
assert env_path.exists()
|
||||||
|
load_dotenv(env_path)
|
||||||
|
# ensure env vars set
|
||||||
|
check_env()
|
||||||
# setup logging
|
# setup logging
|
||||||
fmt = (
|
setup_logging()
|
||||||
'%(asctime)s | '
|
# connect to minIO
|
||||||
'%(levelname)s | '
|
minio_client = connect_minio()
|
||||||
'%(filename)s | '
|
# connect to MongoDB
|
||||||
'%(funcName)s | '
|
collection, db, client = connect_mongo()
|
||||||
'%(message)s'
|
|
||||||
)
|
|
||||||
datefmt = '%Y-%m-%d %H:%M:%S'
|
|
||||||
logging.basicConfig(format=fmt, datefmt=datefmt, level=logging.INFO)
|
|
||||||
# get list of image paths
|
# get list of image paths
|
||||||
test_dir = Path(__file__).parent
|
test_dir = Path(__file__).parent
|
||||||
img_dir = test_dir / 'imgs'
|
img_dir = test_dir / 'imgs'
|
||||||
img_path_list = [path for path in img_dir.glob('*.jpeg') if path.is_file()]
|
img_path_list = [path for path in img_dir.glob('*.jpeg') if path.is_file()]
|
||||||
# instantiate data object
|
# instantiate data object
|
||||||
vis_com_list = [
|
vis_com_list = [
|
||||||
VisualCommunication.from_file(path)
|
VisualCommunication.from_file(path, minio_client=minio_client)
|
||||||
for path
|
for path
|
||||||
in img_path_list
|
in img_path_list
|
||||||
]
|
]
|
||||||
# generate random predictions
|
# generate random predictions
|
||||||
for vis_com in vis_com_list:
|
for vis_com in vis_com_list:
|
||||||
vis_com.generate_random_prediction()
|
vis_com.generate_random_prediction()
|
||||||
# prepare env vars
|
|
||||||
env_path = test_dir.parent / 'local.env'
|
|
||||||
assert env_path.exists()
|
|
||||||
load_dotenv(env_path)
|
|
||||||
os.environ['MONGO_HOST'] = 'localhost'
|
|
||||||
# connect to database
|
|
||||||
collection, db, client = connect()
|
|
||||||
# upload visual communication
|
# upload visual communication
|
||||||
for vis_com in vis_com_list:
|
for vis_com in vis_com_list:
|
||||||
if vis_com.prediction is None:
|
if vis_com.prediction is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user