summaryrefslogtreecommitdiff
path: root/megapixels/app/utils
diff options
context:
space:
mode:
authoradamhrv <adam@ahprojects.com>2018-12-16 01:03:07 +0100
committeradamhrv <adam@ahprojects.com>2018-12-16 01:03:07 +0100
commita52dc6f8edc4e5d00e7c05e34c6c6fe6252ec2bd (patch)
tree98f6bdfc1985590cf5db0580bf0a18eed6198656 /megapixels/app/utils
parent82b2c0b5d6d7baccbe4d574d96e18fe2078047d7 (diff)
add Dataset model, stub face_*analsysi
Diffstat (limited to 'megapixels/app/utils')
-rw-r--r--megapixels/app/utils/path_utils.py50
1 files changed, 34 insertions, 16 deletions
diff --git a/megapixels/app/utils/path_utils.py b/megapixels/app/utils/path_utils.py
index ddbc2864..b0262ea0 100644
--- a/megapixels/app/utils/path_utils.py
+++ b/megapixels/app/utils/path_utils.py
@@ -5,30 +5,48 @@ import logging
from app.settings import app_cfg as cfg
from app.settings import types
-
-# class properties
-DATA_STORE = cfg.DATA_STORE
-DIR_DATSETs = cfg.DIR_DATSET_NAS
-DIR_DATASETS = join(DATA_STORE, 'datasets')
-DIR_PEOPLE = 'datasets/people'
# -------------------------------------------------------------------------
-# Metadata
+# Metadata and media files
# -------------------------------------------------------------------------
-def data_store_dir(opt_data_store):
- return f'/data_store_{opt_data_store.name.lower()}'
+class DataStore:
+ # local data store
+ def __init__(self, opt_data_store, opt_dataset):
+ self.data_store = join(f'/data_store_{opt_data_store.name.lower()}')
+ self.dir_dataset = join(self.data_store, 'datasets', cfg.DIR_PEOPLE, opt_dataset.name.lower())
+ self.dir_media = join(self.dir_dataset, 'media')
+ self.dir_metadata = join(self.dir_dataset, 'metadata')
-def dataset_dir(opt_dataset):
- return f'{opt_dataset.name.lower()}'
+ def metadata(self, enum_type):
+ return join(self.dir_metadata, f'{enum_type.name.lower()}.csv')
-def metadata_dir(opt_data_store, opt_dataset):
- return join(data_store_dir(opt_data_store), DIR_PEOPLE, dataset_dir(opt_dataset), 'metadata')
+ def face_image(self, subdir, fn, ext):
+ return join(self.dir_media, 'original', subdir, f'{fn}.{ext}')
+
+ def face_image_crop(self, subdir, fn, ext):
+ return join(self.dir_media, 'cropped', subdir, f'{fn}.{ext}')
+
+
+class DataStoreS3:
+ # S3 server
+ def __init__(self, opt_dataset):
+ self._dir_media = join(cfg.S3_HTTP_MEDIA_URL, opt_dataset.name.lower())
+ self._dir_metadata = join(cfg.S3_HTTP_METADATA_URL, opt_dataset.name.lower())
+
+ def metadata(self, opt_metadata_type, ext='csv'):
+ return join(self._dir_metadata, f'{opt_metadata_type.name.lower()}.{ext}')
+
+ def face_image(self, opt_uuid, ext='jpg'):
+ #return join(self._dir_media, 'original', f'{opt_uuid}.{ext}')
+ return join(self._dir_media, f'{opt_uuid}.{ext}')
+
+ def face_image_crop(self, opt_uuid, ext='jpg'):
+ # not currently using?
+ return join(self._dir_media, 'cropped', f'{opt_uuid}.{ext}')
-def metadata(opt_data_store, opt_dataset, opt_metadata):
- return join(metadata_dir(opt_data_store, opt_dataset), f'{opt_metadata.name.lower()}.csv')
# -------------------------------------------------------------------------
-# Media
+# Models
# ------------------------------------------------------------------------- \ No newline at end of file