kfp.registry

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

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

Bases: AuthBase

Class for registry authentication using an API token.

Parameters

token – The API token.

Example

client = RegistryClient(
    host='https://us-central1-kfp.pkg.dev/proj/repo', auth=ApiAuth('my_token'))
class kfp.registry.RegistryClient(host: Optional[str], auth: Optional[Union[AuthBase, Credentials]] = None, config_file: Optional[str] = None, auth_file: Optional[str] = None)[source]

Bases: object

Class for communicating with registry hosts.

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

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

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

  • auth_file – 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).

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

Creates a tag on a package version.

Parameters
  • package_name – Name of the package.

  • version – Version of the package.

  • tag – Tag to be attached to the package version.

Returns

Metadata for the created tag.

delete_package(package_name: str) bool[source]

Deletes a package.

Parameters

package_name – Name of the package.

Returns

Whether the package was deleted successfully.

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

Deletes package tag.

Parameters
  • package_name – Name of the package.

  • tag – Tag to be deleted.

Returns

Response from the delete request.

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

Deletes package version.

Parameters
  • package_name – Name of the package.

  • version – Version of the package.

Returns

Whether the version was deleted successfully.

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

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

Parameters
  • package_name – Name of the package.

  • version – Version of the package.

  • tag – Tag attached to the package.

  • file_name – 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 – Name of the package.

Returns

The package metadata.

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

Gets tag metadata.

Parameters
  • package_name – Name of the package.

  • tag – Tag attached to the package version.

Returns

The metadata for the tag.

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

Gets package version metadata.

Parameters
  • package_name – Name of the package.

  • version – Version of the package.

Returns

The version metadata.

list_packages() List[dict][source]

Lists packages.

Returns

List of packages in the repository.

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

Lists package tags.

Parameters

package_name – Name of the package.

Returns

List of tags.

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

Lists package versions.

Parameters

package_name – Name of the package.

Returns

List of package versions.

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

Updates a tag to another package version.

Parameters
  • package_name – Name of the package.

  • version – Version of the package.

  • tag – Tag to be attached to the new package version.

Returns

The metadata for the updated tag.

upload_pipeline(file_name: str, tags: Optional[Union[str, List[str]]] = None, extra_headers: Optional[dict] = None) Tuple[str, str][source]

Uploads the pipeline.

Parameters
  • file_name – The name of the file to be uploaded.

  • tags – Tags to be attached to the uploaded pipeline.

  • extra_headers – Any extra headers required.

Returns

A tuple of the package name and the version.