KonanSDK

class konan_sdk.sdk.KonanSDK(auth_url='https://auth.konan.ai', api_url='https://api.konan.ai', verbose=False)

Bases: object

konan-sdk’s main class for API integration.

__init__(auth_url='https://auth.konan.ai', api_url='https://api.konan.ai', verbose=False)
login(email: Optional[str] = None, password: Optional[str] = None, api_key: Optional[str] = None) None

Login to Konan with _either_ email + password credentails _or_ an API Key.

At least one of the two authentication methods must be passed. If both methods are passed, API Key authentication is used.

Parameters
  • email (str, optional) – email of registered user, defaults to None

  • password (str, optional) – password of registered user, defaults to None

  • api_key (str, optional) – API Key of registered user, defaults to None

create_deployment(name: str, docker_credentials: Optional[KonanDockerCredentials], docker_image: KonanDockerImage, model_name: Optional[str] = None) KonanDeploymentCreationResponse

Call the create deployment function

Parameters
  • name (str) – name of the deployment to create

  • docker_credentials (Optional[KonanDockerCredentials]) – credentials for the docker registry to use

  • docker_image (KonanDockerImage) – docker image information

  • model_name – name of the live model to create, defaults to None

If left as None, will default to the name of the deployment :type model_name: str, optional :return: konan_deployment_creation_response :rtype: KonanDeploymentCreationResponse

create_model(deployment_uuid: str, name: str, docker_credentials: Optional[KonanDockerCredentials], docker_image: KonanDockerImage, model_state: KonanModelState = KonanModelState.Challenger) KonanModel

Call the create model function

Parameters
  • deployment_uuid (str) – uuid of the deployment to create the model in

  • name (str) – name of the model to create

  • docker_credentials (Optional[KonanDockerCredentials]) – credentials for the docker registry to use

  • docker_image (KonanDockerImage) – docker image information

  • model_state (KonanModelState, optional) – state in which to create the Model, defaults to KonanModelState.Challenger

Returns

konan_model

Return type

KonanModel

get_models(deployment_uuid: str) List[KonanModel]

Call the get models function

Parameters

deployment_uuid (str) – uuid of the deployment to get its models

Returns

konan_models

Return type

List[KonanModel]

switch_model_state(deployment_uuid: str, model_uuid: str, switch_to: KonanModelState, new_live_model_uuid: Optional[str] = None) None

Switch the sate of a Konan Model

If model_uuid is the UUID of the current Live model then: - it will be demoted to Challenger, and - the parameter new_live_model_uuid is required

Parameters
  • deployment_uuid (str) – UUID of deployment

  • model_uuid (str) – UUID of model to switch

  • switch_to (KonanModelState) – new state to switch mode to. Must be different from the model’s current state

  • new_live_model_uuid – _description_, defaults to None.

Required only if model_uuid is the UUID of the current Live model :type new_live_model_uuid: str, optional :return: None :rtype: None

predict(deployment_uuid: str, input_data: Union[Dict, str]) Tuple[str, Dict]

Call the predict function for a given deployment

Parameters
  • deployment_uuid (str) – uuid of deployment to use for prediction

  • input_data (Union[Dict, str]) – data to pass to the model

Returns

A tuple of prediction uuid and the prediction output

Return type

Tuple[str, Dict]

evaluate(deployment_uuid: str, start_time: datetime, end_time: datetime) List[KonanBaseMetric]

Call the evaluate function for a given deployment

Parameters
  • deployment_uuid (str) – uuid of deployment to use for evaluation

  • start_time (datetime.datetime) – use predictions made at or after this time

  • end_time (datetime.datetime) – use predictions made before or at this time

Returns

A model evaluation object

Return type

EvaluateEndpoint.ResponseObject

feedback(deployment_uuid: str, feedbacks: List[KonanFeedbackSubmission]) KonanFeedbacksResult

Call the feedback function for a given deployment

Parameters
  • deployment_uuid (str) – uuid of deployment to use for prediction

  • feedbacks (List[KonanFeedbackSubmission]) – feedback objects to register with the deployment

Returns

feedback result

Return type

KonanFeedbacksResult

delete_model(model_uuid: str) bool

Call the delete function for a given model WARNING: Using this method with a valid mode_uuid will DELETE it!! :param model_uuid: uuid of model to delete :type model_uuid: str :return: success :rtype: bool

delete_deployment(deployment_uuid: str) bool

Call the delete function for a given deployment WARNING: Using this method with a valid deployment_uuid will DELETE it!! :param deployment_uuid: uuid of deployment to delete :type deployment_uuid: str :return: success :rtype: bool