The FoundryRestClient and CachedFoundryClient are deprecated in the v2, it should work the same as the one in v1. But now it acts only as a wrapper around [the new v2 clients](#foundry_dev_tools.clients).
The following samples will include the way the new clients and classes can be used in v2, and the old way how it was done in the v1.
Queries the Foundry SQL server with spark SQL dialect.
```python
from foundry_dev_tools import FoundryContext
ctx = FoundryContext()
df = ctx.foundry_sql_server.query_foundry_sql(
"SELECT * FROM `/path/to/test_dataset`", branch="master"
) # returns pandas dataframe by default, can be changed by setting the return_type parameter
print(df.shape)
```
```python
from foundry_dev_tools import FoundryRestClient
rest_client = FoundryRestClient()
df = rest_client.query_foundry_sql("SELECT * FROM `/path/to/test_dataset`", branch='master')
df.to_string()
```
:::{seealso}
With the Dataset class
:::
If dataset isn't already in the cache, download it to the cache and returns a PySpark DataFrame. Useful when reusing datasets.
from foundry_dev_tools import CachedFoundryClient
cached_client = CachedFoundryClient()
df = cached_client.load_dataset('/path/to/test_dataset', branch='master')
df.toPandas().to_string()FDT can act as the auth provider for the foundry-platform-sdk and any TPA-specific OSDK package generated from a Foundry third-party application (TPA).
Install the optional dependency first:
pip install 'foundry-dev-tools[public]'ctx.public_client_v2 returns a pre-configured foundry_sdk.v2.FoundryClient:
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())ctx.public_auth returns a FoundryDevToolsAuth adapter that can be passed directly to any OSDK client:
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)