Jupyter Notebook Utilities¶
deploy_model_version(name: str, model_id: int, runtime_version: str, artifacts_directory: Optional[str] = None, description: Optional[str] = None, metadata: Optional[Dict[str, str]] = None, notebook_path: Optional[str] = None, cognite_client: Optional[cognite.client.experimental.CogniteClient] = None) → int¶
Deploy the model version in the current notebook to the model hosting environment.
- name (str) – The name of the model version.
- model_id (int) – Id of the model to deploy the version to.
- runtime_version (str) – The model hosting runtime version to deploy the model to.
- artifacts_directory (str, optional) – Path of the directory containing any artifacts you want to include with your deployment.
- description (str, optional) – Description of this model version.
- metadata (Dict[str,str], optional) – Any metadata to include about this model verison.
- notebook_path (str, optional) – The path to the notebook. If omitted, the notebook you’re in will be used.
- cognite_client (CogniteClient, optional) – The CogniteClient instance to use for uploading the model. If omitted, a new instance will be created using the API key in the COGNITE_API_KEY environment variable.
The model version id
local_artifacts(model_version_name: str, root_dir: Optional[str] = None) → Callable¶
Local artifacts storage.
Returns a function which works like the builtin open(), but pointing to a directory specific to the provided model version name. The directory will be artifacts/<model_version_name>. By default the artifacts directory will reside in the current working directory.
- model_version_name (str) – The name of the model version which the artifacts belong to.
- root_dir (str, optional) – The root directory where the artifacts directory reside. Defaults to the current working directory.
- A function/context manager which works like the builtin open. Let’s your read and write to the
local artifacts directory.
open_artifact = local_artifacts('my-model') with open_artifact('my_file.txt', 'w') as f: f.write('A cool file\n') # will be stored in artifacts/my-model/my_file.txt
Raised if the current version of Jupyter Notebook is not supported by this integration.
Raised if there is a mistake in how you have defined your model within the notebook.
Raised if your cell defining requirements is not correctly formatted.