baseten-bdn 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- baseten_bdn-0.1.0/.github/workflows/ci.yml +36 -0
- baseten_bdn-0.1.0/.github/workflows/publish.yml +20 -0
- baseten_bdn-0.1.0/.gitignore +6 -0
- baseten_bdn-0.1.0/LICENSE +21 -0
- baseten_bdn-0.1.0/PKG-INFO +94 -0
- baseten_bdn-0.1.0/README.md +74 -0
- baseten_bdn-0.1.0/baseten/bdn/__init__.py +6 -0
- baseten_bdn-0.1.0/baseten/bdn/_useragent.py +12 -0
- baseten_bdn-0.1.0/baseten/bdn/hotload/__init__.py +35 -0
- baseten_bdn-0.1.0/baseten/bdn/hotload/_client.py +533 -0
- baseten_bdn-0.1.0/baseten/bdn/hotload/_models.py +132 -0
- baseten_bdn-0.1.0/baseten/bdn/py.typed +0 -0
- baseten_bdn-0.1.0/baseten/bdn/volumes/__init__.py +49 -0
- baseten_bdn-0.1.0/baseten/bdn/volumes/_cannery.py +128 -0
- baseten_bdn-0.1.0/baseten/bdn/volumes/_client.py +623 -0
- baseten_bdn-0.1.0/baseten/bdn/volumes/_errors.py +82 -0
- baseten_bdn-0.1.0/baseten/bdn/volumes/_manifest.py +460 -0
- baseten_bdn-0.1.0/baseten/bdn/volumes/_materialize.py +146 -0
- baseten_bdn-0.1.0/baseten/bdn/volumes/_models.py +82 -0
- baseten_bdn-0.1.0/baseten/bdn/volumes/_ref.py +246 -0
- baseten_bdn-0.1.0/baseten/bdn/volumes/_s3.py +257 -0
- baseten_bdn-0.1.0/pyproject.toml +73 -0
- baseten_bdn-0.1.0/tests/__init__.py +0 -0
- baseten_bdn-0.1.0/tests/conftest.py +70 -0
- baseten_bdn-0.1.0/tests/test_hotload.py +474 -0
- baseten_bdn-0.1.0/tests/test_import.py +13 -0
- baseten_bdn-0.1.0/tests/test_volumes.py +1057 -0
- baseten_bdn-0.1.0/tests/volume_fixtures.py +336 -0
- baseten_bdn-0.1.0/uv.lock +617 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
check:
|
|
10
|
+
strategy:
|
|
11
|
+
matrix:
|
|
12
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
13
|
+
python-version: ["3.14"]
|
|
14
|
+
include:
|
|
15
|
+
- os: ubuntu-latest
|
|
16
|
+
python-version: "3.11"
|
|
17
|
+
runs-on: ${{ matrix.os }}
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- uses: astral-sh/setup-uv@v6
|
|
22
|
+
|
|
23
|
+
- uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: ${{ matrix.python-version }}
|
|
26
|
+
allow-prereleases: true
|
|
27
|
+
|
|
28
|
+
- run: uv sync
|
|
29
|
+
|
|
30
|
+
- name: Lint
|
|
31
|
+
run: |
|
|
32
|
+
uv run poe lint
|
|
33
|
+
uv run poe typecheck
|
|
34
|
+
|
|
35
|
+
- name: Test
|
|
36
|
+
run: uv run poe test
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
permissions:
|
|
11
|
+
id-token: write
|
|
12
|
+
contents: read
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- uses: astral-sh/setup-uv@v6
|
|
17
|
+
|
|
18
|
+
- run: uv build
|
|
19
|
+
|
|
20
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Baseten
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: baseten-bdn
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for working with BDN inside and outside Baseten
|
|
5
|
+
Project-URL: Homepage, https://github.com/basetenlabs/baseten-bdn
|
|
6
|
+
Project-URL: Issues, https://github.com/basetenlabs/baseten-bdn/issues
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Requires-Dist: backports-zstd>=1.7.0; python_full_version < '3.14'
|
|
15
|
+
Requires-Dist: baseten<1,>=0.11
|
|
16
|
+
Requires-Dist: blake3>=1.0.9
|
|
17
|
+
Requires-Dist: httpx>=0.27
|
|
18
|
+
Requires-Dist: pydantic>=2.0
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# baseten-bdn
|
|
22
|
+
|
|
23
|
+
Python SDK for working with BDN inside and outside Baseten.
|
|
24
|
+
|
|
25
|
+
This package is under initial development. It installs as `baseten-bdn` and
|
|
26
|
+
imports as `baseten.bdn`. The `baseten` package is a namespace shared with
|
|
27
|
+
other Baseten SDKs such as `baseten` and `baseten-loops`.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
pip install baseten-bdn
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Hot Load
|
|
36
|
+
|
|
37
|
+
Inside a model pod that is opted in to BDN Hot Load, `baseten.bdn.hotload`
|
|
38
|
+
attaches BDN volumes below `/bdn/mounts` at runtime. An attach returns once the
|
|
39
|
+
directory is readable.
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from baseten.bdn.hotload import HotLoadClient
|
|
43
|
+
|
|
44
|
+
with HotLoadClient() as hotload:
|
|
45
|
+
adapter = hotload.attach("bdn:adapters/sql-lora@b3:2547…", target="sql-lora")
|
|
46
|
+
|
|
47
|
+
load_adapter(adapter.path) # /bdn/mounts/sql-lora
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`AsyncHotLoadClient` offers the same methods as coroutines. Attachments belong
|
|
51
|
+
to the pod and stay mounted after the client is closed; call `detach` to free a
|
|
52
|
+
target name for reuse.
|
|
53
|
+
|
|
54
|
+
## Volumes
|
|
55
|
+
|
|
56
|
+
From any machine with a Baseten API key, `baseten.bdn.volumes` reads a volume
|
|
57
|
+
version's manifest or pulls a version into a local directory. The client mints a short-lived token through the Baseten API,
|
|
58
|
+
resolves the ref, and reads the volume's objects directly from storage with
|
|
59
|
+
the credentials it is given, verifying every object against its recorded
|
|
60
|
+
digest.
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from baseten.bdn.volumes import VolumeClient
|
|
64
|
+
|
|
65
|
+
with VolumeClient(api_key="...") as volumes:
|
|
66
|
+
result = volumes.pull("bdn:loops/sampler-abc123:step-100", "./checkpoint")
|
|
67
|
+
|
|
68
|
+
print(result.version_ref, result.file_count, result.bytes_written)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Refs are `bdn:<namespace>/<volume>` with an optional `:<tag>` or `@<digest>`
|
|
72
|
+
selector and an optional `/path` inside the version; `VolumeRef` parses and
|
|
73
|
+
renders them. A path on the ref, or `include=[...]`, narrows a pull to those
|
|
74
|
+
entries without moving them. A pull is staged next to `dest_dir` and renamed
|
|
75
|
+
into place once complete, so a failed pull leaves nothing behind; pass
|
|
76
|
+
`overwrite=True` to write into an existing directory in place. Pulling is
|
|
77
|
+
supported on Linux and macOS.
|
|
78
|
+
|
|
79
|
+
## Development
|
|
80
|
+
|
|
81
|
+
Requires [uv](https://docs.astral.sh/uv/).
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
uv sync
|
|
85
|
+
uv run poe lint
|
|
86
|
+
uv run poe typecheck
|
|
87
|
+
uv run poe test
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Run `uv run poe format` to apply formatting and lint fixes.
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# baseten-bdn
|
|
2
|
+
|
|
3
|
+
Python SDK for working with BDN inside and outside Baseten.
|
|
4
|
+
|
|
5
|
+
This package is under initial development. It installs as `baseten-bdn` and
|
|
6
|
+
imports as `baseten.bdn`. The `baseten` package is a namespace shared with
|
|
7
|
+
other Baseten SDKs such as `baseten` and `baseten-loops`.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
pip install baseten-bdn
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Hot Load
|
|
16
|
+
|
|
17
|
+
Inside a model pod that is opted in to BDN Hot Load, `baseten.bdn.hotload`
|
|
18
|
+
attaches BDN volumes below `/bdn/mounts` at runtime. An attach returns once the
|
|
19
|
+
directory is readable.
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
from baseten.bdn.hotload import HotLoadClient
|
|
23
|
+
|
|
24
|
+
with HotLoadClient() as hotload:
|
|
25
|
+
adapter = hotload.attach("bdn:adapters/sql-lora@b3:2547…", target="sql-lora")
|
|
26
|
+
|
|
27
|
+
load_adapter(adapter.path) # /bdn/mounts/sql-lora
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
`AsyncHotLoadClient` offers the same methods as coroutines. Attachments belong
|
|
31
|
+
to the pod and stay mounted after the client is closed; call `detach` to free a
|
|
32
|
+
target name for reuse.
|
|
33
|
+
|
|
34
|
+
## Volumes
|
|
35
|
+
|
|
36
|
+
From any machine with a Baseten API key, `baseten.bdn.volumes` reads a volume
|
|
37
|
+
version's manifest or pulls a version into a local directory. The client mints a short-lived token through the Baseten API,
|
|
38
|
+
resolves the ref, and reads the volume's objects directly from storage with
|
|
39
|
+
the credentials it is given, verifying every object against its recorded
|
|
40
|
+
digest.
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from baseten.bdn.volumes import VolumeClient
|
|
44
|
+
|
|
45
|
+
with VolumeClient(api_key="...") as volumes:
|
|
46
|
+
result = volumes.pull("bdn:loops/sampler-abc123:step-100", "./checkpoint")
|
|
47
|
+
|
|
48
|
+
print(result.version_ref, result.file_count, result.bytes_written)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Refs are `bdn:<namespace>/<volume>` with an optional `:<tag>` or `@<digest>`
|
|
52
|
+
selector and an optional `/path` inside the version; `VolumeRef` parses and
|
|
53
|
+
renders them. A path on the ref, or `include=[...]`, narrows a pull to those
|
|
54
|
+
entries without moving them. A pull is staged next to `dest_dir` and renamed
|
|
55
|
+
into place once complete, so a failed pull leaves nothing behind; pass
|
|
56
|
+
`overwrite=True` to write into an existing directory in place. Pulling is
|
|
57
|
+
supported on Linux and macOS.
|
|
58
|
+
|
|
59
|
+
## Development
|
|
60
|
+
|
|
61
|
+
Requires [uv](https://docs.astral.sh/uv/).
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
uv sync
|
|
65
|
+
uv run poe lint
|
|
66
|
+
uv run poe typecheck
|
|
67
|
+
uv run poe test
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Run `uv run poe format` to apply formatting and lint fixes.
|
|
71
|
+
|
|
72
|
+
## License
|
|
73
|
+
|
|
74
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import functools
|
|
4
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@functools.cache
|
|
8
|
+
def user_agent() -> str:
|
|
9
|
+
try:
|
|
10
|
+
return f"baseten-bdn/{version('baseten-bdn')}"
|
|
11
|
+
except PackageNotFoundError:
|
|
12
|
+
return "baseten-bdn/unknown"
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Client for the pod-local BDN Hot Load API.
|
|
2
|
+
|
|
3
|
+
Use :class:`HotLoadClient` or :class:`AsyncHotLoadClient` from inside an
|
|
4
|
+
opted-in model pod to attach BDN volumes below ``/bdn/mounts`` at runtime.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from baseten.bdn.hotload._client import (
|
|
8
|
+
AsyncHotLoadClient,
|
|
9
|
+
HotLoadClient,
|
|
10
|
+
HotLoadClientOptions,
|
|
11
|
+
)
|
|
12
|
+
from baseten.bdn.hotload._models import (
|
|
13
|
+
AttachmentState,
|
|
14
|
+
HotLoadAPIError,
|
|
15
|
+
HotLoadAttachError,
|
|
16
|
+
HotLoadConnectionError,
|
|
17
|
+
HotLoadError,
|
|
18
|
+
HotLoadProtocolError,
|
|
19
|
+
HotLoadTimeoutError,
|
|
20
|
+
VolumeAttachment,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"AsyncHotLoadClient",
|
|
25
|
+
"AttachmentState",
|
|
26
|
+
"HotLoadAPIError",
|
|
27
|
+
"HotLoadAttachError",
|
|
28
|
+
"HotLoadClient",
|
|
29
|
+
"HotLoadClientOptions",
|
|
30
|
+
"HotLoadConnectionError",
|
|
31
|
+
"HotLoadError",
|
|
32
|
+
"HotLoadProtocolError",
|
|
33
|
+
"HotLoadTimeoutError",
|
|
34
|
+
"VolumeAttachment",
|
|
35
|
+
]
|