Skip to content

Commit cb89e5e

Browse files
Merge branch 'pysdk/removed-kv-store' of https://github.com/JigsawStack/jigsawstack-python into feat/image-generation
2 parents 8a3679c + f0cdbfe commit cb89e5e

File tree

4 files changed

+73
-48
lines changed

4 files changed

+73
-48
lines changed

biome.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"files": {
4+
"ignoreUnknown": false,
5+
"ignore": []
6+
},
7+
"formatter": {
8+
"enabled": true,
9+
"useEditorconfig": true,
10+
"formatWithErrors": false,
11+
"indentStyle": "space",
12+
"indentWidth": 2,
13+
"lineEnding": "lf",
14+
"lineWidth": 150,
15+
"attributePosition": "auto",
16+
"bracketSpacing": true
17+
},
18+
"organizeImports": {
19+
"enabled": true
20+
},
21+
"linter": {
22+
"enabled": false
23+
},
24+
"javascript": {
25+
"formatter": {
26+
"jsxQuoteStyle": "double",
27+
"quoteProperties": "asNeeded",
28+
"trailingCommas": "es5",
29+
"semicolons": "always",
30+
"arrowParentheses": "always",
31+
"bracketSameLine": false,
32+
"quoteStyle": "double",
33+
"attributePosition": "auto",
34+
"bracketSpacing": true
35+
}
36+
}
37+
}

jigsawstack/store.py

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,22 @@
33
from .request import Request, RequestConfig
44
from .async_request import AsyncRequest, AsyncRequestConfig
55
from ._config import ClientConfig
6-
from typing import Any, Dict, List, cast
7-
from typing_extensions import NotRequired, TypedDict
8-
9-
10-
class FileDeleteResponse(TypedDict):
11-
success: bool
126

137

14-
class KVGetParams(TypedDict):
15-
key: str
168

179

18-
class KVGetResponse(TypedDict):
10+
class FileDeleteResponse(TypedDict):
1911
success: bool
20-
value: str
2112

2213

23-
class KVAddParams(TypedDict):
24-
key: str
25-
value: str
26-
encrypt: NotRequired[bool]
27-
byo_secret: NotRequired[str]
28-
29-
30-
class KVAddResponse(TypedDict):
31-
success: bool
32-
3314

3415
class FileUploadParams(TypedDict):
3516
overwrite: bool
3617
filename: str
3718
content_type: NotRequired[str]
3819

3920

40-
class KV(ClientConfig):
21+
4122

4223
config: RequestConfig
4324

@@ -83,7 +64,6 @@ def delete(self, key: str) -> KVGetResponse:
8364
class Store(ClientConfig):
8465

8566
config: RequestConfig
86-
kv: KV
8767

8868
def __init__(
8969
self,
@@ -98,8 +78,6 @@ def __init__(
9878
disable_request_logging=disable_request_logging,
9979
)
10080

101-
self.kv = KV(api_key, api_url, disable_request_logging)
102-
10381
def upload(self, file: bytes, options=FileUploadParams) -> Any:
10482
overwrite = options.get("overwrite")
10583
filename = options.get("filename")
@@ -121,7 +99,7 @@ def upload(self, file: bytes, options=FileUploadParams) -> Any:
12199
return resp
122100

123101
def get(self, key: str) -> Any:
124-
path = f"/store/file/{key}"
102+
path = f"/store/file/read/{key}"
125103
resp = Request(
126104
config=self.config,
127105
path=path,
@@ -131,7 +109,7 @@ def get(self, key: str) -> Any:
131109
return resp
132110

133111
def delete(self, key: str) -> FileDeleteResponse:
134-
path = f"/store/file/{key}"
112+
path = f"/store/file/read/{key}"
135113
resp = Request(
136114
config=self.config,
137115
path=path,
@@ -141,7 +119,6 @@ def delete(self, key: str) -> FileDeleteResponse:
141119
return resp
142120

143121

144-
class AsyncKV(ClientConfig):
145122

146123
config: AsyncRequestConfig
147124

@@ -188,7 +165,6 @@ async def delete(self, key: str) -> KVGetResponse:
188165

189166
class AsyncStore(ClientConfig):
190167
config: AsyncRequestConfig
191-
kv: AsyncKV
192168

193169
def __init__(
194170
self,
@@ -202,7 +178,7 @@ def __init__(
202178
api_key=api_key,
203179
disable_request_logging=disable_request_logging,
204180
)
205-
self.kv = AsyncKV(api_key, api_url, disable_request_logging)
181+
206182

207183
async def upload(self, file: bytes, options=FileUploadParams) -> Any:
208184
overwrite = options.get("overwrite")
@@ -225,7 +201,7 @@ async def upload(self, file: bytes, options=FileUploadParams) -> Any:
225201
return resp
226202

227203
async def get(self, key: str) -> Any:
228-
path = f"/store/file/{key}"
204+
path = f"/store/file/read/{key}"
229205
resp = await AsyncRequest(
230206
config=self.config,
231207
path=path,
@@ -235,7 +211,7 @@ async def get(self, key: str) -> Any:
235211
return resp
236212

237213
async def delete(self, key: str) -> FileDeleteResponse:
238-
path = f"/store/file/{key}"
214+
path = f"/store/file/read/{key}"
239215
resp = AsyncRequest(
240216
config=self.config,
241217
path=path,

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name="jigsawstack",
9-
version="0.1.29",
9+
version="0.1.30",
1010
description="JigsawStack Python SDK",
1111
long_description=open("README.md", encoding="utf8").read(),
1212
long_description_content_type="text/markdown",

tests/test_store.py

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,41 @@
1111

1212

1313
@pytest.mark.skip(reason="Skipping TestWebAPI class for now")
14-
def test_async_kv_response():
15-
async def _test():
16-
client = AsyncJigsawStack()
17-
try:
18-
result = await client.store.kv.add(
19-
{"key": "hello", "value": "world", "encrypt": False}
20-
)
21-
logger.info(result)
22-
assert result["success"] == True
23-
except JigsawStackError as e:
24-
pytest.fail(f"Unexpected JigsawStackError: {e}")
14+
class TestAsyncFileOperations:
15+
"""
16+
Test class for async file operations.
17+
Add your file operation tests here.
18+
"""
19+
20+
def test_async_file_upload(self):
21+
# Template for future file upload tests
22+
pass
23+
24+
def test_async_file_retrieval(self):
25+
# Template for future file retrieval tests
26+
pass
27+
28+
def test_async_file_deletion(self):
29+
# Template for future file deletion tests
30+
pass
2531

26-
asyncio.run(_test())
2732

28-
29-
def test_async_retriev_kv_response():
33+
# Example file upload test
34+
# Uncomment and modify as needed
35+
"""
36+
def test_async_file_upload_example():
3037
async def _test():
3138
client = AsyncJigsawStack()
3239
try:
33-
result = await client.store.kv.get("hello")
40+
file_content = b"test file content"
41+
result = await client.store.upload(
42+
file_content,
43+
{"filename": "test.txt", "overwrite": True}
44+
)
3445
logger.info(result)
35-
assert result["success"] == True
46+
assert result["success"] == True
3647
except JigsawStackError as e:
3748
pytest.fail(f"Unexpected JigsawStackError: {e}")
3849
3950
asyncio.run(_test())
51+
"""

0 commit comments

Comments
 (0)