Skip to content

Commit fdb7206

Browse files
authored
update python example (#32)
* update python basic example * reduce test size to support small servers
1 parent 9604fd3 commit fdb7206

File tree

8 files changed

+39
-46
lines changed

8 files changed

+39
-46
lines changed

.github/workflows/build-python.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ jobs:
5858
name: wheels
5959
path: python/dist
6060

61-
# only run docs on target x86_64
6261
- name: Build Python docs
63-
if: matrix.target == 'x86_64'
62+
if: matrix.target == 'x86_64' # avoids redudundant builds; pdoc isn't arch-specific
6463
working-directory: python
6564
shell: bash
6665
# TODO: pdoc is documenting the installed module, not the source folder.

examples/python/basic.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import blyss
2+
3+
api_key = "<YOUR API KEY HERE>"
4+
client = blyss.Client(api_key, "https://alpha.api.blyss.dev")
5+
6+
# Create the bucket and fill it with some data
7+
bucket_name = "state-capitals"
8+
bucket = None
9+
if not client.exists(bucket_name):
10+
client.create(bucket_name)
11+
12+
# Connect to your bucket
13+
bucket = client.connect(bucket_name)
14+
15+
# Write some data (keys are strings, values are bytes)
16+
bucket.write(
17+
{
18+
"California": "Sacramento".encode(),
19+
"Ohio": "Columbus".encode(),
20+
"New York": "Albany".encode(),
21+
}
22+
)
23+
24+
# This is a completely *private* query:
25+
# the server *cannot* learn that you looked up "California" or "Texas"!
26+
print("Privately reading the capital of California...")
27+
capitals = bucket.private_read(["California", "Texas"])
28+
29+
# when a requested key is not found, its value is None
30+
capitals = [c.decode() if c else None for c in capitals]
31+
print(f"Got '{capitals}'!")

examples/python/main.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

python/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "blyss-client-python"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
edition = "2021"
55
rust-version = "1.70.0"
66

@@ -11,4 +11,4 @@ crate-type = ["cdylib"]
1111

1212
[dependencies]
1313
pyo3 = { version = "0.17.1", features = ["extension-module"] }
14-
spiral-rs = { path = "../lib/spiral-rs" }
14+
spiral-rs = { path = "../lib/spiral-rs" }

python/blyss/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ async def exists(self, bucket_name: str) -> bool:
183183
"""
184184
try:
185185
await _async_get(
186-
self.api_key, self._service_url_for("/" + bucket_name + CHECK_PATH)
186+
self.api_key, self._service_url_for("/" + bucket_name + META_PATH)
187187
)
188188
return True
189189
except ApiException as e:

python/blyss/bucket_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Any, Optional, Union
22
from . import bucket, api, seed
33

4-
BLYSS_BUCKET_URL = "https://beta.api.blyss.dev"
4+
BLYSS_BUCKET_URL = "https://alpha.api.blyss.dev"
55
DEFAULT_BUCKET_PARAMETERS = {
66
"maxItemSize": 1000,
77
"keyStoragePolicy": "none",

python/tests/test_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def test_e2e_async(
4646
client = blyss.AsyncClient(api_key, endpoint)
4747
# generate random string for bucket name
4848
bucket_name = generateBucketName()
49-
await client.create(bucket_name, usage_hints={"maxItemSize": 40_000})
49+
await client.create(bucket_name, usage_hints={"maxItemSize": 10_000})
5050
print("Created bucket")
5151
bucket = await client.connect(bucket_name)
5252
print(await bucket.info())
@@ -117,7 +117,7 @@ def test_e2e(endpoint: str, api_key: str, N: int = 4000, itemSize: int = 32):
117117
client = blyss.Client(api_key, endpoint)
118118
# generate random string for bucket name
119119
bucket_name = generateBucketName()
120-
client.create(bucket_name, usage_hints={"maxItemSize": 40_000})
120+
client.create(bucket_name, usage_hints={"maxItemSize": 10_000})
121121
print("Created bucket")
122122
bucket = client.connect(bucket_name)
123123
print(bucket.info())

0 commit comments

Comments
 (0)