Skip to content

release: 0.7.0 #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 82 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
c8d3baf
chore(internal): codegen related update (#72)
stainless-app[bot] Dec 3, 2024
e5ea14a
chore: make the `Omit` type public (#74)
stainless-app[bot] Dec 5, 2024
cee4d9d
chore(internal): bump pydantic dependency (#75)
stainless-app[bot] Dec 10, 2024
eebb262
docs(readme): fix http client proxies example (#76)
stainless-app[bot] Dec 10, 2024
e6d7e6d
chore(internal): codegen related update (#77)
stainless-app[bot] Dec 13, 2024
3805a84
chore(internal): codegen related update (#78)
stainless-app[bot] Dec 14, 2024
d02caf0
chore(internal): codegen related update (#79)
stainless-app[bot] Dec 14, 2024
3bc669f
chore(internal): updated imports (#80)
stainless-app[bot] Dec 14, 2024
0f9e170
chore(internal): codegen related update (#81)
stainless-app[bot] Dec 17, 2024
c62a02c
chore(internal): codegen related update (#82)
stainless-app[bot] Dec 17, 2024
d38014d
docs(readme): example snippet for client context manager (#83)
stainless-app[bot] Dec 17, 2024
1afb368
chore(internal): fix some typos (#84)
stainless-app[bot] Dec 18, 2024
04d214e
chore(internal): codegen related update (#85)
stainless-app[bot] Jan 2, 2025
edc7ec8
chore(client): simplify `Optional[object]` to just `object` (#86)
stainless-app[bot] Jan 7, 2025
bfb504b
chore: add missing isclass check (#87)
stainless-app[bot] Jan 7, 2025
f37b2d0
chore(internal): bump httpx dependency (#88)
stainless-app[bot] Jan 8, 2025
b17e41e
fix(client): only call .close() when needed (#89)
stainless-app[bot] Jan 8, 2025
d717022
docs: fix typos (#90)
stainless-app[bot] Jan 9, 2025
f4ff2a9
chore(internal): codegen related update (#91)
stainless-app[bot] Jan 9, 2025
12e53c2
fix(api): better support union schemas with common properties (#92)
stainless-app[bot] Jan 10, 2025
72ebbe1
fix: correctly handle deserialising `cls` fields (#94)
stainless-app[bot] Jan 10, 2025
2a4460a
chore(internal): codegen related update (#95)
stainless-app[bot] Jan 17, 2025
2af70ba
docs(raw responses): fix duplicate `the` (#96)
stainless-app[bot] Jan 21, 2025
539f898
fix(tests): make test_get_platform less flaky (#97)
stainless-app[bot] Jan 21, 2025
58f4215
chore(internal): avoid pytest-asyncio deprecation warning (#98)
stainless-app[bot] Jan 21, 2025
b40d0f4
chore(internal): minor style changes (#99)
stainless-app[bot] Jan 22, 2025
ff3d099
chore(internal): minor formatting changes (#100)
stainless-app[bot] Jan 24, 2025
74c72a3
chore(internal): codegen related update (#101)
stainless-app[bot] Jan 28, 2025
02ff898
chore(internal): change default timeout to an int (#102)
stainless-app[bot] Feb 4, 2025
704af11
chore(internal): bummp ruff dependency (#103)
stainless-app[bot] Feb 4, 2025
a81d0cb
feat(client): send `X-Stainless-Read-Timeout` header (#104)
stainless-app[bot] Feb 6, 2025
46076eb
chore(internal): fix type traversing dictionary params (#105)
stainless-app[bot] Feb 7, 2025
2c42ae6
chore(internal): minor type handling changes (#106)
stainless-app[bot] Feb 7, 2025
ef75a36
chore(internal): update client tests (#107)
stainless-app[bot] Feb 13, 2025
2cd0b7e
fix: asyncify on non-asyncio runtimes (#108)
stainless-app[bot] Feb 14, 2025
731a3a1
feat(client): allow passing `NotGiven` for body (#109)
stainless-app[bot] Feb 21, 2025
d782782
chore(internal): fix devcontainers setup (#110)
stainless-app[bot] Feb 22, 2025
0cde4b1
chore(internal): properly set __pydantic_private__ (#111)
stainless-app[bot] Feb 26, 2025
f369b75
docs: update URLs from stainlessapi.com to stainless.com (#112)
stainless-app[bot] Feb 28, 2025
ef563e2
chore(docs): update client docstring (#113)
stainless-app[bot] Feb 28, 2025
0a60d39
chore(internal): remove unused http client options forwarding (#114)
stainless-app[bot] Mar 4, 2025
c372084
docs: revise readme docs about nested params (#115)
stainless-app[bot] Mar 11, 2025
ee670af
test: add DEFER_PYDANTIC_BUILD=false flag to tests (#116)
stainless-app[bot] Mar 11, 2025
10305c5
chore(internal): remove extra empty newlines (#117)
stainless-app[bot] Mar 14, 2025
e06c7c2
feat(api): manual updates (#118)
stainless-app[bot] Mar 14, 2025
e37a8c1
feat(api): manual updates (#119)
stainless-app[bot] Mar 14, 2025
d3996ae
codegen metadata
stainless-app[bot] Mar 14, 2025
bcf8542
feat(api): manual updates (#120)
stainless-app[bot] Mar 14, 2025
97b0d81
chore(internal): bump rye to 0.44.0 (#121)
stainless-app[bot] Mar 15, 2025
fcf590f
fix(types): handle more discriminated union shapes (#122)
stainless-app[bot] Mar 15, 2025
62dff95
fix(ci): ensure pip is always available (#123)
stainless-app[bot] Mar 17, 2025
e0320a6
fix(ci): remove publishing patch (#124)
stainless-app[bot] Mar 17, 2025
15f7e02
chore: fix typos (#125)
stainless-app[bot] Mar 27, 2025
adef4b9
codegen metadata
stainless-app[bot] Mar 27, 2025
74ea3e8
fix(types): add missing total=False (#126)
stainless-app[bot] Mar 28, 2025
76f461f
codegen metadata
stainless-app[bot] Mar 29, 2025
66f49a1
codegen metadata
stainless-app[bot] Apr 2, 2025
e49928a
chore(internal): remove trailing character (#127)
stainless-app[bot] Apr 4, 2025
7254708
chore(internal): slight transform perf improvement (#128)
stainless-app[bot] Apr 9, 2025
a3a2656
chore(internal): expand CI branch coverage
stainless-app[bot] Apr 10, 2025
1997d9b
chore(internal): reduce CI branch coverage
stainless-app[bot] Apr 10, 2025
cdf262b
fix(perf): skip traversing types for NotGiven values
stainless-app[bot] Apr 12, 2025
8aa7193
fix(perf): optimize some hot paths
stainless-app[bot] Apr 12, 2025
279561f
chore(internal): update pyright settings
stainless-app[bot] Apr 15, 2025
fa4d5c4
chore(client): minor internal fixes
stainless-app[bot] Apr 15, 2025
019fea9
chore(internal): bump pyright version
stainless-app[bot] Apr 17, 2025
ab8ab97
chore(internal): base client updates
stainless-app[bot] Apr 17, 2025
e33fb48
chore(internal): update models test
stainless-app[bot] Apr 19, 2025
8eb40d8
chore(ci): add timeout thresholds for CI jobs
stainless-app[bot] Apr 23, 2025
dbac172
chore(internal): import reformatting
stainless-app[bot] Apr 23, 2025
b6639ab
chore(internal): fix list file params
stainless-app[bot] Apr 23, 2025
9105502
chore(internal): refactor retries to not use recursion
stainless-app[bot] Apr 23, 2025
640f98b
fix(pydantic v1): more robust ModelField.annotation check
stainless-app[bot] Apr 23, 2025
77de939
chore(internal): minor formatting changes
stainless-app[bot] Apr 24, 2025
0a80ffd
chore(internal): codegen related update
stainless-app[bot] Apr 24, 2025
3740879
chore(ci): only use depot for staging repos
stainless-app[bot] Apr 24, 2025
eb1c4af
chore: broadly detect json family of content-type headers
stainless-app[bot] Apr 24, 2025
dcde56a
chore(internal): avoid errors for isinstance checks on proxies
stainless-app[bot] May 9, 2025
b14060f
fix(package): support direct resource imports
stainless-app[bot] May 10, 2025
28aed61
chore(ci): upload sdks to package manager
stainless-app[bot] May 15, 2025
8aa8c86
chore(ci): fix installation instructions
stainless-app[bot] May 16, 2025
26a5800
release: 0.7.0
stainless-app[bot] May 16, 2025
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
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

USER vscode

RUN curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.35.0" RYE_INSTALL_OPTION="--yes" bash
RUN curl -sSf https://rye.astral.sh/get | RYE_VERSION="0.44.0" RYE_INSTALL_OPTION="--yes" bash
ENV PATH=/home/vscode/.rye/shims:$PATH

RUN echo "[[ -d .venv ]] && source .venv/bin/activate" >> /home/vscode/.bashrc
RUN echo "[[ -d .venv ]] && source .venv/bin/activate || export PATH=\$PATH" >> /home/vscode/.bashrc
3 changes: 3 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
}
}
}
},
"features": {
"ghcr.io/devcontainers/features/node:1": {}
}

// Features to add to the dev container. More info: https://containers.dev/features.
Expand Down
51 changes: 37 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
- next
branches-ignore:
- 'generated'
- 'codegen/**'
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'

jobs:
lint:
timeout-minutes: 10
name: lint
runs-on: ubuntu-latest


runs-on: ${{ github.repository == 'stainless-sdks/braintrust-sdk-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4

Expand All @@ -22,18 +21,43 @@ jobs:
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.35.0'
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'

- name: Install dependencies
run: rye sync --all-features

- name: Run lints
run: ./scripts/lint

upload:
if: github.repository == 'stainless-sdks/braintrust-sdk-python'
timeout-minutes: 10
name: upload
permissions:
contents: read
id-token: write
runs-on: depot-ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Get GitHub OIDC Token
id: github-oidc
uses: actions/github-script@v6
with:
script: core.setOutput('github_token', await core.getIDToken());

- name: Upload tarball
env:
URL: https://pkg.stainless.com/s
AUTH: ${{ steps.github-oidc.outputs.github_token }}
SHA: ${{ github.sha }}
run: ./scripts/utils/upload-artifact.sh

test:
timeout-minutes: 10
name: test
runs-on: ubuntu-latest

runs-on: ${{ github.repository == 'stainless-sdks/braintrust-sdk-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4

Expand All @@ -42,12 +66,11 @@ jobs:
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.35.0'
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'

- name: Bootstrap
run: ./scripts/bootstrap

- name: Run tests
run: ./scripts/test

2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.35.0'
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'

- name: Publish to PyPI
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.6.0"
".": "0.7.0"
}
4 changes: 3 additions & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
configured_endpoints: 110
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-ce135a587d4ea037e39949984ed8f98578043e8c3a90fa203d24f28d234d8675.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/manugoyal%2Fbraintrust-sdk-f0d64ce0e0efde75f9c171f7f3c3d4a72f00a77abb3bc5a7d65b7be1e715689b.yml
openapi_spec_hash: a027e48cc6aea2fab3cbdd38f4081119
config_hash: 1ea10787f4def6c54a53f0e6f776f0a5
96 changes: 96 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2024 Braintrust
Copyright 2025 Braintrust

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
53 changes: 45 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Braintrust Python library provides convenient access to the Braintrust REST
application. The library includes type definitions for all request params and response fields,
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).

It is generated with [Stainless](https://www.stainlessapi.com/).
It is generated with [Stainless](https://www.stainless.com/).

## Documentation

Expand Down Expand Up @@ -140,6 +140,33 @@ for project in first_page.objects:
# Remove `await` for non-async usage.
```

## Nested params

Nested parameters are dictionaries, typed using `TypedDict`, for example:

```python
from braintrust_api import Braintrust

client = Braintrust()

project = client.projects.update(
project_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
settings={
"baseline_experiment_id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"comparison_key": "comparison_key",
"span_field_order": [
{
"column_id": "column_id",
"object_type": "object_type",
"position": "position",
"layout": "full",
}
],
},
)
print(project.settings)
```

## Handling errors

When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `braintrust_api.APIConnectionError` is raised.
Expand Down Expand Up @@ -170,7 +197,7 @@ except braintrust_api.APIStatusError as e:
print(e.response)
```

Error codes are as followed:
Error codes are as follows:

| Status Code | Error Type |
| ----------- | -------------------------- |
Expand Down Expand Up @@ -309,8 +336,7 @@ If you need to access undocumented endpoints, params, or response properties, th
#### Undocumented endpoints

To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
http verbs. Options on the client will be respected (such as retries) will be respected when making this
request.
http verbs. Options on the client will be respected (such as retries) when making this request.

```py
import httpx
Expand Down Expand Up @@ -339,18 +365,19 @@ can also get all the extra fields on the Pydantic model as a dict with

You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:

- Support for proxies
- Custom transports
- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)
- Custom [transports](https://www.python-httpx.org/advanced/transports/)
- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality

```python
import httpx
from braintrust_api import Braintrust, DefaultHttpxClient

client = Braintrust(
# Or use the `BRAINTRUST_BASE_URL` env var
base_url="http://my.test.server.example.com:8083",
http_client=DefaultHttpxClient(
proxies="http://my.test.proxy.example.com",
proxy="http://my.test.proxy.example.com",
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
),
)
Expand All @@ -366,12 +393,22 @@ client.with_options(http_client=DefaultHttpxClient(...))

By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.

```py
from braintrust_api import Braintrust

with Braintrust() as client:
# make requests here
...

# HTTP client is now closed
```

## Versioning

This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:

1. Changes that only affect static types, without breaking runtime behavior.
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_.
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
3. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

## Reporting Security Issues

This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.
This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.

To report a security issue, please contact the Stainless team at security@stainlessapi.com.
To report a security issue, please contact the Stainless team at security@stainless.com.

## Responsible Disclosure

Expand Down
9 changes: 8 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ from braintrust_api.types import (
AISecret,
ACL,
ACLBatchUpdateResponse,
ACLObjectType,
APIKey,
ChatCompletionContentPartImage,
ChatCompletionContentPartText,
Expand All @@ -16,6 +17,7 @@ from braintrust_api.types import (
Dataset,
DatasetEvent,
EnvVar,
EnvVarObjectType,
Experiment,
ExperimentEvent,
FeedbackDatasetItem,
Expand All @@ -32,14 +34,17 @@ from braintrust_api.types import (
InsertExperimentEvent,
InsertProjectLogsEvent,
MetricSummary,
ObjectReference,
OnlineScoreConfig,
Organization,
PatchOrganizationMembersOutput,
Permission,
Project,
ProjectLogsEvent,
ProjectScore,
ProjectScoreCategory,
ProjectScoreConfig,
ProjectScoreType,
ProjectSettings,
ProjectTag,
Prompt,
Expand All @@ -50,13 +55,15 @@ from braintrust_api.types import (
ScoreSummary,
SpanAttributes,
SpanIFrame,
SpanType,
SummarizeDatasetResponse,
SummarizeExperimentResponse,
User,
View,
ViewData,
ViewDataSearch,
ViewOptions,
ViewType,
)
```

Expand Down Expand Up @@ -162,7 +169,7 @@ Methods:
- <code title="get /v1/acl/{acl_id}">client.acls.<a href="./src/braintrust_api/resources/acls.py">retrieve</a>(acl_id) -> <a href="./src/braintrust_api/types/shared/acl.py">ACL</a></code>
- <code title="get /v1/acl">client.acls.<a href="./src/braintrust_api/resources/acls.py">list</a>(\*\*<a href="src/braintrust_api/types/acl_list_params.py">params</a>) -> <a href="./src/braintrust_api/types/shared/acl.py">SyncListObjects[ACL]</a></code>
- <code title="delete /v1/acl/{acl_id}">client.acls.<a href="./src/braintrust_api/resources/acls.py">delete</a>(acl_id) -> <a href="./src/braintrust_api/types/shared/acl.py">ACL</a></code>
- <code title="post /v1/acl/batch-update">client.acls.<a href="./src/braintrust_api/resources/acls.py">batch_update</a>(\*\*<a href="src/braintrust_api/types/acl_batch_update_params.py">params</a>) -> <a href="./src/braintrust_api/types/shared/acl_batch_update_response.py">ACLBatchUpdateResponse</a></code>
- <code title="post /v1/acl/batch_update">client.acls.<a href="./src/braintrust_api/resources/acls.py">batch_update</a>(\*\*<a href="src/braintrust_api/types/acl_batch_update_params.py">params</a>) -> <a href="./src/braintrust_api/types/shared/acl_batch_update_response.py">ACLBatchUpdateResponse</a></code>
- <code title="delete /v1/acl">client.acls.<a href="./src/braintrust_api/resources/acls.py">find_and_delete</a>(\*\*<a href="src/braintrust_api/types/acl_find_and_delete_params.py">params</a>) -> <a href="./src/braintrust_api/types/shared/acl.py">ACL</a></code>

# Users
Expand Down
3 changes: 0 additions & 3 deletions bin/publish-pypi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@
set -eux
mkdir -p dist
rye build --clean
# Patching importlib-metadata version until upstream library version is updated
# https://github.com/pypa/twine/issues/977#issuecomment-2189800841
"$HOME/.rye/self/bin/python3" -m pip install 'importlib-metadata==7.2.1'
rye publish --yes --token=$PYPI_TOKEN
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ cache_fine_grained = True
# ```
# Changing this codegen to make mypy happy would increase complexity
# and would not be worth it.
disable_error_code = func-returns-value
disable_error_code = func-returns-value,overload-cannot-match

# https://github.com/python/mypy/issues/12162
[mypy.overrides]
Expand Down
Loading