Model Hub

class pinecone.hub.HubFunction(image: str, config: dict = None, **kwargs)

A special Pinecone Function that loads models from the Model Hub.

  • image (str) – a Pinecone Model Hub docker image URI

  • config (dict, optional) – configurations for the model, defaults to None

async handle_msg(msg: core_pb2.Request, timeout: float = 30) → core_pb2.Request

Handles requests.

class pinecone.hub.ImageBuilder(image: str, build_path: pathlib.Path, model_path: pathlib.Path, pip: List[str] = None, data_paths: List[pathlib.Path] = None)

A helper class for building Pinecone Hub models.

  • image – name of the docker image in the form REPOSITORY:TAG

  • build_path – path to which artifacts will be saved for building the docker image.

  • model_path – path to the main model file. The model file is where Pinecone loads the inference APIs.

  • data_paths – paths to ancillary data, such as serialized Tensorflow models. These files will be copied to the docker build path.

  • pip – additional Python packages to be installed. In the base docker image, only numpy is preloaded. It is recommended that you use exact versions.

get_build_cmd() → str

Returns the docker build command.

get_push_cmd() → str

Returns command to push to docker hub.


Creates artifacts for building a Pinecone-compatible docker image.

The following will be created:

  • The build directory build_path where the artifacts reside in preparation for running docker build.

  • The main model file will be copied from model_path to the docker build path.

  • Ancillary data files and directories specified in data_paths will be copied to the docker build path.

  • A Dockerfile template for building the docker image will be created in the docker build path.


exist_ok (bool, optional) – same as pathlib.Path.mkdir, defaults to False.

property repository
property tag
class pinecone.hub.ImageServer(image: str, image_type: str)

Creates a local server for testing a HubFunction.

  • image (str) – name of the docker image

  • image_type (str) – one of {“preprocessor”, “postprocessor”}

class pinecone.hub.QueryResult(ids, scores, data)

Create new instance of QueryResult(ids, scores, data)

property data

Alias for field number 2

property ids

Alias for field number 0

property scores

Alias for field number 1


Returns the complete repository image URI.


Returns the image name prepended with the user name.


Creates or unarchives a repository.


Archives a repository.

pinecone.hub.get_login_cmd() → str

Returns CLI command for logging into Pinecone hub.


Shows all repositories.


Lists tags of a repository.


Decorator for wrapping a class as a Postporcessor.


from pinecone.hub improt postprocessor

class MyPostprocessor:
    def transform(self, queries: np.ndarray, matches: Iterable[QueryResult]) -> Iterable[QueryResult]:
        return results

Decorator for wrapping a class as a Preprocessor.


from pinecone.hub import preprocessor

class MyPreprocessor:
    def transform(self, vectors: np.ndarray) -> np.ndarray:
        return vectors