DAPPER (Document Analysis, Processing, and Pattern Extraction Repository)
Statistical Learning Final Project for Document Classification
 
Loading...
Searching...
No Matches
classification.data.minio_handler.MinioManager Class Reference

Manager class for MinIO object storage operations. More...

Collaboration diagram for classification.data.minio_handler.MinioManager:
Collaboration graph

Public Member Functions

 __init__ (self, endpoint="localhost:9900", access_key="minioadmin", secret_key="minioadmin", bucket_name="dapper", bool secure=False)
 Constructor for MinioManager class.
 
str upload_image (self, Image.Image image, str filename)
 Uploads an image to MinIO storage.
 
Optional[tuple] process_row (self, int index, pd.Series row)
 Processes a single row from a DataFrame for upload.
 
pd.DataFrame upload_dataframe (self, pd.DataFrame df, int max_workers=12)
 Uploads all images from a DataFrame to MinIO.
 

Public Attributes

 client
 
 endpoint
 
 bucket_name
 
 all_images
 

Protected Member Functions

 _refresh_object_list (self)
 Refreshes the list of objects in the bucket.
 
str _generate_filename (self, str label, int index, str source, bool is_augmented)
 Generates a standardized filename for image storage.
 

Detailed Description

Manager class for MinIO object storage operations.

This class provides methods for interacting with MinIO object storage, including uploading images, managing buckets, and organizing data with consistent naming conventions for document classification tasks.

Constructor & Destructor Documentation

◆ __init__()

classification.data.minio_handler.MinioManager.__init__ (   self,
  endpoint = "localhost:9900",
  access_key = "minioadmin",
  secret_key = "minioadmin",
  bucket_name = "dapper",
bool   secure = False 
)

Constructor for MinioManager class.

Parameters
endpointMinIO server endpoint URL
access_keyMinIO access key
secret_keyMinIO secret key
bucket_nameName of the MinIO bucket to use
secureUse TLS for MinIO connection

Member Function Documentation

◆ _generate_filename()

str classification.data.minio_handler.MinioManager._generate_filename (   self,
str  label,
int  index,
str  source,
bool  is_augmented 
)
protected

Generates a standardized filename for image storage.

Parameters
labelClass label for the image
indexIndex of the image in the dataset
sourceSource dataset name
is_augmentedWhether the image is an augmented version
Returns
Standardized filename for MinIO storage

◆ _refresh_object_list()

classification.data.minio_handler.MinioManager._refresh_object_list (   self)
protected

Refreshes the list of objects in the bucket.

Updates the internal cache of object names in the MinIO bucket to track which images have already been uploaded.

◆ process_row()

Optional[tuple] classification.data.minio_handler.MinioManager.process_row (   self,
int  index,
pd.Series  row 
)

Processes a single row from a DataFrame for upload.

Parameters
indexIndex of the row in the DataFrame
rowSeries containing image and metadata
Returns
Tuple of (index, URL) or (index, None) if processing failed

◆ upload_dataframe()

pd.DataFrame classification.data.minio_handler.MinioManager.upload_dataframe (   self,
pd.DataFrame  df,
int   max_workers = 12 
)

Uploads all images from a DataFrame to MinIO.

Parameters
dfDataFrame containing images and metadata
max_workersMaximum number of worker threads for parallel processing
Returns
DataFrame with updated image URLs

◆ upload_image()

str classification.data.minio_handler.MinioManager.upload_image (   self,
Image.Image  image,
str  filename 
)

Uploads an image to MinIO storage.

Parameters
imagePIL Image to upload
filenameName to use for the uploaded file
Returns
URL of the uploaded image

Member Data Documentation

◆ all_images

classification.data.minio_handler.MinioManager.all_images

◆ bucket_name

classification.data.minio_handler.MinioManager.bucket_name

◆ client

classification.data.minio_handler.MinioManager.client

◆ endpoint

classification.data.minio_handler.MinioManager.endpoint

The documentation for this class was generated from the following file: