move_images_to_minio #44
@@ -2,10 +2,27 @@ from __future__ import annotations
|
||||
|
||||
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__':
|
||||
# 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
|
||||
test_dir = Path(__file__).parent
|
||||
img_dir = test_dir / 'imgs'
|
||||
@@ -13,7 +30,7 @@ if __name__ == '__main__':
|
||||
print(img_path_list)
|
||||
# instantiate data object
|
||||
vis_com_list = [
|
||||
VisualCommunication.from_file(path)
|
||||
VisualCommunication.from_file(path, minio_client=minio_client)
|
||||
for path
|
||||
in img_path_list
|
||||
]
|
||||
|
||||
+17
-11
@@ -1,15 +1,29 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
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.utils import check_env
|
||||
from shared.utils import setup_logging
|
||||
|
||||
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
|
||||
test_dir = Path(__file__).parent
|
||||
img_dir = test_dir / 'imgs'
|
||||
@@ -17,20 +31,12 @@ if __name__ == '__main__':
|
||||
print(img_path_list)
|
||||
# instantiate data object
|
||||
vis_com_list = [
|
||||
VisualCommunication.from_file(path)
|
||||
VisualCommunication.from_file(path, minio_client=minio_client)
|
||||
for path
|
||||
in img_path_list
|
||||
]
|
||||
for vis_com in vis_com_list:
|
||||
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
|
||||
for vis_com in vis_com_list:
|
||||
try:
|
||||
|
||||
@@ -5,10 +5,25 @@ from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
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.utils import check_env
|
||||
from shared.utils import setup_logging
|
||||
|
||||
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
|
||||
ext_img_dir = Path('/Volumes/BW-PSSD/Mixed Methods/')
|
||||
assert ext_img_dir.exists()
|
||||
@@ -20,19 +35,11 @@ if __name__ == '__main__':
|
||||
print(f"found {len(img_path_list)} images")
|
||||
# create visual communication objects
|
||||
vis_com_list = [
|
||||
VisualCommunication.from_file(path)
|
||||
VisualCommunication.from_file(path, minio_client=minio_client)
|
||||
for path
|
||||
in img_path_list
|
||||
]
|
||||
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
|
||||
for vis_com in vis_com_list:
|
||||
try:
|
||||
|
||||
@@ -1,46 +1,42 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
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.classes import VisualCommunication
|
||||
from shared.utils import check_env
|
||||
from shared.utils import setup_logging
|
||||
|
||||
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
|
||||
fmt = (
|
||||
'%(asctime)s | '
|
||||
'%(levelname)s | '
|
||||
'%(filename)s | '
|
||||
'%(funcName)s | '
|
||||
'%(message)s'
|
||||
)
|
||||
datefmt = '%Y-%m-%d %H:%M:%S'
|
||||
logging.basicConfig(format=fmt, datefmt=datefmt, level=logging.INFO)
|
||||
setup_logging()
|
||||
# connect to minIO
|
||||
minio_client = connect_minio()
|
||||
# connect to MongoDB
|
||||
collection, db, client = connect_mongo()
|
||||
# get list of image paths
|
||||
test_dir = Path(__file__).parent
|
||||
img_dir = test_dir / 'imgs'
|
||||
img_path_list = [path for path in img_dir.glob('*.jpeg') if path.is_file()]
|
||||
# instantiate data object
|
||||
vis_com_list = [
|
||||
VisualCommunication.from_file(path)
|
||||
VisualCommunication.from_file(path, minio_client=minio_client)
|
||||
for path
|
||||
in img_path_list
|
||||
]
|
||||
# generate random predictions
|
||||
for vis_com in vis_com_list:
|
||||
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
|
||||
for vis_com in vis_com_list:
|
||||
if vis_com.prediction is None:
|
||||
|
||||
Reference in New Issue
Block a user