External Monitoring module#
Module with all classes and methods to manage the Monitored External Machine Learning (ML) models.
MLOpsExternalMonitoring#
- class mlops_codex.external_monitoring.MLOpsExternalMonitoring(group: str, ex_monitoring_hash: str, status: MonitoringStatus | None = MonitoringStatus.Unvalidated, login: str | None = None, password: str | None = None, url: str | None = None)[source]#
Bases:
BaseMLOps
Class that handles an external monitoring object
- host(wait: bool | None = False)[source]#
Host the new external monitoring.
- Parameters:
wait (Optional[bool], optional) – If true, wait until the host is validated or invalidate.
- Raises:
AuthenticationError – Raised if there is an authentication issue.
GroupError – Raised if there is an error related to the group.
ServerError – Raised if the server encounters an issue.
ExternalMonitoringError – Raised if there is an error specific to external monitoring.
- Returns:
The external monitoring hash if the new external monitoring is successfully hosted.
- Return type:
str
- logs(start: str, end: str)[source]#
Get the logs of an external monitoring.
- Parameters:
start (str) – Start date to look for the records. The format must be dd-MM-yyyy.
end (str) – End date to look for the records. The format must be dd-MM-yyyy.
- upload_file(*, model_file: str | None = None, requirements_file: str | None = None, preprocess_file: str | None = None, preprocess_reference: str | None = None, shap_reference: str | None = None, python_version: str | None = '3.10')[source]#
Validate inputs before sending files.
- Parameters:
model_file (Optional[str], optional) – Path to your model.pkl file. Defaults to None.
requirements_file (Optional[str], optional) – Path to your requirements.txt file. Defaults to None.
preprocess_file (Optional[str], optional) – Path to your preprocessing file. Defaults to None.
preprocess_reference (Optional[str], optional) – Preprocessing function entrypoint. Defaults to None.
shap_reference (Optional[str], optional) – Shap function entrypoint. Defaults to None.
python_version (Optional[str], optional) – Python version. Can be “3.8”, “3.9”, or “3.10”. Defaults to “3.10”.
- Raises:
InputError – Raised if there is an error with the input model_file.
InputError – Raised if there is an error with the input requirements_file.
MLOpsExternalMonitoringClient#
- class mlops_codex.external_monitoring.MLOpsExternalMonitoringClient(*, login: str | None = None, password: str | None = None, url: str | None = None)[source]#
Bases:
BaseMLOpsClient
Class that handles MLOps External Monitoring Client
- Parameters:
login (str) – Login for authenticating with the client. You can also use the env variable MLOPS_USER to set this
password (str) – Password for authenticating with the client. You can also use the env variable MLOPS_PASSWORD to set this
url (str) – URL to MLOps Server. Default value is https://neomaril.datarisk.net/, use it to test your deployment first before changing to production. You can also use the env variable MLOPS_URL to set this
- Raises:
ServerError – Database produced an unexpected error.
AuthenticationError – If user is not in the master group.
CredentialError – If the Cloud Credential is Invalid
- get_external_monitoring(external_monitoring_hash: str) MLOpsExternalMonitoring [source]#
Return an external monitoring.
- Parameters:
external_monitoring_hash (str) – External Monitoring Hash.
- Raises:
ExternalMonitoringError – Raised if there is an error fetching the external monitoring.
- Returns:
The requested MLOps external monitoring instance.
- Return type:
- register_monitoring(**kwargs) MLOpsExternalMonitoring | None [source]#
Register a MLOps External Monitoring.
- Parameters:
name (str) – External Monitoring name.
group (str) – External Monitoring group. The group is the same used for the external training and datasource.
training_execution_id (int) – Valid MLOps training execution id.
period (str) – The frequency the monitoring will run. It can be one of the following: “Day”, “Week”, “Quarter”, “Month”, “Year”.
input_cols (list) – List with input column names.
output_cols (list) – List with output column names.
datasource_name (str) – Valid MLOps datasource name.
extraction_type (str) – Type of extraction. It can be one of the following: “Incremental”, “Full”.
datasource_uri (str) – Valid datasource URI.
column_name (Optional[str], optional) – Column name of the data column.
reference_date (Optional[str], optional) – Reference extraction date.
python_version (Optional[str], optional) – Python version used to run preprocessing scripts. It can be one of the following: “3.8”, “3.9”, “3.10”. Defaults to “3.10”.
- Raises:
InputError – Raised if there is an error with the provided input.
- Returns:
The newly registered MLOps external monitoring instance.
- Return type: