chuk-artifacts 0.1.4__py3-none-any.whl → 0.1.5__py3-none-any.whl
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.
- chuk_artifacts/admin.py +28 -24
- chuk_artifacts/metadata.py +11 -11
- {chuk_artifacts-0.1.4.dist-info → chuk_artifacts-0.1.5.dist-info}/METADATA +1 -1
- {chuk_artifacts-0.1.4.dist-info → chuk_artifacts-0.1.5.dist-info}/RECORD +7 -7
- {chuk_artifacts-0.1.4.dist-info → chuk_artifacts-0.1.5.dist-info}/WHEEL +0 -0
- {chuk_artifacts-0.1.4.dist-info → chuk_artifacts-0.1.5.dist-info}/licenses/LICENSE +0 -0
- {chuk_artifacts-0.1.4.dist-info → chuk_artifacts-0.1.5.dist-info}/top_level.txt +0 -0
chuk_artifacts/admin.py
CHANGED
@@ -21,15 +21,19 @@ class AdminOperations:
|
|
21
21
|
"""Handles administrative and debugging operations."""
|
22
22
|
|
23
23
|
def __init__(self, artifact_store: 'ArtifactStore'):
|
24
|
+
# canonical reference
|
24
25
|
self.artifact_store = artifact_store
|
25
26
|
|
27
|
+
# backward-compat/consistency with other ops modules
|
28
|
+
self.store = artifact_store
|
29
|
+
|
26
30
|
async def validate_configuration(self) -> Dict[str, Any]:
|
27
31
|
"""Validate store configuration and connectivity."""
|
28
32
|
results = {"timestamp": datetime.utcnow().isoformat() + "Z"}
|
29
33
|
|
30
34
|
# Test session provider
|
31
35
|
try:
|
32
|
-
session_ctx_mgr = self.
|
36
|
+
session_ctx_mgr = self.artifact_store._session_factory()
|
33
37
|
async with session_ctx_mgr as session:
|
34
38
|
# Test basic operations
|
35
39
|
test_key = f"test_{uuid.uuid4().hex}"
|
@@ -39,53 +43,53 @@ class AdminOperations:
|
|
39
43
|
if value == "test_value":
|
40
44
|
results["session"] = {
|
41
45
|
"status": "ok",
|
42
|
-
"provider": self.
|
46
|
+
"provider": self.artifact_store._session_provider_name
|
43
47
|
}
|
44
48
|
else:
|
45
49
|
results["session"] = {
|
46
50
|
"status": "error",
|
47
51
|
"message": "Session store test failed",
|
48
|
-
"provider": self.
|
52
|
+
"provider": self.artifact_store._session_provider_name
|
49
53
|
}
|
50
54
|
except Exception as e:
|
51
55
|
results["session"] = {
|
52
56
|
"status": "error",
|
53
57
|
"message": str(e),
|
54
|
-
"provider": self.
|
58
|
+
"provider": self.artifact_store._session_provider_name
|
55
59
|
}
|
56
60
|
|
57
61
|
# Test storage provider
|
58
62
|
try:
|
59
|
-
storage_ctx_mgr = self.
|
63
|
+
storage_ctx_mgr = self.artifact_store._s3_factory()
|
60
64
|
async with storage_ctx_mgr as s3:
|
61
|
-
await s3.head_bucket(Bucket=self.
|
65
|
+
await s3.head_bucket(Bucket=self.artifact_store.bucket)
|
62
66
|
results["storage"] = {
|
63
67
|
"status": "ok",
|
64
|
-
"bucket": self.
|
65
|
-
"provider": self.
|
68
|
+
"bucket": self.artifact_store.bucket,
|
69
|
+
"provider": self.artifact_store._storage_provider_name
|
66
70
|
}
|
67
71
|
except Exception as e:
|
68
72
|
results["storage"] = {
|
69
73
|
"status": "error",
|
70
74
|
"message": str(e),
|
71
|
-
"provider": self.
|
75
|
+
"provider": self.artifact_store._storage_provider_name
|
72
76
|
}
|
73
77
|
|
74
78
|
# Test session manager (chuk_sessions)
|
75
79
|
try:
|
76
80
|
# Try to allocate a test session
|
77
|
-
test_session = await self.
|
81
|
+
test_session = await self.artifact_store._session_manager.allocate_session(
|
78
82
|
user_id="test_admin_user"
|
79
83
|
)
|
80
84
|
# Validate it
|
81
|
-
is_valid = await self.
|
85
|
+
is_valid = await self.artifact_store._session_manager.validate_session(test_session)
|
82
86
|
# Clean up
|
83
|
-
await self.
|
87
|
+
await self.artifact_store._session_manager.delete_session(test_session)
|
84
88
|
|
85
89
|
if is_valid:
|
86
90
|
results["session_manager"] = {
|
87
91
|
"status": "ok",
|
88
|
-
"sandbox_id": self.
|
92
|
+
"sandbox_id": self.artifact_store.sandbox_id,
|
89
93
|
"test_session": test_session
|
90
94
|
}
|
91
95
|
else:
|
@@ -104,18 +108,18 @@ class AdminOperations:
|
|
104
108
|
async def get_stats(self) -> Dict[str, Any]:
|
105
109
|
"""Get storage statistics."""
|
106
110
|
base_stats = {
|
107
|
-
"storage_provider": self.
|
108
|
-
"session_provider": self.
|
109
|
-
"bucket": self.
|
110
|
-
"max_retries": self.
|
111
|
-
"closed": self.
|
112
|
-
"sandbox_id": self.
|
113
|
-
"session_ttl_hours": self.
|
111
|
+
"storage_provider": self.artifact_store._storage_provider_name,
|
112
|
+
"session_provider": self.artifact_store._session_provider_name,
|
113
|
+
"bucket": self.artifact_store.bucket,
|
114
|
+
"max_retries": self.artifact_store.max_retries,
|
115
|
+
"closed": self.artifact_store._closed,
|
116
|
+
"sandbox_id": self.artifact_store.sandbox_id,
|
117
|
+
"session_ttl_hours": self.artifact_store.session_ttl_hours,
|
114
118
|
}
|
115
119
|
|
116
120
|
# Add session manager stats from chuk_sessions
|
117
121
|
try:
|
118
|
-
session_stats = self.
|
122
|
+
session_stats = self.artifact_store._session_manager.get_cache_stats()
|
119
123
|
base_stats["session_manager"] = session_stats
|
120
124
|
except Exception as e:
|
121
125
|
base_stats["session_manager"] = {
|
@@ -131,7 +135,7 @@ class AdminOperations:
|
|
131
135
|
|
132
136
|
# Clean up expired sessions using chuk_sessions
|
133
137
|
try:
|
134
|
-
expired_sessions = await self.
|
138
|
+
expired_sessions = await self.artifact_store._session_manager.cleanup_expired_sessions()
|
135
139
|
results["expired_sessions_cleaned"] = expired_sessions
|
136
140
|
except Exception as e:
|
137
141
|
results["session_cleanup_error"] = str(e)
|
@@ -146,8 +150,8 @@ class AdminOperations:
|
|
146
150
|
async def get_sandbox_info(self) -> Dict[str, Any]:
|
147
151
|
"""Get information about the current sandbox."""
|
148
152
|
return {
|
149
|
-
"sandbox_id": self.
|
150
|
-
"session_prefix_pattern": self.
|
153
|
+
"sandbox_id": self.artifact_store.sandbox_id,
|
154
|
+
"session_prefix_pattern": self.artifact_store.get_session_prefix_pattern(),
|
151
155
|
"grid_architecture": {
|
152
156
|
"enabled": True,
|
153
157
|
"pattern": "grid/{sandbox_id}/{session_id}/{artifact_id}",
|
chuk_artifacts/metadata.py
CHANGED
@@ -23,7 +23,7 @@ class MetadataOperations:
|
|
23
23
|
"""Clean metadata operations for grid architecture using chuk_sessions."""
|
24
24
|
|
25
25
|
def __init__(self, artifact_store: 'ArtifactStore'):
|
26
|
-
self.
|
26
|
+
self.artifact_store = artifact_store
|
27
27
|
|
28
28
|
async def get_metadata(self, artifact_id: str) -> Dict[str, Any]:
|
29
29
|
"""Get artifact metadata."""
|
@@ -43,15 +43,15 @@ class MetadataOperations:
|
|
43
43
|
record = await self._get_record(artifact_id)
|
44
44
|
|
45
45
|
# Delete from storage
|
46
|
-
storage_ctx_mgr = self.
|
46
|
+
storage_ctx_mgr = self.artifact_store._s3_factory()
|
47
47
|
async with storage_ctx_mgr as s3:
|
48
48
|
await s3.delete_object(
|
49
|
-
Bucket=self.
|
49
|
+
Bucket=self.artifact_store.bucket,
|
50
50
|
Key=record["key"]
|
51
51
|
)
|
52
52
|
|
53
53
|
# Delete metadata from session provider
|
54
|
-
session_ctx_mgr = self.
|
54
|
+
session_ctx_mgr = self.artifact_store._session_factory()
|
55
55
|
async with session_ctx_mgr as session:
|
56
56
|
if hasattr(session, 'delete'):
|
57
57
|
await session.delete(artifact_id)
|
@@ -68,13 +68,13 @@ class MetadataOperations:
|
|
68
68
|
try:
|
69
69
|
artifacts = []
|
70
70
|
# Use the session manager's canonical prefix instead of building our own
|
71
|
-
prefix = self.
|
71
|
+
prefix = self.artifact_store._session_manager.get_canonical_prefix(session_id)
|
72
72
|
|
73
|
-
storage_ctx_mgr = self.
|
73
|
+
storage_ctx_mgr = self.artifact_store._s3_factory()
|
74
74
|
async with storage_ctx_mgr as s3:
|
75
75
|
if hasattr(s3, 'list_objects_v2'):
|
76
76
|
response = await s3.list_objects_v2(
|
77
|
-
Bucket=self.
|
77
|
+
Bucket=self.artifact_store.bucket,
|
78
78
|
Prefix=prefix,
|
79
79
|
MaxKeys=limit
|
80
80
|
)
|
@@ -82,7 +82,7 @@ class MetadataOperations:
|
|
82
82
|
for obj in response.get('Contents', []):
|
83
83
|
key = obj['Key']
|
84
84
|
# Parse the grid key using chuk_sessions
|
85
|
-
parsed = self.
|
85
|
+
parsed = self.artifact_store._session_manager.parse_grid_key(key)
|
86
86
|
if parsed and parsed.get('artifact_id'):
|
87
87
|
artifact_id = parsed['artifact_id']
|
88
88
|
try:
|
@@ -158,7 +158,7 @@ class MetadataOperations:
|
|
158
158
|
record[key] = value
|
159
159
|
|
160
160
|
# Store updated record using session provider
|
161
|
-
session_ctx_mgr = self.
|
161
|
+
session_ctx_mgr = self.artifact_store._session_factory()
|
162
162
|
async with session_ctx_mgr as session:
|
163
163
|
await session.setex(artifact_id, record.get("ttl", 900), json.dumps(record))
|
164
164
|
|
@@ -184,7 +184,7 @@ class MetadataOperations:
|
|
184
184
|
record["ttl"] = new_ttl
|
185
185
|
|
186
186
|
# Store updated record with new TTL using session provider
|
187
|
-
session_ctx_mgr = self.
|
187
|
+
session_ctx_mgr = self.artifact_store._session_factory()
|
188
188
|
async with session_ctx_mgr as session:
|
189
189
|
await session.setex(artifact_id, new_ttl, json.dumps(record))
|
190
190
|
|
@@ -197,7 +197,7 @@ class MetadataOperations:
|
|
197
197
|
async def _get_record(self, artifact_id: str) -> Dict[str, Any]:
|
198
198
|
"""Get artifact metadata record from session provider."""
|
199
199
|
try:
|
200
|
-
session_ctx_mgr = self.
|
200
|
+
session_ctx_mgr = self.artifact_store._session_factory()
|
201
201
|
async with session_ctx_mgr as session:
|
202
202
|
raw = await session.get(artifact_id)
|
203
203
|
except Exception as e:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: chuk-artifacts
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.5
|
4
4
|
Summary: Chuk Artifacts provides a production-ready, modular artifact storage system that works seamlessly across multiple storage backends (memory, filesystem, AWS S3, IBM Cloud Object Storage) with Redis or memory-based metadata caching and strict session-based security.
|
5
5
|
License: MIT
|
6
6
|
Requires-Python: >=3.11
|
@@ -1,11 +1,11 @@
|
|
1
1
|
chuk_artifacts/__init__.py,sha256=-4S9FWKVcQSa2ZD3GVbmbpGZPcl0cTQN_TFZLSqV7lQ,3605
|
2
|
-
chuk_artifacts/admin.py,sha256=
|
2
|
+
chuk_artifacts/admin.py,sha256=lUgmKBPxJh-0FYrGWjkACXQOl8lbVEDPJaeGVsWZmC4,6071
|
3
3
|
chuk_artifacts/base.py,sha256=BtuVnC9M8QI1znyTdBxjZ6knIKP_k0yUfLfh7inGJUc,2559
|
4
4
|
chuk_artifacts/batch.py,sha256=x8ARrWJ24I9fAXXodzvh31uMxYrvwZCGGJhUCM4vMJ4,5099
|
5
5
|
chuk_artifacts/config.py,sha256=MaUzHzKPoBUyERviEpv8JVvPybMzSksgLyj0b7AO3Sc,7664
|
6
6
|
chuk_artifacts/core.py,sha256=hokH7cgGE2ZaEwlV8XMKOov3EMvcLS2HufdApLS6l3M,6699
|
7
7
|
chuk_artifacts/exceptions.py,sha256=f-s7Mg7c8vMXsbgqO2B6lMHdXcJQNvsESAY4GhJaV4g,814
|
8
|
-
chuk_artifacts/metadata.py,sha256=
|
8
|
+
chuk_artifacts/metadata.py,sha256=McyKLviBInpqh2eF621xhqb3Ix7QUj_nVc1gg_tUlqY,7830
|
9
9
|
chuk_artifacts/models.py,sha256=_foXlkr0DprqgztDw5WtlDc-s1OouLgYNp4XM1Ghp-g,837
|
10
10
|
chuk_artifacts/presigned.py,sha256=-GE8r0CfUZuPNA_jnSGTfX7kuws6kYCPe7C4y6FItdo,11491
|
11
11
|
chuk_artifacts/provider_factory.py,sha256=T0IXx1C8gygJzp417oB44_DxEaZoZR7jcdwQy8FghRE,3398
|
@@ -16,8 +16,8 @@ chuk_artifacts/providers/ibm_cos.py,sha256=K1-VAX4UVV9tA161MOeDXOKloQ0hB77jdw1-p
|
|
16
16
|
chuk_artifacts/providers/ibm_cos_iam.py,sha256=VtwvCi9rMMcZx6i9l21ob6wM8jXseqvjzgCnAA82RkY,3186
|
17
17
|
chuk_artifacts/providers/memory.py,sha256=B1C-tR1PcNz-UuDfGm1bhjPz3oITVATIMPekVbE7nm4,10487
|
18
18
|
chuk_artifacts/providers/s3.py,sha256=eWhBhFSaobpRbazn7ySfU_7D8rm_xCfdSVqRtzXzXRY,2858
|
19
|
-
chuk_artifacts-0.1.
|
20
|
-
chuk_artifacts-0.1.
|
21
|
-
chuk_artifacts-0.1.
|
22
|
-
chuk_artifacts-0.1.
|
23
|
-
chuk_artifacts-0.1.
|
19
|
+
chuk_artifacts-0.1.5.dist-info/licenses/LICENSE,sha256=SG9BmgtPBagPV0d-Fep-msdAGl-E1CeoBL7-EDRH2qA,1066
|
20
|
+
chuk_artifacts-0.1.5.dist-info/METADATA,sha256=LEDEBlXqdLSHIJDut0xjsBPBHlwLP2X8HfWshD2xyeg,21188
|
21
|
+
chuk_artifacts-0.1.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
22
|
+
chuk_artifacts-0.1.5.dist-info/top_level.txt,sha256=1_PVMtWXR0A-ZmeH6apF9mPaMtU0i23JE6wmN4GBRDI,15
|
23
|
+
chuk_artifacts-0.1.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|