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
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,35 @@ It consists of two parts:
# Out[2]: (17, 10)
```

- 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:

```shell
pip install 'foundry-dev-tools[public]'
```

Use the built-in `foundry-platform-sdk` client:

```python
import pyarrow as pa
import polars as pl
from foundry_dev_tools import FoundryContext

ctx = FoundryContext()
client = ctx.public_client_v2
ds = client.datasets.Dataset.read_table("<dataset-rid>", format="ARROW")
df = pl.from_arrow(pa.ipc.open_stream(ds).read_all())
```

Or pass FDT's auth to any TPA OSDK client:

```python
from foundry_dev_tools import FoundryContext
from my_tpa_sdk import FoundryClient # your generated OSDK package

ctx = FoundryContext()
client = FoundryClient(auth=ctx.public_auth, hostname=ctx.host.domain)
```

## Quickstart

With pip:
Expand Down
8 changes: 8 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog],
and this project adheres to [Semantic Versioning].

## [2.1.24] - 2026-05-07

## Added
- add `FoundryContext.public_auth` property returning a `FoundryDevToolsAuth` adapter for use with OSDK and foundry-platform-sdk clients

## Fixed
- fix misleading error message when `foundry-platform-sdk` is not installed (was suggesting `pip install foundry_sdk`)

## [2.1.23] - 2026-02-20

## Added
Expand Down
37 changes: 37 additions & 0 deletions docs/examples/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,40 @@ cached_client = CachedFoundryClient()
df = cached_client.load_dataset('/path/to/test_dataset', branch='master')
df.toPandas().to_string()
```

## foundry-platform-sdk and OSDK integration

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).

Install the optional dependency first:

```shell
pip install 'foundry-dev-tools[public]'
```

### Using the built-in foundry-platform-sdk client

`ctx.public_client_v2` returns a pre-configured `foundry_sdk.v2.FoundryClient`:

```python
import pyarrow as pa
import polars as pl
from foundry_dev_tools import FoundryContext

ctx = FoundryContext()
client = ctx.public_client_v2
ds = client.datasets.Dataset.read_table("<dataset-rid>", format="ARROW")
df = pl.from_arrow(pa.ipc.open_stream(ds).read_all())
```

### Using a TPA OSDK package

`ctx.public_auth` returns a `FoundryDevToolsAuth` adapter that can be passed directly to any OSDK client:

```python
from foundry_dev_tools import FoundryContext
from my_tpa_sdk import FoundryClient # your generated OSDK package

ctx = FoundryContext()
client = FoundryClient(auth=ctx.public_auth, hostname=ctx.host.domain)
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
except ImportError:
from foundry_dev_tools._optional import FakeModule

foundry_sdk = FakeModule("foundry_sdk")
foundry_sdk = FakeModule("foundry-platform-sdk")

__all__ = ["foundry_sdk"]
18 changes: 16 additions & 2 deletions libs/foundry-dev-tools/src/foundry_dev_tools/config/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from foundry_dev_tools.config.config_types import Host, Token
from foundry_dev_tools.config.token_provider import TokenProvider
from foundry_dev_tools.foundry_api_client import FoundryRestClient
from foundry_dev_tools.public_sdk.auth import FoundryDevToolsAuth
from foundry_dev_tools.utils import api_types


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

return FoundryRestClient(ctx=self)

@property
def public_auth(self) -> FoundryDevToolsAuth:
"""Returns :py:class:`foundry_dev_tools.public_sdk.auth.FoundryDevToolsAuth`.

Auth adapter for use with OSDK and foundry-platform-sdk clients.

Examples:
>>> from my_tpa_sdk import FoundryClient
>>> client = FoundryClient(auth=ctx.public_auth, hostname=ctx.host.domain)
"""
from foundry_dev_tools.public_sdk.auth import FoundryDevToolsAuth

return FoundryDevToolsAuth(self)

@cached_property
def public_client_v2(self) -> FoundrySdkV2Client:
"""Returns :py:class:`foundry_sdk.v2.FoundryClient`.
Expand All @@ -208,10 +223,9 @@ def public_client_v2(self) -> FoundrySdkV2Client:
>>> polars_df = pl.from_arrow(pa_df)
"""
from foundry_dev_tools._optional.foundry_platform_sdk import foundry_sdk
from foundry_dev_tools.public_sdk.auth import FoundryDevToolsAuth

return foundry_sdk.v2.FoundryClient(
auth=FoundryDevToolsAuth(self),
auth=self.public_auth,
hostname=self.host.domain,
)

Expand Down
16 changes: 16 additions & 0 deletions tests/unit/public_sdk/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ def test_foundry_dev_tools_auth_get_token_bridges_context_token(test_context_moc
assert token.access_token == expected_token


def test_public_auth_returns_foundry_dev_tools_auth(test_context_mock):
"""Verify FoundryContext.public_auth returns a FoundryDevToolsAuth wrapping the context."""
auth = test_context_mock.public_auth

assert isinstance(auth, FoundryDevToolsAuth)
assert auth._ctx is test_context_mock


def test_public_auth_token_matches_context_token(test_context_mock):
"""Verify public_auth reflects the current context token."""
expected_token = "public-auth-token-789" # noqa: S105
test_context_mock.token_provider._jwt = expected_token

assert test_context_mock.public_auth.get_token().access_token == expected_token


def test_public_client_v2_uses_foundry_dev_tools_auth(test_context_mock):
"""Verify FoundryContext.public_client_v2 creates FoundryClient with FoundryDevToolsAuth."""
from foundry_sdk.v2 import FoundryClient
Expand Down
Loading