Model Hub¶
-
class
pinecone.hub.
HubFunction
(image: str, config: dict = None, **kwargs)¶ A special Pinecone Function that loads models from the Model Hub.
- Parameters
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.
- Parameters
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.
-
package
(exist_ok=False)¶ 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 runningdocker 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.
- Parameters
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.
- Parameters
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
-
property
-
pinecone.hub.
as_repo_image
(image)¶ Returns the complete repository image URI.
-
pinecone.hub.
as_user_image
(image)¶ Returns the image name prepended with the user name.
-
pinecone.hub.
create_repository
(name)¶ Creates or unarchives a repository.
-
pinecone.hub.
delete_repository
(name)¶ Archives a repository.
-
pinecone.hub.
get_login_cmd
() → str¶ Returns CLI command for logging into Pinecone hub.
-
pinecone.hub.
list_repositories
()¶ Shows all repositories.
Lists tags of a repository.
-
pinecone.hub.
postprocessor
(cls)¶ Decorator for wrapping a class as a Postporcessor.
Usage:
from pinecone.hub improt postprocessor @postprocessor class MyPostprocessor: def transform(self, queries: np.ndarray, matches: Iterable[QueryResult]) -> Iterable[QueryResult]: return results
-
pinecone.hub.
preprocessor
(cls)¶ Decorator for wrapping a class as a Preprocessor.
Usage:
from pinecone.hub import preprocessor @preprocessor class MyPreprocessor: def transform(self, vectors: np.ndarray) -> np.ndarray: return vectors