Skip to content

Commit e38fb67

Browse files
authored
feat: add FoundryContext.public_auth for OSDK and platform SDK integration (#121)
* feat: add FoundryContext.public_auth for OSDK and platform SDK integration Adds ctx.public_auth property returning a FoundryDevToolsAuth adapter, making it straightforward to feed FDT credentials into any TPA OSDK or foundry-platform-sdk client without manual imports. Also simplifies public_client_v2 to delegate to public_auth, and fixes the missing-dep error message to show the correct PyPI package name (foundry-platform-sdk instead of foundry_sdk). * docs: add foundry-platform-sdk and OSDK integration examples * docs: add foundry-platform-sdk and OSDK integration examples to README
1 parent 782954d commit e38fb67

6 files changed

Lines changed: 107 additions & 3 deletions

File tree

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,35 @@ It consists of two parts:
5252
# Out[2]: (17, 10)
5353
```
5454

55+
- FDT can also act as the auth provider for [foundry-platform-sdk](https://pypi.org/project/foundry-platform-sdk/) and any TPA-specific OSDK package. Install the optional dependency first:
56+
57+
```shell
58+
pip install 'foundry-dev-tools[public]'
59+
```
60+
61+
Use the built-in `foundry-platform-sdk` client:
62+
63+
```python
64+
import pyarrow as pa
65+
import polars as pl
66+
from foundry_dev_tools import FoundryContext
67+
68+
ctx = FoundryContext()
69+
client = ctx.public_client_v2
70+
ds = client.datasets.Dataset.read_table("<dataset-rid>", format="ARROW")
71+
df = pl.from_arrow(pa.ipc.open_stream(ds).read_all())
72+
```
73+
74+
Or pass FDT's auth to any TPA OSDK client:
75+
76+
```python
77+
from foundry_dev_tools import FoundryContext
78+
from my_tpa_sdk import FoundryClient # your generated OSDK package
79+
80+
ctx = FoundryContext()
81+
client = FoundryClient(auth=ctx.public_auth, hostname=ctx.host.domain)
82+
```
83+
5584
## Quickstart
5685

5786
With pip:

docs/changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog],
66
and this project adheres to [Semantic Versioning].
77

8+
## [2.1.24] - 2026-05-07
9+
10+
## Added
11+
- add `FoundryContext.public_auth` property returning a `FoundryDevToolsAuth` adapter for use with OSDK and foundry-platform-sdk clients
12+
13+
## Fixed
14+
- fix misleading error message when `foundry-platform-sdk` is not installed (was suggesting `pip install foundry_sdk`)
15+
816
## [2.1.23] - 2026-02-20
917

1018
## Added

docs/examples/api.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,40 @@ cached_client = CachedFoundryClient()
4949
df = cached_client.load_dataset('/path/to/test_dataset', branch='master')
5050
df.toPandas().to_string()
5151
```
52+
53+
## foundry-platform-sdk and OSDK integration
54+
55+
FDT can act as the auth provider for the [foundry-platform-sdk](https://pypi.org/project/foundry-platform-sdk/) and any TPA-specific OSDK package generated from a Foundry third-party application (TPA).
56+
57+
Install the optional dependency first:
58+
59+
```shell
60+
pip install 'foundry-dev-tools[public]'
61+
```
62+
63+
### Using the built-in foundry-platform-sdk client
64+
65+
`ctx.public_client_v2` returns a pre-configured `foundry_sdk.v2.FoundryClient`:
66+
67+
```python
68+
import pyarrow as pa
69+
import polars as pl
70+
from foundry_dev_tools import FoundryContext
71+
72+
ctx = FoundryContext()
73+
client = ctx.public_client_v2
74+
ds = client.datasets.Dataset.read_table("<dataset-rid>", format="ARROW")
75+
df = pl.from_arrow(pa.ipc.open_stream(ds).read_all())
76+
```
77+
78+
### Using a TPA OSDK package
79+
80+
`ctx.public_auth` returns a `FoundryDevToolsAuth` adapter that can be passed directly to any OSDK client:
81+
82+
```python
83+
from foundry_dev_tools import FoundryContext
84+
from my_tpa_sdk import FoundryClient # your generated OSDK package
85+
86+
ctx = FoundryContext()
87+
client = FoundryClient(auth=ctx.public_auth, hostname=ctx.host.domain)
88+
```

libs/foundry-dev-tools/src/foundry_dev_tools/_optional/foundry_platform_sdk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
except ImportError:
99
from foundry_dev_tools._optional import FakeModule
1010

11-
foundry_sdk = FakeModule("foundry_sdk")
11+
foundry_sdk = FakeModule("foundry-platform-sdk")
1212

1313
__all__ = ["foundry_sdk"]

libs/foundry-dev-tools/src/foundry_dev_tools/config/context.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from foundry_dev_tools.config.config_types import Host, Token
4141
from foundry_dev_tools.config.token_provider import TokenProvider
4242
from foundry_dev_tools.foundry_api_client import FoundryRestClient
43+
from foundry_dev_tools.public_sdk.auth import FoundryDevToolsAuth
4344
from foundry_dev_tools.utils import api_types
4445

4546

@@ -192,6 +193,20 @@ def foundry_rest_client(self) -> FoundryRestClient:
192193

193194
return FoundryRestClient(ctx=self)
194195

196+
@property
197+
def public_auth(self) -> FoundryDevToolsAuth:
198+
"""Returns :py:class:`foundry_dev_tools.public_sdk.auth.FoundryDevToolsAuth`.
199+
200+
Auth adapter for use with OSDK and foundry-platform-sdk clients.
201+
202+
Examples:
203+
>>> from my_tpa_sdk import FoundryClient
204+
>>> client = FoundryClient(auth=ctx.public_auth, hostname=ctx.host.domain)
205+
"""
206+
from foundry_dev_tools.public_sdk.auth import FoundryDevToolsAuth
207+
208+
return FoundryDevToolsAuth(self)
209+
195210
@cached_property
196211
def public_client_v2(self) -> FoundrySdkV2Client:
197212
"""Returns :py:class:`foundry_sdk.v2.FoundryClient`.
@@ -208,10 +223,9 @@ def public_client_v2(self) -> FoundrySdkV2Client:
208223
>>> polars_df = pl.from_arrow(pa_df)
209224
"""
210225
from foundry_dev_tools._optional.foundry_platform_sdk import foundry_sdk
211-
from foundry_dev_tools.public_sdk.auth import FoundryDevToolsAuth
212226

213227
return foundry_sdk.v2.FoundryClient(
214-
auth=FoundryDevToolsAuth(self),
228+
auth=self.public_auth,
215229
hostname=self.host.domain,
216230
)
217231

tests/unit/public_sdk/test_auth.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@ def test_foundry_dev_tools_auth_get_token_bridges_context_token(test_context_moc
2626
assert token.access_token == expected_token
2727

2828

29+
def test_public_auth_returns_foundry_dev_tools_auth(test_context_mock):
30+
"""Verify FoundryContext.public_auth returns a FoundryDevToolsAuth wrapping the context."""
31+
auth = test_context_mock.public_auth
32+
33+
assert isinstance(auth, FoundryDevToolsAuth)
34+
assert auth._ctx is test_context_mock
35+
36+
37+
def test_public_auth_token_matches_context_token(test_context_mock):
38+
"""Verify public_auth reflects the current context token."""
39+
expected_token = "public-auth-token-789" # noqa: S105
40+
test_context_mock.token_provider._jwt = expected_token
41+
42+
assert test_context_mock.public_auth.get_token().access_token == expected_token
43+
44+
2945
def test_public_client_v2_uses_foundry_dev_tools_auth(test_context_mock):
3046
"""Verify FoundryContext.public_client_v2 creates FoundryClient with FoundryDevToolsAuth."""
3147
from foundry_sdk.v2 import FoundryClient

0 commit comments

Comments
 (0)