kfp.registry

The kfp.registry module contains objects for communicating with registry client hosts.

Classes:

RegistryClient(host[, auth, config_file, ...])

Class for communicating with registry hosts.

ApiAuth(token)

Class for registry authentication using an API token.

class kfp.registry.RegistryClient(host: str | None, auth: AuthBase | Credentials | None = None, config_file: str | None = None, auth_file: str | None = None)[source]

Bases: object

Class for communicating with registry hosts.

Parameters
host: str | None

The address of the registry host. The host needs to be specified here or in the config file.

auth: AuthBase | Credentials | None = None

Authentication using requests.auth.AuthBase or google.auth.credentials.Credentials.

config_file: str | None = None

The location of the local config file. If not specified, defaults to '~/.config/kfp/context.json' (if it exists).

auth_file: str | None = None

The location of the local config file that contains the authentication token. If not specified, defaults to '~/.config/kfp/registry_credentials.json' (if it exists).

Methods:

upload_pipeline(file_name[, tags, extra_headers])

Uploads the pipeline.

download_pipeline(package_name[, version, ...])

Downloads a pipeline.

get_package(package_name)

Gets package metadata.

list_packages()

Lists packages.

delete_package(package_name)

Deletes a package.

get_version(package_name, version)

Gets package version metadata.

list_versions(package_name)

Lists package versions.

delete_version(package_name, version)

Deletes package version.

create_tag(package_name, version, tag)

Creates a tag on a package version.

get_tag(package_name, tag)

Gets tag metadata.

update_tag(package_name, version, tag)

Updates a tag to another package version.

list_tags(package_name)

Lists package tags.

delete_tag(package_name, tag)

Deletes package tag.

upload_pipeline(file_name: str, tags: str | list[str] | None = None, extra_headers: dict | None = None) tuple[str, str][source]

Uploads the pipeline.

Parameters
file_name: str

The name of the file to be uploaded.

tags: str | list[str] | None = None

Tags to be attached to the uploaded pipeline.

extra_headers: dict | None = None

Any extra headers required.

Returns

A tuple of the package name and the version.

download_pipeline(package_name: str, version: str | None = None, tag: str | None = None, file_name: str | None = None) str[source]

Downloads a pipeline. Either version or tag must be specified.

Parameters
package_name: str

Name of the package.

version: str | None = None

Version of the package.

tag: str | None = None

Tag attached to the package.

file_name: str | None = None

File name to be saved as. If not specified, the file name will be based on the package name and version/tag.

Returns

The file name of the downloaded pipeline.

get_package(package_name: str) dict[str, Any][source]

Gets package metadata.

Parameters
package_name: str

Name of the package.

Returns

The package metadata.

list_packages() list[dict][source]

Lists packages.

Returns

List of packages in the repository.

delete_package(package_name: str) bool[source]

Deletes a package.

Parameters
package_name: str

Name of the package.

Returns

Whether the package was deleted successfully.

get_version(package_name: str, version: str) dict[str, Any][source]

Gets package version metadata.

Parameters
package_name: str

Name of the package.

version: str

Version of the package.

Returns

The version metadata.

list_versions(package_name: str) list[dict][source]

Lists package versions.

Parameters
package_name: str

Name of the package.

Returns

List of package versions.

delete_version(package_name: str, version: str) bool[source]

Deletes package version.

Parameters
package_name: str

Name of the package.

version: str

Version of the package.

Returns

Whether the version was deleted successfully.

create_tag(package_name: str, version: str, tag: str) dict[str, Any][source]

Creates a tag on a package version.

Parameters
package_name: str

Name of the package.

version: str

Version of the package.

tag: str

Tag to be attached to the package version.

Returns

Metadata for the created tag.

get_tag(package_name: str, tag: str) dict[str, Any][source]

Gets tag metadata.

Parameters
package_name: str

Name of the package.

tag: str

Tag attached to the package version.

Returns

The metadata for the tag.

update_tag(package_name: str, version: str, tag: str) dict[str, Any][source]

Updates a tag to another package version.

Parameters
package_name: str

Name of the package.

version: str

Version of the package.

tag: str

Tag to be attached to the new package version.

Returns

The metadata for the updated tag.

list_tags(package_name: str) list[dict][source]

Lists package tags.

Parameters
package_name: str

Name of the package.

Returns

List of tags.

delete_tag(package_name: str, tag: str) dict[str, Any][source]

Deletes package tag.

Parameters
package_name: str

Name of the package.

tag: str

Tag to be deleted.

Returns

Response from the delete request.

class kfp.registry.ApiAuth(token: str)[source]

Bases: AuthBase

Class for registry authentication using an API token.

Parameters
token: str

The API token.

Example

client = RegistryClient(
    host='https://us-central1-kfp.pkg.dev/proj/repo', auth=ApiAuth('my_token'))