Metadata-Version: 2.4
Name: apache-gravitino
Version: 2.0.0rc1
Summary: Python lib/client for Apache Gravitino
Home-page: https://github.com/apache/gravitino
Author: Apache Software Foundation
Author-email: dev@gravitino.apache.org
Maintainer: Apache Gravitino Community
Maintainer-email: dev@gravitino.apache.org
License: Apache-2.0
Project-URL: Homepage, https://gravitino.apache.org/
Project-URL: Source Code, https://github.com/apache/gravitino
Project-URL: Documentation, https://gravitino.apache.org/docs/overview
Project-URL: Bug Tracker, https://github.com/apache/gravitino/issues
Project-URL: Slack Chat, https://the-asf.slack.com/archives/C078RESTT19
Keywords: Data,AI,metadata,catalog
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: dataclasses-json<0.7,>=0.6.7
Requires-Dist: simplejson<5,>=3.20.1
Provides-Extra: dev
Requires-Dist: requests==2.32.5; extra == "dev"
Requires-Dist: packaging==26.3; extra == "dev"
Requires-Dist: dataclasses-json==0.6.7; extra == "dev"
Requires-Dist: simplejson==3.20.1; extra == "dev"
Requires-Dist: pylint==4.0.5; extra == "dev"
Requires-Dist: black==26.3.1; extra == "dev"
Requires-Dist: flake8==7.0.0; extra == "dev"
Requires-Dist: pre-commit==3.5.0; extra == "dev"
Requires-Dist: twine==6.2.0; extra == "dev"
Requires-Dist: coverage==7.14.3; extra == "dev"
Requires-Dist: pandas==2.3.3; extra == "dev"
Requires-Dist: pyarrow==23.0.1; extra == "dev"
Requires-Dist: fsspec==2026.2.0; extra == "dev"
Requires-Dist: gcsfs==2026.2.0; extra == "dev"
Requires-Dist: s3fs==2026.2.0; extra == "dev"
Requires-Dist: ossfs==2025.5.0; extra == "dev"
Requires-Dist: adlfs==2026.2.0; extra == "dev"
Requires-Dist: llama-index==0.13.0; extra == "dev"
Requires-Dist: tenacity==9.1.4; extra == "dev"
Requires-Dist: cachetools==7.1.4; extra == "dev"
Requires-Dist: readerwriterlock==1.0.9; extra == "dev"
Requires-Dist: docker==7.1.0; extra == "dev"
Requires-Dist: pyjwt[crypto]==2.13.0; extra == "dev"
Requires-Dist: jwcrypto==1.5.6; extra == "dev"
Requires-Dist: sphinx==7.1.2; extra == "dev"
Requires-Dist: furo==2024.8.6; extra == "dev"
Requires-Dist: banks==2.4.5; extra == "dev"
Requires-Dist: ray==2.55.1; extra == "dev"
Requires-Dist: lance-ray==0.4.2; extra == "dev"
Requires-Dist: lance-namespace==0.7.5; extra == "dev"
Provides-Extra: lance
Requires-Dist: ray>=2.55.1; extra == "lance"
Requires-Dist: lance-ray<1,>=0.3.0; extra == "lance"
Provides-Extra: gvfs
Requires-Dist: cachetools<8,>=7.1.4; extra == "gvfs"
Requires-Dist: fsspec>=2023.12.1; extra == "gvfs"
Requires-Dist: readerwriterlock<2,>=1.0.9; extra == "gvfs"
Provides-Extra: hdfs
Requires-Dist: cachetools<8,>=7.1.4; extra == "hdfs"
Requires-Dist: fsspec>=2023.12.1; extra == "hdfs"
Requires-Dist: readerwriterlock<2,>=1.0.9; extra == "hdfs"
Requires-Dist: pyarrow<27,>=17.0.0; extra == "hdfs"
Provides-Extra: s3
Requires-Dist: cachetools<8,>=7.1.4; extra == "s3"
Requires-Dist: fsspec>=2023.12.1; extra == "s3"
Requires-Dist: readerwriterlock<2,>=1.0.9; extra == "s3"
Requires-Dist: s3fs>=2023.12.1; extra == "s3"
Provides-Extra: gcs
Requires-Dist: cachetools<8,>=7.1.4; extra == "gcs"
Requires-Dist: fsspec>=2023.12.1; extra == "gcs"
Requires-Dist: readerwriterlock<2,>=1.0.9; extra == "gcs"
Requires-Dist: gcsfs>=2023.12.1; extra == "gcs"
Provides-Extra: oss
Requires-Dist: cachetools<8,>=7.1.4; extra == "oss"
Requires-Dist: fsspec>=2023.12.1; extra == "oss"
Requires-Dist: readerwriterlock<2,>=1.0.9; extra == "oss"
Requires-Dist: ossfs>=2025.5.0; extra == "oss"
Provides-Extra: azure
Requires-Dist: cachetools<8,>=7.1.4; extra == "azure"
Requires-Dist: fsspec>=2023.12.1; extra == "azure"
Requires-Dist: readerwriterlock<2,>=1.0.9; extra == "azure"
Requires-Dist: adlfs>=2026.2.0; extra == "azure"
Provides-Extra: storage
Requires-Dist: cachetools<8,>=7.1.4; extra == "storage"
Requires-Dist: fsspec>=2023.12.1; extra == "storage"
Requires-Dist: readerwriterlock<2,>=1.0.9; extra == "storage"
Requires-Dist: pyarrow<27,>=17.0.0; extra == "storage"
Requires-Dist: s3fs>=2023.12.1; extra == "storage"
Requires-Dist: gcsfs>=2023.12.1; extra == "storage"
Requires-Dist: ossfs>=2025.5.0; extra == "storage"
Requires-Dist: adlfs>=2026.2.0; extra == "storage"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: maintainer
Dynamic: maintainer-email
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

## Introduction

Apache Gravitino is a high-performance, geo-distributed, and federated metadata lake.
It manages the metadata directly in different sources, types, and regions, also provides users
the unified metadata access for data and AI assets.

Gravitino Python client helps data scientists easily manage metadata using Python language.

![gravitino-python-client-introduction](https://github.com/apache/gravitino/blob/main/docs/assets/gravitino-python-client-introduction.png?raw=true)

## Usage

Use Gravitino Python client library with Spark, PyTorch, Tensorflow, Ray and Python environment.

First of all, You must have a Gravitino server set up and run, You can refer document of
[How to install Gravitino](https://gravitino.apache.org/docs/latest/how-to-install/) to build Gravitino server from source code and
install it in your local.

### Python Client API

```shell
pip install apache-gravitino
```

The base installation provides the Gravitino metadata client. For GVFS with local `file://` paths
and no remote backend, install only the shared GVFS dependencies:

```shell
pip install "apache-gravitino[gvfs]"
```

For a remote storage backend, install its extra, for example:

```shell
pip install "apache-gravitino[hdfs]"
pip install "apache-gravitino[s3]"
pip install "apache-gravitino[gcs]"
pip install "apache-gravitino[oss]"
pip install "apache-gravitino[azure]"
```

To preserve the previous installation profile that included all GVFS backends, install
`apache-gravitino[storage]`. Ray Data applications that only use Gravitino for metadata can install
the base Gravitino client alongside their Ray Data dependencies without installing these storage
extras.

1. [Manage metalake using Gravitino Python API](https://gravitino.apache.org/docs/latest/manage-metalake-using-gravitino/?language=python)
2. [Manage fileset metadata using Gravitino Python API](https://gravitino.apache.org/docs/latest/manage-fileset-metadata-using-gravitino/?language=python)
3. [Manage Semantic Model metadata using Gravitino Python API](https://gravitino.apache.org/docs/latest/manage-semantic-model-metadata-using-gravitino/?language=python)
4. [Manage view metadata using Gravitino Python API](https://gravitino.apache.org/docs/latest/manage-view-metadata-using-gravitino/?language=python)

### View Operations

Use `as_view_catalog()` on a loaded relational catalog to manage views. The
[View guide](https://gravitino.apache.org/docs/latest/manage-view-metadata-using-gravitino/?language=python) includes Python examples for view
creation, list/load, alteration (rename, set/remove property, and replace), and drop operations.

### HTTP Error Handling

Valid Gravitino and OAuth2 error responses retain their existing domain exceptions.
When an HTTP error has an empty, unreadable or invalid error response, the client raises
`gravitino.exceptions.base.HTTPResponseException`, a subclass of `RESTException`.
Its `status_code`, `request_method` and `endpoint` attributes describe the HTTP status,
the original client request method and its origin (scheme, hostname and optional port).
Applications can catch `RESTException` to include these fallback failures.

Fallback diagnostics omit URL credentials, paths, query parameters, fragments, request data,
response headers and response bodies. The default traceback suppresses the underlying
HTTP and decoding exception chain. Existing domain error messages are unchanged.
This replaces the decoding or validation exceptions previously exposed for invalid HTTP
error responses, and bypasses custom error handlers for empty or invalid error responses.
Connection failures and timeouts before an HTTP error response retain their existing behavior.
The client does not retry requests as part of this error handling.

### Runtime dependency ranges

The metadata client and optional storage or Lance integrations use these runtime
requirements. Development and standard integration-test dependencies are pinned separately.

| Installation | Runtime requirements |
| --- | --- |
| Core | `dataclasses-json>=0.6.7,<0.7`, `simplejson>=3.20.1,<5` |
| GVFS shared | `cachetools>=7.1.4,<8`, `fsspec>=2023.12.1`, `readerwriterlock>=1.0.9,<2` |
| HDFS | `pyarrow>=17.0.0,<27` |
| S3 | `s3fs>=2023.12.1` |
| GCS | `gcsfs>=2023.12.1` |
| OSS | `ossfs>=2025.5.0` |
| Azure | `adlfs>=2026.2.0` |
| Lance | `ray>=2.55.1`, `lance-ray>=0.3.0,<1` |

Backend libraries also constrain their dependencies. For example, s3fs and gcsfs
2023.12.1 both require fsspec 2023.12.1. The installer selects a compatible combination
when multiple extras or `[storage]` are requested. The storage profile does not include
`[lance]`; request both extras when both features are needed.

Python package compatibility also applies. For example, PyArrow 26 requires Python 3.11
or later. The allowed ranges do not imply that every version combination has been tested.

### Semantic Model Ossie Import and Export

Use `as_semantic_model_catalog()` on a loaded relational catalog to manage Semantic Models.
The [Semantic Model guide](https://gravitino.apache.org/docs/latest/manage-semantic-model-metadata-using-gravitino/?language=python)
includes Python examples for native creation, list/load, alteration, deletion, and Apache Ossie
YAML/JSON import and export, along with the source and permission requirements.

The SDK transfers Ossie document text directly and requires no YAML parser. Import and export
default to `document_format="yaml"`; use `"json"` for JSON documents.

### Fileset Example

We offer a playground environment to help you quickly understand how to use Gravitino Python
client to manage non-tabular data on HDFS via Fileset in Gravitino. You can refer to the
document [How to use the playground](https://gravitino.apache.org/docs/latest/how-to-use-the-playground/)
to launch a Gravitino server, HDFS and Jupyter notebook environment in you local Docker environment.

Waiting for the playground Docker environment to start, you can directly open
`http://localhost:18888/lab/tree/gravitino-fileset-example.ipynb` in the browser and run the example.

The [gravitino-fileset-example](https://github.com/apache/gravitino-playground/blob/main/init/jupyter/gravitino-fileset-example.ipynb)
contains the following code snippets:

1. Install HDFS Python client.
2. Create a HDFS client to connect HDFS and to do some test operations.
3. Install the Gravitino Python client with HDFS support: `pip install "apache-gravitino[hdfs]"`.
4. Initialize Gravitino admin client and create a Gravitino metalake.
5. Initialize Gravitino client and list metalakes.
6. Create a Gravitino `Catalog` and special `type` is `Catalog.Type.FILESET` and `provider` is
   [fileset](https://gravitino.apache.org/docs/latest/fileset-catalog/)
7. Create a Gravitino `Schema` with the `location` pointed to a HDFS path, and use `hdfs client` to
   check if the schema location is successfully created in HDFS.
8. Create a `Fileset` with `type` is [Fileset.Type.MANAGED](https://gravitino.apache.org/docs/latest/manage-fileset-metadata-using-gravitino/#fileset-operations),
   use `hdfs client` to check if the fileset location was successfully created in HDFS.
9. Drop this `Fileset.Type.MANAGED` type fileset and check if the fileset location was
   successfully deleted in HDFS.
10. Create a `Fileset` with `type` is [Fileset.Type.EXTERNAL](https://gravitino.apache.org/docs/latest/manage-fileset-metadata-using-gravitino/#fileset-operations)
    and `location` pointed to exist HDFS path
11. Drop this `Fileset.Type.EXTERNAL` type fileset and check if the fileset location was
    not deleted in HDFS.

## Python Client Development

Use any IDE to develop Gravitino Python Client. Directly open the client-python module project in the IDE.

### Prerequisites

+ Python 3.10+
+ Refer to [How to build Gravitino](https://gravitino.apache.org/docs/latest/how-to-build/#prerequisites) to have necessary build
  environment ready for building.

### Develop with uv

The Python client also provides an optional [uv](https://docs.astral.sh/uv/) development
workflow. The existing Gradle build, CI, and release commands continue to use their existing
environment setup.

Install uv, then run the following commands from `clients/client-python`:

```shell
uv sync --locked --extra dev --python 3.12
uv run --locked --extra dev python scripts/generate_version.py
uv run --locked --extra dev black --check gravitino tests scripts
uv run --locked --extra dev pylint gravitino tests scripts
PYTHONPATH="$PWD" uv run --locked --extra dev --directory tests/unittests python -m unittest
```

The version-generation command is required after a fresh checkout. Configure your IDE to use
`clients/client-python/.venv/bin/python` (or `.venv/Scripts/python.exe` on Windows).
For another supported Python version, select it with `--python`. Use a separate environment
when switching between Python versions or dependency combinations.
The unit-test command sets `PYTHONPATH` to make the existing shared test helpers importable,
as the Gradle test task does.

`setup.py` and the existing `requirements*.txt` files continue to declare package metadata
and dependencies. `uv.lock` records the resolved development environment; SDK users can
continue installing the published package with pip. After changing a requirement file,
run `uv lock`, review the lockfile changes, and verify `uv lock --check`. Use
`uv sync --locked --all-extras` to install all existing optional extras in the
development environment.

For an independent lock, metadata-equivalence and cache-invalidation check, run:

```shell
uv run --locked python scripts/check_uv_workflow.py
```

This lightweight check needs only the core client and the default setuptools development
tool. It changes README and requirements only in temporary source copies, reuses the uv
cache, and exits nonzero on failure. The uv commands above do not run integration tests;
use the existing Gradle commands below with their server or storage prerequisites.

### Build and Test

1. Clone the Gravitino project.

    ```shell
    git clone git@github.com:apache/gravitino.git
    ```

2. Build the Gravitino Python client module

    ```shell
    # Default Python version is 3.12
    ./gradlew :clients:client-python:build
    # If you want to build Python client with specific Python version,
    # add `-PpythonVersion` with version number:
    ./gradlew :clients:client-python:build -PpythonVersion=3.11
    ```
 
3. Run unit tests

    ```shell
    ./gradlew :clients:client-python:test -PskipITs
    ```

4. Run integration tests

   Because Python client connects to Gravitino Server to run integration tests,
   So it runs `./gradlew compileDistribution -x test` command automatically to compile the
   Gravitino project in the `distribution` directory. When you run integration tests via Gradle
   command or IDE, Gravitino integration test framework (`integration_test_env.py`)
   will start and stop Gravitino server automatically.

    ```shell
    ./gradlew :clients:client-python:test
    ```

5. Distribute the Gravitino Python client module

    ```shell
    ./gradlew :clients:client-python:distribution
    ```

6. Deploy the Gravitino Python client to https://pypi.org/project/apache-gravitino/

    ```shell
    ./gradlew :clients:client-python:deploy
    ```
   
### IDE Specific Settings

#### JetBrains IntelliJ IDEA

We use Conda Environment to manage Python Environment, to configure Python
SDK, you need to:

1. Make sure you installed [Python Plugin](https://plugins.jetbrains.com/plugin/631-python).
2. Make sure you followed the step to build python module in [Build and Test](#build-and-test)
3. Make sure you are at the root directory of Gravitino Git repository. 
4. Find conda executable by executing this command

   ```shell
   find $(pwd)/.gradle/python/*/Miniforge3/bin/conda
   
   # example output
   /Users/YOUR_USER_NAME/gravitino/.gradle/python/MacOSX/Miniforge3/bin/conda
   ```

5. Find Python Interpreter with this command:

   ```shell
   find $(pwd)/.gradle/python/*/Miniforge3/envs/*/bin/python
   
   # example output
   /Users/YOUR_USER_NAME/gravitino/.gradle/python/MacOSX/Miniforge3/envs/python-3.12/bin/python
   ```

6. Follow steps in [Create a conda environment](https://www.jetbrains.com/help/idea/configuring-python-sdk.html#gdizlj_44), 
and at step 5, choose [Existing conda environment](https://www.jetbrains.com/help/idea/configuring-python-sdk.html#existing-conda-environment)

7. Fill in the output from step 4 into *Conda executable* field, step 5 into *Interpreter* field.
![Configure conda_env](https://github.com/apache/gravitino/blob/main/docs/assets/configure-conda-env.png?raw=true)
And you will see a new Python SDK is added, and it has several packages installed.
![Add Platform SDK](https://github.com/apache/gravitino/blob/main/docs/assets/add-platform-sdk.png?raw=true)

8. Set `clients/client-python` module sdk to the one we set in previous step.
![Configure python module sdk](https://github.com/apache/gravitino/blob/main/docs/assets/configure-python-module-sdk.png?raw=true)

9. Done! Now, open any python files and start developing Gravitino Python Client.

##### Running Integration Tests in IntelliJ IDEA

Since integration tests require Gravitino Java distribution, so you cannot run tests with IntelliJ
[Run tests button](https://www.jetbrains.com/help/idea/performing-tests.html),
Please execute this gradle task with [Gradle Plugin](https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin.html)
or in command line to run integration tests.

```shell
./gradlew clients:client-python:integrationTest
```

Or, you would see errors like:

```shell
...
ERROR:tests.integration.integration_test_env:Gravitino Python client integration test must configure `GRAVITINO_HOME`

Process finished with exit code 0
```

## Resources

+ Official website https://gravitino.apache.org/
+ Project home on GitHub: https://github.com/apache/gravitino/
+ Playground with Docker: https://github.com/apache/gravitino-playground
+ User documentation: https://gravitino.apache.org/docs/
+ Slack Community: [https://the-asf.slack.com#gravitino](https://the-asf.slack.com/archives/C078RESTT19)

## Domains

See [Manage domains](https://gravitino.apache.org/docs/latest/manage-domains-in-gravitino/) for a complete executable example
covering creation, publication, tag membership, reverse lookup and cleanup.

## License

Gravitino is under the Apache License Version 2.0, See the [LICENSE](https://github.com/apache/gravitino/blob/main/LICENSE) for the details.
