SmartShelf-Project 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- smartshelf_project-1.1.0/PKG-INFO +86 -0
- smartshelf_project-1.1.0/README.md +76 -0
- smartshelf_project-1.1.0/SmartShelf_Project.egg-info/PKG-INFO +86 -0
- smartshelf_project-1.1.0/SmartShelf_Project.egg-info/SOURCES.txt +7 -0
- smartshelf_project-1.1.0/SmartShelf_Project.egg-info/dependency_links.txt +1 -0
- smartshelf_project-1.1.0/SmartShelf_Project.egg-info/top_level.txt +1 -0
- smartshelf_project-1.1.0/cloud_utils.py +77 -0
- smartshelf_project-1.1.0/pyproject.toml +19 -0
- smartshelf_project-1.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: SmartShelf-Project
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: A simple demo Python library
|
|
5
|
+
Author-email: Vedant Bandarkar <vedantbandarkar@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/VedantB-sudo/SmartShelfProject
|
|
8
|
+
Requires-Python: >=3.7
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
SmartCloudManager
|
|
12
|
+
SmartCloudManager is a high-level Python library designed to simplify and encapsulate complex AWS service interactions. Developed as part of a Master’s level Cloud Platform Programming project at the National College of Ireland, this library provides a streamlined interface for Amazon Textract, DynamoDB, S3, and SES.
|
|
13
|
+
|
|
14
|
+
By abstracting low-level Boto3 API calls into a clean, object-oriented structure, SmartCloudManager allows developers to implement robust cloud-native functionalities with minimal boilerplate code.
|
|
15
|
+
|
|
16
|
+
Key Features
|
|
17
|
+
The library utilizes Advanced Programming Constructs to ensure efficiency and reliability:
|
|
18
|
+
|
|
19
|
+
Context Manager Support: Implements __enter__ and __exit__ for safe resource handling and clean session management.
|
|
20
|
+
|
|
21
|
+
Lazy Loading Pattern: AWS clients (Textract, DynamoDB, S3) are only initialized when first accessed, reducing memory overhead and improving startup performance.
|
|
22
|
+
|
|
23
|
+
Automated Telemetry: Built-in methods for real-time stock updates in Amazon DynamoDB using optimized UpdateExpressions.
|
|
24
|
+
|
|
25
|
+
AI-Driven Extraction: Simplified interface for Amazon Textract form analysis to convert document images into structured Python dictionaries.
|
|
26
|
+
|
|
27
|
+
Installation
|
|
28
|
+
You can install the library directly from PyPI using pip:
|
|
29
|
+
|
|
30
|
+
Bash
|
|
31
|
+
pip install smart-cloud-manager
|
|
32
|
+
Requirements
|
|
33
|
+
The library requires boto3. Before execution, ensure you have your AWS credentials configured in your environment or via the AWS CLI:
|
|
34
|
+
|
|
35
|
+
AWS_ACCESS_KEY_ID
|
|
36
|
+
|
|
37
|
+
AWS_SECRET_ACCESS_KEY
|
|
38
|
+
|
|
39
|
+
AWS_SESSION_TOKEN (if using temporary credentials)
|
|
40
|
+
|
|
41
|
+
AWS_DEFAULT_REGION (Defaults to us-east-1)
|
|
42
|
+
|
|
43
|
+
Implementation Guide
|
|
44
|
+
1. Basic Usage with Context Manager
|
|
45
|
+
The recommended way to use the library is with a with statement. This ensures that resources are handled correctly according to Pythonic best practices.
|
|
46
|
+
|
|
47
|
+
Python
|
|
48
|
+
from smart_cloud_manager import SmartCloudManager
|
|
49
|
+
|
|
50
|
+
# Initialize the manager within a context
|
|
51
|
+
with SmartCloudManager(region_name="us-east-1") as cloud:
|
|
52
|
+
print("Cloud Manager session initialized successfully.")
|
|
53
|
+
# Perform operations here
|
|
54
|
+
2. Document Analysis (Amazon Textract)
|
|
55
|
+
The library abstracts the complex JSON response from Textract into a more manageable format for inventory applications.
|
|
56
|
+
|
|
57
|
+
Python
|
|
58
|
+
with SmartCloudManager() as cloud:
|
|
59
|
+
# Analyzes an invoice or document stored in S3
|
|
60
|
+
extracted_data = cloud.extract_inventory_data(
|
|
61
|
+
bucket_name="your-s3-bucket-name",
|
|
62
|
+
document_name="invoice_sample.jpg"
|
|
63
|
+
)
|
|
64
|
+
print(f"Extracted Results: {extracted_data}")
|
|
65
|
+
3. Real-Time Inventory Telemetry (Amazon DynamoDB)
|
|
66
|
+
Update stock levels or sensor data directly without writing raw Boto3 dictionary structures.
|
|
67
|
+
|
|
68
|
+
Python
|
|
69
|
+
with SmartCloudManager() as cloud:
|
|
70
|
+
success = cloud.update_stock_telemetry(
|
|
71
|
+
table_name="InventoryLog",
|
|
72
|
+
item_id="PROD-102",
|
|
73
|
+
quantity=15
|
|
74
|
+
)
|
|
75
|
+
if success:
|
|
76
|
+
print("Telemetry successfully updated in DynamoDB.")
|
|
77
|
+
Technical Architecture
|
|
78
|
+
This library is designed to fulfill the LO3 (formulate and produce new code libraries) and LO4 (apply advanced programming constructs) requirements of the MSCCLOUD curriculum.
|
|
79
|
+
|
|
80
|
+
By separating service-specific logic from the main Django application views, the architecture promotes high cohesion and low coupling. The use of a private helper method _parse_textract_response demonstrates proper encapsulation and internal data transformation logic.
|
|
81
|
+
|
|
82
|
+
License
|
|
83
|
+
Distributed under the MIT License. See LICENSE for more information.
|
|
84
|
+
|
|
85
|
+
Authors
|
|
86
|
+
Developed for the National College of Ireland (NCI) - Cloud Platform Programming Module.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
SmartCloudManager
|
|
2
|
+
SmartCloudManager is a high-level Python library designed to simplify and encapsulate complex AWS service interactions. Developed as part of a Master’s level Cloud Platform Programming project at the National College of Ireland, this library provides a streamlined interface for Amazon Textract, DynamoDB, S3, and SES.
|
|
3
|
+
|
|
4
|
+
By abstracting low-level Boto3 API calls into a clean, object-oriented structure, SmartCloudManager allows developers to implement robust cloud-native functionalities with minimal boilerplate code.
|
|
5
|
+
|
|
6
|
+
Key Features
|
|
7
|
+
The library utilizes Advanced Programming Constructs to ensure efficiency and reliability:
|
|
8
|
+
|
|
9
|
+
Context Manager Support: Implements __enter__ and __exit__ for safe resource handling and clean session management.
|
|
10
|
+
|
|
11
|
+
Lazy Loading Pattern: AWS clients (Textract, DynamoDB, S3) are only initialized when first accessed, reducing memory overhead and improving startup performance.
|
|
12
|
+
|
|
13
|
+
Automated Telemetry: Built-in methods for real-time stock updates in Amazon DynamoDB using optimized UpdateExpressions.
|
|
14
|
+
|
|
15
|
+
AI-Driven Extraction: Simplified interface for Amazon Textract form analysis to convert document images into structured Python dictionaries.
|
|
16
|
+
|
|
17
|
+
Installation
|
|
18
|
+
You can install the library directly from PyPI using pip:
|
|
19
|
+
|
|
20
|
+
Bash
|
|
21
|
+
pip install smart-cloud-manager
|
|
22
|
+
Requirements
|
|
23
|
+
The library requires boto3. Before execution, ensure you have your AWS credentials configured in your environment or via the AWS CLI:
|
|
24
|
+
|
|
25
|
+
AWS_ACCESS_KEY_ID
|
|
26
|
+
|
|
27
|
+
AWS_SECRET_ACCESS_KEY
|
|
28
|
+
|
|
29
|
+
AWS_SESSION_TOKEN (if using temporary credentials)
|
|
30
|
+
|
|
31
|
+
AWS_DEFAULT_REGION (Defaults to us-east-1)
|
|
32
|
+
|
|
33
|
+
Implementation Guide
|
|
34
|
+
1. Basic Usage with Context Manager
|
|
35
|
+
The recommended way to use the library is with a with statement. This ensures that resources are handled correctly according to Pythonic best practices.
|
|
36
|
+
|
|
37
|
+
Python
|
|
38
|
+
from smart_cloud_manager import SmartCloudManager
|
|
39
|
+
|
|
40
|
+
# Initialize the manager within a context
|
|
41
|
+
with SmartCloudManager(region_name="us-east-1") as cloud:
|
|
42
|
+
print("Cloud Manager session initialized successfully.")
|
|
43
|
+
# Perform operations here
|
|
44
|
+
2. Document Analysis (Amazon Textract)
|
|
45
|
+
The library abstracts the complex JSON response from Textract into a more manageable format for inventory applications.
|
|
46
|
+
|
|
47
|
+
Python
|
|
48
|
+
with SmartCloudManager() as cloud:
|
|
49
|
+
# Analyzes an invoice or document stored in S3
|
|
50
|
+
extracted_data = cloud.extract_inventory_data(
|
|
51
|
+
bucket_name="your-s3-bucket-name",
|
|
52
|
+
document_name="invoice_sample.jpg"
|
|
53
|
+
)
|
|
54
|
+
print(f"Extracted Results: {extracted_data}")
|
|
55
|
+
3. Real-Time Inventory Telemetry (Amazon DynamoDB)
|
|
56
|
+
Update stock levels or sensor data directly without writing raw Boto3 dictionary structures.
|
|
57
|
+
|
|
58
|
+
Python
|
|
59
|
+
with SmartCloudManager() as cloud:
|
|
60
|
+
success = cloud.update_stock_telemetry(
|
|
61
|
+
table_name="InventoryLog",
|
|
62
|
+
item_id="PROD-102",
|
|
63
|
+
quantity=15
|
|
64
|
+
)
|
|
65
|
+
if success:
|
|
66
|
+
print("Telemetry successfully updated in DynamoDB.")
|
|
67
|
+
Technical Architecture
|
|
68
|
+
This library is designed to fulfill the LO3 (formulate and produce new code libraries) and LO4 (apply advanced programming constructs) requirements of the MSCCLOUD curriculum.
|
|
69
|
+
|
|
70
|
+
By separating service-specific logic from the main Django application views, the architecture promotes high cohesion and low coupling. The use of a private helper method _parse_textract_response demonstrates proper encapsulation and internal data transformation logic.
|
|
71
|
+
|
|
72
|
+
License
|
|
73
|
+
Distributed under the MIT License. See LICENSE for more information.
|
|
74
|
+
|
|
75
|
+
Authors
|
|
76
|
+
Developed for the National College of Ireland (NCI) - Cloud Platform Programming Module.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: SmartShelf-Project
|
|
3
|
+
Version: 1.1.0
|
|
4
|
+
Summary: A simple demo Python library
|
|
5
|
+
Author-email: Vedant Bandarkar <vedantbandarkar@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/VedantB-sudo/SmartShelfProject
|
|
8
|
+
Requires-Python: >=3.7
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
SmartCloudManager
|
|
12
|
+
SmartCloudManager is a high-level Python library designed to simplify and encapsulate complex AWS service interactions. Developed as part of a Master’s level Cloud Platform Programming project at the National College of Ireland, this library provides a streamlined interface for Amazon Textract, DynamoDB, S3, and SES.
|
|
13
|
+
|
|
14
|
+
By abstracting low-level Boto3 API calls into a clean, object-oriented structure, SmartCloudManager allows developers to implement robust cloud-native functionalities with minimal boilerplate code.
|
|
15
|
+
|
|
16
|
+
Key Features
|
|
17
|
+
The library utilizes Advanced Programming Constructs to ensure efficiency and reliability:
|
|
18
|
+
|
|
19
|
+
Context Manager Support: Implements __enter__ and __exit__ for safe resource handling and clean session management.
|
|
20
|
+
|
|
21
|
+
Lazy Loading Pattern: AWS clients (Textract, DynamoDB, S3) are only initialized when first accessed, reducing memory overhead and improving startup performance.
|
|
22
|
+
|
|
23
|
+
Automated Telemetry: Built-in methods for real-time stock updates in Amazon DynamoDB using optimized UpdateExpressions.
|
|
24
|
+
|
|
25
|
+
AI-Driven Extraction: Simplified interface for Amazon Textract form analysis to convert document images into structured Python dictionaries.
|
|
26
|
+
|
|
27
|
+
Installation
|
|
28
|
+
You can install the library directly from PyPI using pip:
|
|
29
|
+
|
|
30
|
+
Bash
|
|
31
|
+
pip install smart-cloud-manager
|
|
32
|
+
Requirements
|
|
33
|
+
The library requires boto3. Before execution, ensure you have your AWS credentials configured in your environment or via the AWS CLI:
|
|
34
|
+
|
|
35
|
+
AWS_ACCESS_KEY_ID
|
|
36
|
+
|
|
37
|
+
AWS_SECRET_ACCESS_KEY
|
|
38
|
+
|
|
39
|
+
AWS_SESSION_TOKEN (if using temporary credentials)
|
|
40
|
+
|
|
41
|
+
AWS_DEFAULT_REGION (Defaults to us-east-1)
|
|
42
|
+
|
|
43
|
+
Implementation Guide
|
|
44
|
+
1. Basic Usage with Context Manager
|
|
45
|
+
The recommended way to use the library is with a with statement. This ensures that resources are handled correctly according to Pythonic best practices.
|
|
46
|
+
|
|
47
|
+
Python
|
|
48
|
+
from smart_cloud_manager import SmartCloudManager
|
|
49
|
+
|
|
50
|
+
# Initialize the manager within a context
|
|
51
|
+
with SmartCloudManager(region_name="us-east-1") as cloud:
|
|
52
|
+
print("Cloud Manager session initialized successfully.")
|
|
53
|
+
# Perform operations here
|
|
54
|
+
2. Document Analysis (Amazon Textract)
|
|
55
|
+
The library abstracts the complex JSON response from Textract into a more manageable format for inventory applications.
|
|
56
|
+
|
|
57
|
+
Python
|
|
58
|
+
with SmartCloudManager() as cloud:
|
|
59
|
+
# Analyzes an invoice or document stored in S3
|
|
60
|
+
extracted_data = cloud.extract_inventory_data(
|
|
61
|
+
bucket_name="your-s3-bucket-name",
|
|
62
|
+
document_name="invoice_sample.jpg"
|
|
63
|
+
)
|
|
64
|
+
print(f"Extracted Results: {extracted_data}")
|
|
65
|
+
3. Real-Time Inventory Telemetry (Amazon DynamoDB)
|
|
66
|
+
Update stock levels or sensor data directly without writing raw Boto3 dictionary structures.
|
|
67
|
+
|
|
68
|
+
Python
|
|
69
|
+
with SmartCloudManager() as cloud:
|
|
70
|
+
success = cloud.update_stock_telemetry(
|
|
71
|
+
table_name="InventoryLog",
|
|
72
|
+
item_id="PROD-102",
|
|
73
|
+
quantity=15
|
|
74
|
+
)
|
|
75
|
+
if success:
|
|
76
|
+
print("Telemetry successfully updated in DynamoDB.")
|
|
77
|
+
Technical Architecture
|
|
78
|
+
This library is designed to fulfill the LO3 (formulate and produce new code libraries) and LO4 (apply advanced programming constructs) requirements of the MSCCLOUD curriculum.
|
|
79
|
+
|
|
80
|
+
By separating service-specific logic from the main Django application views, the architecture promotes high cohesion and low coupling. The use of a private helper method _parse_textract_response demonstrates proper encapsulation and internal data transformation logic.
|
|
81
|
+
|
|
82
|
+
License
|
|
83
|
+
Distributed under the MIT License. See LICENSE for more information.
|
|
84
|
+
|
|
85
|
+
Authors
|
|
86
|
+
Developed for the National College of Ireland (NCI) - Cloud Platform Programming Module.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cloud_utils
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import boto3
|
|
2
|
+
import logging
|
|
3
|
+
from botocore.exceptions import ClientError
|
|
4
|
+
|
|
5
|
+
# Setup logging for the library
|
|
6
|
+
logger = logging.getLogger(__name__)
|
|
7
|
+
|
|
8
|
+
class SmartCloudManager:
|
|
9
|
+
"""
|
|
10
|
+
Custom Library for SmartShelf to encapsulate AWS Service Logic.
|
|
11
|
+
This fulfills the LO3 and LO4 requirements for the NCI Project.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, region_name="us-east-1"):
|
|
15
|
+
self.region = region_name
|
|
16
|
+
self._textract = None
|
|
17
|
+
self._s3 = None
|
|
18
|
+
self._dynamodb = None
|
|
19
|
+
self._ses = None
|
|
20
|
+
|
|
21
|
+
def __enter__(self):
|
|
22
|
+
"""Context Manager entry point."""
|
|
23
|
+
return self
|
|
24
|
+
|
|
25
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
|
26
|
+
"""Context Manager exit point for clean resource handling."""
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
@property
|
|
30
|
+
def textract_client(self):
|
|
31
|
+
if not self._textract:
|
|
32
|
+
self._textract = boto3.client("textract", region_name=self.region)
|
|
33
|
+
return self._textract
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def dynamodb_resource(self):
|
|
37
|
+
if not self._dynamodb:
|
|
38
|
+
self._dynamodb = boto3.resource("dynamodb", region_name=self.region)
|
|
39
|
+
return self._dynamodb
|
|
40
|
+
|
|
41
|
+
def extract_inventory_data(self, bucket_name, document_name):
|
|
42
|
+
"""
|
|
43
|
+
Uses Amazon Textract to identify key-value pairs from invoices.
|
|
44
|
+
"""
|
|
45
|
+
try:
|
|
46
|
+
response = self.textract_client.analyze_document(
|
|
47
|
+
Document={'S3Object': {'Bucket': bucket_name, 'Name': document_name}},
|
|
48
|
+
FeatureTypes=['FORMS']
|
|
49
|
+
)
|
|
50
|
+
return self._parse_textract_response(response)
|
|
51
|
+
except ClientError as e:
|
|
52
|
+
logger.error(f"Textract Error: {e}")
|
|
53
|
+
return None
|
|
54
|
+
|
|
55
|
+
def _parse_textract_response(self, response):
|
|
56
|
+
"""
|
|
57
|
+
Private helper method to clean raw JSON into meaningful data.
|
|
58
|
+
"""
|
|
59
|
+
extracted_data = {}
|
|
60
|
+
# Logic to map blocks to Key-Value pairs goes here
|
|
61
|
+
return extracted_data
|
|
62
|
+
|
|
63
|
+
def update_stock_telemetry(self, table_name, item_id, quantity):
|
|
64
|
+
"""
|
|
65
|
+
Updates DynamoDB with real-time stock levels.
|
|
66
|
+
"""
|
|
67
|
+
table = self.dynamodb_resource.Table(table_name)
|
|
68
|
+
try:
|
|
69
|
+
table.update_item(
|
|
70
|
+
Key={'item_id': item_id},
|
|
71
|
+
UpdateExpression="set stock_level = :q",
|
|
72
|
+
ExpressionAttributeValues={':q': quantity}
|
|
73
|
+
)
|
|
74
|
+
return True
|
|
75
|
+
except ClientError as e:
|
|
76
|
+
logger.error(f"DynamoDB Error: {e}")
|
|
77
|
+
return False
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "SmartShelf-Project"
|
|
7
|
+
version = "1.1.0"
|
|
8
|
+
description = "A simple demo Python library"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name="Vedant Bandarkar", email="vedantbandarkar@gmail.com" }
|
|
12
|
+
]
|
|
13
|
+
license = { text = "MIT" }
|
|
14
|
+
requires-python = ">=3.7"
|
|
15
|
+
|
|
16
|
+
dependencies = []
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
"Homepage" = "https://github.com/VedantB-sudo/SmartShelfProject"
|