Name | unitycatalog-client JSON |
Version |
0.2.1
JSON |
| download |
home_page | None |
Summary | Official Python SDK for Unity Catalog |
upload_time | 2024-12-04 17:56:17 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | Apache-2.0 |
keywords |
sdk
unitycatalog
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Unity Catalog Python Client SDK
Welcome to the official Python Client SDK for Unity Catalog!
Unity Catalog is the industry's only universal catalog for data and AI.
- **Multimodal interface supports any format, engine, and asset**
- Multi-format support: It is extensible and supports Delta Lake, Apache Iceberg and Apache Hudi via UniForm, Apache Parquet, JSON, CSV, and many others.
- Multi-engine support: With its open APIs, data cataloged in Unity can be read by many leading compute engines.
- Multimodal: It supports all your data and AI assets, including tables, files, functions, AI models.
- **Open source API and implementation** - OpenAPI spec and OSS implementation (Apache 2.0 license). It is also compatible with Apache Hive's metastore API and Apache Iceberg's REST catalog API. Unity Catalog is currently a sandbox project with LF AI and Data Foundation (part of the Linux Foundation).
- **Unified governance** for data and AI - Govern and secure tabular data, unstructured assets, and AI assets with a single interface.
## Python Client SDK
The Unity Catalog Python SDK provides a convenient Python-native interface to all of the functionality of the Unity Catalog
REST APIs. The library includes interfaces for all supported public modules.
This library is generated using the [OpenAPI Generator](https://openapi-generator.tech/docs/generators/python) toolkit, providing client interfaces using the `aiohttp` request handling library.
## Installation
The Python Client SDK and associated shared namespace package for Unity Catalog use [hatch](https://hatch.pypa.io/latest/) as their supported build backend.
To ensure that you can install the package, install `hatch` via any of the listed options [here](https://hatch.pypa.io/latest/install/).
To use the `unitycatalog-client` SDK, you can install directly from PyPI:
```sh
pip install unitycatalog-client
```
To install from source, you will need to fork and clone the [unitycatalog repository](https://github.com/unitycatalog/unitycatalog) locally.
To build the Python source locally, you will need to have `JDK17` installed and activated.
Once your configuration supports the execution of [sbt](https://www.scala-sbt.org/), you can run the following within the root
of the repository to generate the Python Client SDK source:
```sh
build/sbt pythonClient/generate
```
The source code will be generated at `unitycatalog/clients/python/target`.
You can then install the package in editable mode from the repository root:
```sh
pip install -e clients/python/target
```
## Usage
To get started with using the Python Client SDK, first ensure that you have a running Unity Catalog server to connect to.
You can follow instructions [here](https://docs.unitycatalog.io/quickstart/) to quickly get started with setting up
a local Unity Catalog server if needed.
Once the server is running, you can set up the Python client to make async requests to the Unity Catalog server.
For the examples listed here, we will be using a local unauthenticated server for simplicity's sake.
```python
from unitycatalog.client import Configuration
config = Configuration()
config.host = "http://localhost:8080/api/2.1/unity-catalog"
```
Once we have our configuration, we can set our client that we will be using for each request:
```python
from unitycatalog.client import ApiClient
client = ApiClient(configuration=config)
```
With our client configured and instantiated, we can use any of the Unity Catalog APIs by importing from the
`client` namespace directly and send requests to the server.
```python
from unitycatalog.client import CatalogsApi
catalogs_api = CatalogsApi(api_client=client)
my_catalogs = await catalogs_api.list_catalogs()
```
>Note: APIs that support pagination (such as `list_catalogs`) should have continutation token logic for assembling the paginated
return values into a single collection.
A simple example of consuming a paginated response is:
```python
async def list_all_catalogs(catalog_api):
token = None
catalogs = []
while True:
results = await catalog_api.list_catalogs(page_token=token)
catalogs += results.catalogs
if next_token := results.next_page_token:
token = next_token
else:
break
return catalogs
my_catalogs = await list_all_catalogs(catalogs_api)
```
Creating a new catalog with the Python SDK is straight-forward:
```python
from unitycatalog.client.models import CreateCatalog, CatalogInfo
async def create_catalog(catalog_name, catalog_api, comment=None):
new_catalog = CreateCatalog(
name=catalog_name,
comment=comment or ""
)
return await catalog_api.create_catalog(create_catalog=new_catalog)
await create_catalog("MyNewCatalog", catalog_api=catalogs_api, comment="This is a new catalog.")
```
Adding a new Schema to our created Catalog is similarly simple:
```python
from unitycatalog.client import SchemasApi
from unitycatalog.client import CreateSchema, SchemaInfo
schemas_api = SchemasApi(api_client=client)
async def create_schema(schema_name, catalog_name, schema_api, comment=None):
new_schema = CreateSchema(
name=schema_name,
catalog_name=catalog_name,
comment=comment or ""
)
return await schema_api.create_schema(create_schema=new_schema)
await create_schema(schema_name="MyNewSchema", catalog_name="MyNewCatalog", schema_api=schemas_api, comment="This is a new schema.")
```
And listing the schemas within our newly created Catalog (note that if you expect paginated responses, ensure that you are passing
continuation tokens as shown above in `list_all_catalogs`):
```python
await schemas_api.list_schemas(catalog_name="MyNewCatalog")
```
## Feedback
Have requests for the Unity Catalog project? Interested in getting involved in the Open Source project?
See the [repository on GitHub](https://github.com/unitycatalog/unitycatalog)
Read [the documentation](https://www.unitycatalog.io/) for more guidance and examples!
Raw data
{
"_id": null,
"home_page": null,
"name": "unitycatalog-client",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "Denny Lee <denny.lee@databricks.com>, Ben Wilson <benjamin.wilson@databricks.com>, Tathagata Das <tathagata.das1565@gmail.com>",
"keywords": "sdk, unitycatalog",
"author": null,
"author_email": "Unity Catalog Developers <dev-feedback@unitycatalog.com>",
"download_url": "https://files.pythonhosted.org/packages/ab/fc/b479fd3a932301745da7ed39aa25105e74fb1d917b8fd74fb82b495e667f/unitycatalog_client-0.2.1.tar.gz",
"platform": null,
"description": "# Unity Catalog Python Client SDK\n\nWelcome to the official Python Client SDK for Unity Catalog!\n\nUnity Catalog is the industry's only universal catalog for data and AI.\n\n- **Multimodal interface supports any format, engine, and asset**\n - Multi-format support: It is extensible and supports Delta Lake, Apache Iceberg and Apache Hudi via UniForm, Apache Parquet, JSON, CSV, and many others.\n - Multi-engine support: With its open APIs, data cataloged in Unity can be read by many leading compute engines.\n - Multimodal: It supports all your data and AI assets, including tables, files, functions, AI models.\n- **Open source API and implementation** - OpenAPI spec and OSS implementation (Apache 2.0 license). It is also compatible with Apache Hive's metastore API and Apache Iceberg's REST catalog API. Unity Catalog is currently a sandbox project with LF AI and Data Foundation (part of the Linux Foundation).\n- **Unified governance** for data and AI - Govern and secure tabular data, unstructured assets, and AI assets with a single interface.\n\n## Python Client SDK\n\nThe Unity Catalog Python SDK provides a convenient Python-native interface to all of the functionality of the Unity Catalog\nREST APIs. The library includes interfaces for all supported public modules.\n\nThis library is generated using the [OpenAPI Generator](https://openapi-generator.tech/docs/generators/python) toolkit, providing client interfaces using the `aiohttp` request handling library.\n\n## Installation\n\nThe Python Client SDK and associated shared namespace package for Unity Catalog use [hatch](https://hatch.pypa.io/latest/) as their supported build backend.\n\nTo ensure that you can install the package, install `hatch` via any of the listed options [here](https://hatch.pypa.io/latest/install/).\n\nTo use the `unitycatalog-client` SDK, you can install directly from PyPI:\n\n```sh\npip install unitycatalog-client\n```\n\nTo install from source, you will need to fork and clone the [unitycatalog repository](https://github.com/unitycatalog/unitycatalog) locally.\n\nTo build the Python source locally, you will need to have `JDK17` installed and activated.\n\nOnce your configuration supports the execution of [sbt](https://www.scala-sbt.org/), you can run the following within the root\nof the repository to generate the Python Client SDK source:\n\n```sh\nbuild/sbt pythonClient/generate\n```\n\nThe source code will be generated at `unitycatalog/clients/python/target`. \n\nYou can then install the package in editable mode from the repository root:\n\n```sh\npip install -e clients/python/target\n```\n\n## Usage\n\nTo get started with using the Python Client SDK, first ensure that you have a running Unity Catalog server to connect to.\nYou can follow instructions [here](https://docs.unitycatalog.io/quickstart/) to quickly get started with setting up\na local Unity Catalog server if needed.\n\nOnce the server is running, you can set up the Python client to make async requests to the Unity Catalog server.\n\nFor the examples listed here, we will be using a local unauthenticated server for simplicity's sake.\n\n```python\nfrom unitycatalog.client import Configuration\n\n\nconfig = Configuration()\nconfig.host = \"http://localhost:8080/api/2.1/unity-catalog\"\n```\n\nOnce we have our configuration, we can set our client that we will be using for each request:\n\n```python\nfrom unitycatalog.client import ApiClient\n\n\nclient = ApiClient(configuration=config)\n```\n\nWith our client configured and instantiated, we can use any of the Unity Catalog APIs by importing from the\n`client` namespace directly and send requests to the server.\n\n```python\nfrom unitycatalog.client import CatalogsApi\n\n\ncatalogs_api = CatalogsApi(api_client=client)\nmy_catalogs = await catalogs_api.list_catalogs()\n```\n\n>Note: APIs that support pagination (such as `list_catalogs`) should have continutation token logic for assembling the paginated\nreturn values into a single collection.\n\nA simple example of consuming a paginated response is:\n\n```python\nasync def list_all_catalogs(catalog_api):\n token = None\n catalogs = []\n while True:\n results = await catalog_api.list_catalogs(page_token=token)\n catalogs += results.catalogs\n if next_token := results.next_page_token:\n token = next_token\n else:\n break\n return catalogs\n\nmy_catalogs = await list_all_catalogs(catalogs_api)\n```\n\nCreating a new catalog with the Python SDK is straight-forward:\n\n```python\nfrom unitycatalog.client.models import CreateCatalog, CatalogInfo\n\n\nasync def create_catalog(catalog_name, catalog_api, comment=None):\n new_catalog = CreateCatalog(\n name=catalog_name,\n comment=comment or \"\"\n )\n return await catalog_api.create_catalog(create_catalog=new_catalog)\n\nawait create_catalog(\"MyNewCatalog\", catalog_api=catalogs_api, comment=\"This is a new catalog.\")\n```\n\nAdding a new Schema to our created Catalog is similarly simple:\n\n```python\nfrom unitycatalog.client import SchemasApi\nfrom unitycatalog.client import CreateSchema, SchemaInfo\n\n\nschemas_api = SchemasApi(api_client=client)\n\nasync def create_schema(schema_name, catalog_name, schema_api, comment=None):\n new_schema = CreateSchema(\n name=schema_name,\n catalog_name=catalog_name,\n comment=comment or \"\"\n )\n return await schema_api.create_schema(create_schema=new_schema)\n\nawait create_schema(schema_name=\"MyNewSchema\", catalog_name=\"MyNewCatalog\", schema_api=schemas_api, comment=\"This is a new schema.\")\n```\n\nAnd listing the schemas within our newly created Catalog (note that if you expect paginated responses, ensure that you are passing\ncontinuation tokens as shown above in `list_all_catalogs`):\n\n```python\nawait schemas_api.list_schemas(catalog_name=\"MyNewCatalog\")\n```\n\n## Feedback\n\nHave requests for the Unity Catalog project? Interested in getting involved in the Open Source project?\n\nSee the [repository on GitHub](https://github.com/unitycatalog/unitycatalog)\n\nRead [the documentation](https://www.unitycatalog.io/) for more guidance and examples!",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Official Python SDK for Unity Catalog",
"version": "0.2.1",
"project_urls": {
"homepage": "https://www.unitycatalog.io/",
"issues": "https://github.com/unitycatalog/unitycatalog/issues",
"repository": "https://github.com/unitycatalog/unitycatalog"
},
"split_keywords": [
"sdk",
" unitycatalog"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9f6a3f1a8380134281bb31a0b8fa662da262d42dee984f78f5864b3ab5590cc3",
"md5": "97e782a85f6df7b65f60fcffde9fe0c2",
"sha256": "096e241c1597522c0a8d12f268942bd7ea85a1e5cafd17cc54dca00c42012cd7"
},
"downloads": -1,
"filename": "unitycatalog_client-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "97e782a85f6df7b65f60fcffde9fe0c2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 131784,
"upload_time": "2024-12-04T17:56:15",
"upload_time_iso_8601": "2024-12-04T17:56:15.983786Z",
"url": "https://files.pythonhosted.org/packages/9f/6a/3f1a8380134281bb31a0b8fa662da262d42dee984f78f5864b3ab5590cc3/unitycatalog_client-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "abfcb479fd3a932301745da7ed39aa25105e74fb1d917b8fd74fb82b495e667f",
"md5": "87eb72768531594943eaa4caa847bf91",
"sha256": "4d4ccbf20e94d282627234c7ae6ffba2d401dad2e821edc3a14d950a075aefe7"
},
"downloads": -1,
"filename": "unitycatalog_client-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "87eb72768531594943eaa4caa847bf91",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 50960,
"upload_time": "2024-12-04T17:56:17",
"upload_time_iso_8601": "2024-12-04T17:56:17.114107Z",
"url": "https://files.pythonhosted.org/packages/ab/fc/b479fd3a932301745da7ed39aa25105e74fb1d917b8fd74fb82b495e667f/unitycatalog_client-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-04 17:56:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "unitycatalog",
"github_project": "unitycatalog",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "unitycatalog-client"
}