diff --git a/.github/workflows/build-python.yml b/.github/workflows/build-python.yml index cc48f83..efb660c 100644 --- a/.github/workflows/build-python.yml +++ b/.github/workflows/build-python.yml @@ -58,9 +58,8 @@ jobs: name: wheels path: python/dist - # only run docs on target x86_64 - name: Build Python docs - if: matrix.target == 'x86_64' + if: matrix.target == 'x86_64' # avoids redudundant builds; pdoc isn't arch-specific working-directory: python shell: bash # TODO: pdoc is documenting the installed module, not the source folder. diff --git a/examples/python/basic.py b/examples/python/basic.py new file mode 100644 index 0000000..25bd56f --- /dev/null +++ b/examples/python/basic.py @@ -0,0 +1,31 @@ +import blyss + +api_key = "" +client = blyss.Client(api_key, "https://alpha.api.blyss.dev") + +# Create the bucket and fill it with some data +bucket_name = "state-capitals" +bucket = None +if not client.exists(bucket_name): + client.create(bucket_name) + +# Connect to your bucket +bucket = client.connect(bucket_name) + +# Write some data (keys are strings, values are bytes) +bucket.write( + { + "California": "Sacramento".encode(), + "Ohio": "Columbus".encode(), + "New York": "Albany".encode(), + } +) + +# This is a completely *private* query: +# the server *cannot* learn that you looked up "California" or "Texas"! +print("Privately reading the capital of California...") +capitals = bucket.private_read(["California", "Texas"]) + +# when a requested key is not found, its value is None +capitals = [c.decode() if c else None for c in capitals] +print(f"Got '{capitals}'!") diff --git a/examples/python/main.py b/examples/python/main.py deleted file mode 100644 index d1f262c..0000000 --- a/examples/python/main.py +++ /dev/null @@ -1,37 +0,0 @@ -import blyss -import logging -import requests -import json - -api_key = "" -client = blyss.Client(api_key) - -# Create the bucket and fill it with some data -bucket_name = "state-capitals" -bucket = None -if not client.exists(bucket_name): - client.create(bucket_name) - -# Connect to your bucket -bucket = client.connect(bucket_name) - -# Write some data to it -bucket.write( - { - "California": "Sacramento", - "Ohio": "Columbus", - "New York": "Albany", - } -) - -# This is a completely *private* query: -# the server *cannot* learn that you looked up "California"! -print("Privately reading the capital of California...") -capital = bucket.private_read("California") -print(f"Got '{capital}'!") - -# This is a completely *private* intersection operation: -# the server *cannot* learn that the set was ['Wyoming', 'California', 'Ohio']! -set_to_test = ["Wyoming", "California", "Ohio"] -intersection = bucket.private_key_intersect(set_to_test) -print(f"Intersection of {set_to_test} and bucket yielded: {intersection}") diff --git a/python/Cargo.lock b/python/Cargo.lock index ab7a3d2..e3f66fb 100644 --- a/python/Cargo.lock +++ b/python/Cargo.lock @@ -25,7 +25,7 @@ dependencies = [ [[package]] name = "blyss-client-python" -version = "0.2.1" +version = "0.2.2" dependencies = [ "pyo3", "spiral-rs", diff --git a/python/Cargo.toml b/python/Cargo.toml index b044422..42b75d0 100644 --- a/python/Cargo.toml +++ b/python/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "blyss-client-python" -version = "0.2.1" +version = "0.2.2" edition = "2021" rust-version = "1.70.0" @@ -11,4 +11,4 @@ crate-type = ["cdylib"] [dependencies] pyo3 = { version = "0.17.1", features = ["extension-module"] } -spiral-rs = { path = "../lib/spiral-rs" } \ No newline at end of file +spiral-rs = { path = "../lib/spiral-rs" } diff --git a/python/blyss/api.py b/python/blyss/api.py index 0f373ce..3b0e620 100644 --- a/python/blyss/api.py +++ b/python/blyss/api.py @@ -183,7 +183,7 @@ async def exists(self, bucket_name: str) -> bool: """ try: await _async_get( - self.api_key, self._service_url_for("/" + bucket_name + CHECK_PATH) + self.api_key, self._service_url_for("/" + bucket_name + META_PATH) ) return True except ApiException as e: diff --git a/python/blyss/bucket_service.py b/python/blyss/bucket_service.py index 56a5601..9b14aef 100644 --- a/python/blyss/bucket_service.py +++ b/python/blyss/bucket_service.py @@ -1,7 +1,7 @@ from typing import Any, Optional, Union from . import bucket, api, seed -BLYSS_BUCKET_URL = "https://beta.api.blyss.dev" +BLYSS_BUCKET_URL = "https://alpha.api.blyss.dev" DEFAULT_BUCKET_PARAMETERS = { "maxItemSize": 1000, "keyStoragePolicy": "none", diff --git a/python/tests/test_service.py b/python/tests/test_service.py index fc0f1a1..23e3d5e 100644 --- a/python/tests/test_service.py +++ b/python/tests/test_service.py @@ -46,7 +46,7 @@ async def test_e2e_async( client = blyss.AsyncClient(api_key, endpoint) # generate random string for bucket name bucket_name = generateBucketName() - await client.create(bucket_name, usage_hints={"maxItemSize": 40_000}) + await client.create(bucket_name, usage_hints={"maxItemSize": 10_000}) print("Created bucket") bucket = await client.connect(bucket_name) print(await bucket.info()) @@ -117,7 +117,7 @@ def test_e2e(endpoint: str, api_key: str, N: int = 4000, itemSize: int = 32): client = blyss.Client(api_key, endpoint) # generate random string for bucket name bucket_name = generateBucketName() - client.create(bucket_name, usage_hints={"maxItemSize": 40_000}) + client.create(bucket_name, usage_hints={"maxItemSize": 10_000}) print("Created bucket") bucket = client.connect(bucket_name) print(bucket.info())