From 75a32618fda01ab5d760877114066c978af8a1f8 Mon Sep 17 00:00:00 2001 From: Nico Mohr Date: Thu, 7 May 2026 14:26:41 +0200 Subject: [PATCH 1/3] 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/changelog.md | 8 ++++++++ .../_optional/foundry_platform_sdk.py | 2 +- .../src/foundry_dev_tools/config/context.py | 18 ++++++++++++++++-- tests/unit/public_sdk/test_auth.py | 16 ++++++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index c588cf6..7595c67 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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 diff --git a/libs/foundry-dev-tools/src/foundry_dev_tools/_optional/foundry_platform_sdk.py b/libs/foundry-dev-tools/src/foundry_dev_tools/_optional/foundry_platform_sdk.py index 4d26019..b1c660e 100644 --- a/libs/foundry-dev-tools/src/foundry_dev_tools/_optional/foundry_platform_sdk.py +++ b/libs/foundry-dev-tools/src/foundry_dev_tools/_optional/foundry_platform_sdk.py @@ -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"] diff --git a/libs/foundry-dev-tools/src/foundry_dev_tools/config/context.py b/libs/foundry-dev-tools/src/foundry_dev_tools/config/context.py index 7a956dc..dc248d0 100644 --- a/libs/foundry-dev-tools/src/foundry_dev_tools/config/context.py +++ b/libs/foundry-dev-tools/src/foundry_dev_tools/config/context.py @@ -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 @@ -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`. @@ -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, ) diff --git a/tests/unit/public_sdk/test_auth.py b/tests/unit/public_sdk/test_auth.py index c3f1121..be0ac94 100644 --- a/tests/unit/public_sdk/test_auth.py +++ b/tests/unit/public_sdk/test_auth.py @@ -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 From 3ded410f6d5e6dbbc1c583c6aab09bcecfb9e657 Mon Sep 17 00:00:00 2001 From: Nico Mohr Date: Thu, 7 May 2026 14:49:16 +0200 Subject: [PATCH 2/3] docs: add foundry-platform-sdk and OSDK integration examples --- docs/examples/api.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/examples/api.md b/docs/examples/api.md index 5b4336b..7ec6513 100644 --- a/docs/examples/api.md +++ b/docs/examples/api.md @@ -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("", 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) +``` From a95d3072278bbcdd89b3dca2594885df0415eb85 Mon Sep 17 00:00:00 2001 From: Nico Mohr Date: Thu, 7 May 2026 14:57:59 +0200 Subject: [PATCH 3/3] docs: add foundry-platform-sdk and OSDK integration examples to README --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 34063e0..1994835 100644 --- a/README.md +++ b/README.md @@ -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("", 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: