gravitino.client.gravitino_client.GravitinoClient

class gravitino.client.gravitino_client.GravitinoClient(uri: str, metalake_name: str, check_version: bool = True, auth_data_provider: AuthDataProvider | None = None, request_headers: dict | None = None, client_config: dict | None = None)

Bases: GravitinoClientBase, SupportsJobs

Gravitino Client for a user to interact with the Gravitino API, allowing the client to list, load, create, and alter Catalog.

It uses an underlying {@link RESTClient} to send HTTP requests and receive responses from the API.

__init__(uri: str, metalake_name: str, check_version: bool = True, auth_data_provider: AuthDataProvider | None = None, request_headers: dict | None = None, client_config: dict | None = None)

Constructs a new GravitinoClient with the given URI, authenticator and AuthDataProvider.

Args:

uri: The base URI for the Gravitino API. metalake_name: The specified metalake name. auth_data_provider: The provider of the data which is used for authentication. request_headers: The headers to be included in the HTTP requests. client_config: The config properties for the HTTP Client

Raises:

NoSuchMetalakeException if the metalake with specified name does not exist.

Methods

__init__(uri, metalake_name[, ...])

Constructs a new GravitinoClient with the given URI, authenticator and AuthDataProvider.

alter_catalog(name, *changes)

cancel_job(job_id)

Cancels a job by its ID.

check_metalake_name(metalake_name)

check_version()

Check the compatibility of the client with the target server.

close()

Closes the GravitinoClient and releases any underlying resources.

create_catalog(name, catalog_type, provider, ...)

delete_job_template(job_template_name)

Deletes a job template by its name.

disable_catalog(name)

drop_catalog(name[, force])

enable_catalog(name)

get_client_version()

Retrieves the version of the Gravitino Python Client.

get_job(job_id)

Retrieves a job by its ID.

get_job_template(job_template_name)

Retrieves a job template by its name.

get_metalake()

Get the current metalake object

get_server_version()

Retrieves the version of the Gravitino API.

list_catalogs()

list_catalogs_info()

list_job_templates()

Lists all job templates in the current metalake.

list_jobs([job_template_name])

Lists all the jobs in the current metalake.

load_catalog(name)

load_metalake(name)

Loads a specific Metalake from the Gravitino API.

register_job_template(job_template)

Register a job template with the specified job template to Gravitino.

run_job(job_template_name, job_conf)

Runs a job using the specified job template and configuration.

Attributes

API_METALAKES_IDENTIFIER_PATH

The REST API path prefix for load a specific metalake

API_METALAKES_LIST_PATH

The REST API path for listing metalakes

CLIENT_VERSION_HEADER

API_METALAKES_IDENTIFIER_PATH = 'api/metalakes/'

The REST API path prefix for load a specific metalake

API_METALAKES_LIST_PATH = 'api/metalakes'

The REST API path for listing metalakes

cancel_job(job_id: str) JobHandle

Cancels a job by its ID.

Args:

job_id: The ID of the job to cancel.

Returns:

The JobHandle object representing the cancelled job.

Raises:

NoSuchJobException: If no job with the specified ID exists.

check_version()

Check the compatibility of the client with the target server.

Raises:

GravitinoRuntimeException If the client version is greater than the server version.

close()

Closes the GravitinoClient and releases any underlying resources.

delete_job_template(job_template_name: str) bool

Deletes a job template by its name. This will remove the job template from Gravitino, and it will no longer be available for execution. Only when all the jobs associated with this job template are completed, failed or cancelled, the job template can be deleted successfully, otherwise it will throw InUseException. Returns false if the job template to be deleted does not exist.

The deletion of a job template will also delete all the jobs associated with this template.

Args:

job_template_name: The name of the job template to delete.

Returns:

bool: True if the job template was deleted successfully, False if the job template does not exist.

Raises:

InUseException: If there are still queued or started jobs associated with this job template.

get_client_version() GravitinoVersion

Retrieves the version of the Gravitino Python Client.

Returns:

A GravitinoVersion instance representing the version of the Gravitino Python Client.

get_job(job_id: str) JobHandle

Retrieves a job by its ID.

Args:

job_id: The ID of the job to retrieve.

Returns:

The JobHandle object corresponding to the specified job ID.

Raises:

NoSuchJobException: If no job with the specified ID exists.

get_job_template(job_template_name: str) JobTemplate

Retrieves a job template by its name.

Args:

job_template_name: The name of the job template to retrieve.

Returns:

The JobTemplate object corresponding to the specified name.

Raises:

NoSuchJobTemplateException: If no job template with the specified name exists.

get_metalake() GravitinoMetalake

Get the current metalake object

Raises:

NoSuchMetalakeException if the metalake with specified name does not exist.

Returns:

the GravitinoMetalake object

get_server_version() GravitinoVersion

Retrieves the version of the Gravitino API.

Returns:

A GravitinoVersion instance representing the version of the Gravitino API.

list_job_templates() List[JobTemplate]

Lists all job templates in the current metalake.

Returns:

A list of JobTemplate objects representing the job templates in the metalake.

list_jobs(job_template_name: str | None = None) List[JobHandle]

Lists all the jobs in the current metalake.

Args:

job_template_name: Optional; if provided, filters the jobs by the specified job template name.

Returns:

A list of JobHandle objects representing the jobs in the metalake.

load_metalake(name: str) GravitinoMetalake

Loads a specific Metalake from the Gravitino API.

Args:

name: The name of the Metalake to be loaded.

Returns:

A GravitinoMetalake instance representing the loaded Metalake.

Raises:

NoSuchMetalakeException If the specified Metalake does not exist.

register_job_template(job_template) None

Register a job template with the specified job template to Gravitino. The registered job template will be maintained in Gravitino, allowing it to be executed later.

Args:

job_template: The job template to register.

Raises:

JobTemplateAlreadyExists: If a job template with the same name already exists.

run_job(job_template_name: str, job_conf: Dict[str, str]) JobHandle

Runs a job using the specified job template and configuration.

Args:

job_template_name: The name of the job template to use for running the job. job_conf: A dictionary containing the configuration for the job.

Returns:

A JobHandle object representing the started job.

Raises:

NoSuchJobTemplateException: If no job template with the specified name exists.