Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.1.0"
".": "1.2.0"
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 1.2.0 (2025-02-04)

Full Changelog: [v1.1.0...v1.2.0](https://github.com/BrainbaseHQ/brainbase-python-sdk/compare/v1.1.0...v1.2.0)

### Features

* **api:** update via SDK Studio ([#12](https://github.com/BrainbaseHQ/brainbase-python-sdk/issues/12)) ([a363549](https://github.com/BrainbaseHQ/brainbase-python-sdk/commit/a3635498129383f20cae75014ad9720e18cc7ec6))

## 1.1.0 (2025-02-04)

Full Changelog: [v1.0.1...v1.1.0](https://github.com/BrainbaseHQ/brainbase-python-sdk/compare/v1.0.1...v1.1.0)
Expand Down
27 changes: 15 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,25 @@ pip install brainbase-labs
The full API of this library can be found in [api.md](api.md).

```python
import os
from brainbase import Brainbase

client = Brainbase(
api_key=os.environ.get("API_KEY"), # This is the default and can be omitted
api_key="My API Key",
)

client.workers.list()
```

While you can provide an `api_key` keyword argument,
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
to add `API_KEY="My API Key"` to your `.env` file
so that your API Key is not stored in source control.

## Async usage

Simply import `AsyncBrainbase` instead of `Brainbase` and use `await` with each API call:

```python
import os
import asyncio
from brainbase import AsyncBrainbase

client = AsyncBrainbase(
api_key=os.environ.get("API_KEY"), # This is the default and can be omitted
api_key="My API Key",
)


Expand Down Expand Up @@ -84,7 +77,9 @@ All errors inherit from `brainbase.APIError`.
import brainbase
from brainbase import Brainbase

client = Brainbase()
client = Brainbase(
api_key="My API Key",
)

try:
client.workers.list()
Expand Down Expand Up @@ -127,6 +122,7 @@ from brainbase import Brainbase
client = Brainbase(
# default is 2
max_retries=0,
api_key="My API Key",
)

# Or, configure per-request:
Expand All @@ -145,11 +141,13 @@ from brainbase import Brainbase
client = Brainbase(
# 20 seconds (default is 1 minute)
timeout=20.0,
api_key="My API Key",
)

# More granular control:
client = Brainbase(
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
api_key="My API Key",
)

# Override per-request:
Expand Down Expand Up @@ -193,7 +191,9 @@ The "raw" Response object can be accessed by prefixing `.with_raw_response.` to
```py
from brainbase import Brainbase

client = Brainbase()
client = Brainbase(
api_key="My API Key",
)
response = client.workers.with_raw_response.list()
print(response.headers.get('X-My-Header'))

Expand Down Expand Up @@ -274,6 +274,7 @@ client = Brainbase(
proxy="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
api_key="My API Key",
)
```

Expand All @@ -290,7 +291,9 @@ By default the library closes underlying HTTP connections whenever the client is
```py
from brainbase import Brainbase

with Brainbase() as client:
with Brainbase(
api_key="My API Key",
) as client:
# make requests here
...

Expand Down
2 changes: 1 addition & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Methods:

- <code title="post /api/workers/{id}">client.workers.<a href="./src/brainbase/resources/workers/workers.py">create</a>(id, \*\*<a href="src/brainbase/types/worker_create_params.py">params</a>) -> None</code>
- <code title="post /api/workers">client.workers.<a href="./src/brainbase/resources/workers/workers.py">create</a>(\*\*<a href="src/brainbase/types/worker_create_params.py">params</a>) -> None</code>
- <code title="get /api/workers/{id}">client.workers.<a href="./src/brainbase/resources/workers/workers.py">retrieve</a>(id) -> None</code>
- <code title="get /api/workers">client.workers.<a href="./src/brainbase/resources/workers/workers.py">list</a>() -> None</code>
- <code title="delete /api/workers/{id}">client.workers.<a href="./src/brainbase/resources/workers/workers.py">delete</a>(id) -> None</code>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "brainbase-labs"
version = "1.1.0"
version = "1.2.0"
description = "The official Python library for the brainbase API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
12 changes: 0 additions & 12 deletions src/brainbase/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ def __init__(
def qs(self) -> Querystring:
return Querystring(array_format="comma")

@property
@override
def auth_headers(self) -> dict[str, str]:
api_key = self.api_key
return {"x-api-key": api_key}

@property
@override
def default_headers(self) -> dict[str, str | Omit]:
Expand Down Expand Up @@ -281,12 +275,6 @@ def __init__(
def qs(self) -> Querystring:
return Querystring(array_format="comma")

@property
@override
def auth_headers(self) -> dict[str, str]:
api_key = self.api_key
return {"x-api-key": api_key}

@property
@override
def default_headers(self) -> dict[str, str | Omit]:
Expand Down
2 changes: 1 addition & 1 deletion src/brainbase/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "brainbase"
__version__ = "1.1.0" # x-release-please-version
__version__ = "1.2.0" # x-release-please-version
22 changes: 8 additions & 14 deletions src/brainbase/resources/workers/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,9 @@ def with_streaming_response(self) -> WorkersResourceWithStreamingResponse:

def create(
self,
id: str,
*,
name: str,
description: str | NotGiven = NOT_GIVEN,
name: str | NotGiven = NOT_GIVEN,
status: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -82,7 +81,7 @@ def create(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> None:
"""
Update a worker
Create a new worker

Args:
extra_headers: Send extra headers
Expand All @@ -93,15 +92,13 @@ def create(

timeout: Override the client-level default timeout for this request, in seconds
"""
if not id:
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
return self._post(
f"/api/workers/{id}",
"/api/workers",
body=maybe_transform(
{
"description": description,
"name": name,
"description": description,
"status": status,
},
worker_create_params.WorkerCreateParams,
Expand Down Expand Up @@ -231,10 +228,9 @@ def with_streaming_response(self) -> AsyncWorkersResourceWithStreamingResponse:

async def create(
self,
id: str,
*,
name: str,
description: str | NotGiven = NOT_GIVEN,
name: str | NotGiven = NOT_GIVEN,
status: str | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
Expand All @@ -244,7 +240,7 @@ async def create(
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> None:
"""
Update a worker
Create a new worker

Args:
extra_headers: Send extra headers
Expand All @@ -255,15 +251,13 @@ async def create(

timeout: Override the client-level default timeout for this request, in seconds
"""
if not id:
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
extra_headers = {"Accept": "*/*", **(extra_headers or {})}
return await self._post(
f"/api/workers/{id}",
"/api/workers",
body=await async_maybe_transform(
{
"description": description,
"name": name,
"description": description,
"status": status,
},
worker_create_params.WorkerCreateParams,
Expand Down
6 changes: 3 additions & 3 deletions src/brainbase/types/worker_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

from __future__ import annotations

from typing_extensions import TypedDict
from typing_extensions import Required, TypedDict

__all__ = ["WorkerCreateParams"]


class WorkerCreateParams(TypedDict, total=False):
description: str
name: Required[str]

name: str
description: str

status: str
34 changes: 8 additions & 26 deletions tests/api_resources/test_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,16 @@ class TestWorkers:
@parametrize
def test_method_create(self, client: Brainbase) -> None:
worker = client.workers.create(
id="id",
name="name",
)
assert worker is None

@pytest.mark.skip()
@parametrize
def test_method_create_with_all_params(self, client: Brainbase) -> None:
worker = client.workers.create(
id="id",
description="description",
name="name",
description="description",
status="status",
)
assert worker is None
Expand All @@ -38,7 +37,7 @@ def test_method_create_with_all_params(self, client: Brainbase) -> None:
@parametrize
def test_raw_response_create(self, client: Brainbase) -> None:
response = client.workers.with_raw_response.create(
id="id",
name="name",
)

assert response.is_closed is True
Expand All @@ -50,7 +49,7 @@ def test_raw_response_create(self, client: Brainbase) -> None:
@parametrize
def test_streaming_response_create(self, client: Brainbase) -> None:
with client.workers.with_streaming_response.create(
id="id",
name="name",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -60,14 +59,6 @@ def test_streaming_response_create(self, client: Brainbase) -> None:

assert cast(Any, response.is_closed) is True

@pytest.mark.skip()
@parametrize
def test_path_params_create(self, client: Brainbase) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
client.workers.with_raw_response.create(
id="",
)

@pytest.mark.skip()
@parametrize
def test_method_retrieve(self, client: Brainbase) -> None:
Expand Down Expand Up @@ -188,17 +179,16 @@ class TestAsyncWorkers:
@parametrize
async def test_method_create(self, async_client: AsyncBrainbase) -> None:
worker = await async_client.workers.create(
id="id",
name="name",
)
assert worker is None

@pytest.mark.skip()
@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncBrainbase) -> None:
worker = await async_client.workers.create(
id="id",
description="description",
name="name",
description="description",
status="status",
)
assert worker is None
Expand All @@ -207,7 +197,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncBrainbase)
@parametrize
async def test_raw_response_create(self, async_client: AsyncBrainbase) -> None:
response = await async_client.workers.with_raw_response.create(
id="id",
name="name",
)

assert response.is_closed is True
Expand All @@ -219,7 +209,7 @@ async def test_raw_response_create(self, async_client: AsyncBrainbase) -> None:
@parametrize
async def test_streaming_response_create(self, async_client: AsyncBrainbase) -> None:
async with async_client.workers.with_streaming_response.create(
id="id",
name="name",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
Expand All @@ -229,14 +219,6 @@ async def test_streaming_response_create(self, async_client: AsyncBrainbase) ->

assert cast(Any, response.is_closed) is True

@pytest.mark.skip()
@parametrize
async def test_path_params_create(self, async_client: AsyncBrainbase) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
await async_client.workers.with_raw_response.create(
id="",
)

@pytest.mark.skip()
@parametrize
async def test_method_retrieve(self, async_client: AsyncBrainbase) -> None:
Expand Down
Loading