Code Monkey home page Code Monkey logo

customer-satisfaction-mlops's Introduction

Hi ๐Ÿ‘‹, I'm Ayush Singh

Machine Learning Engineer & Data Scientist

ayush714

ayush714

ayushsi69507942

  • ๐Ÿ”ญ I am currently working as MLOps Engineer at zenml.io, where I am working on creating end to end production grade machine learning projects.

  • ๐ŸŒฑ I have worked as Data Scientist at artifact.io, where I worked in creating large scale NLP products for the organization. I have also worked as Deep Learning Engineer at visionnlp.com/ where I worked on client based projects.

  • ๐Ÿ‘ฏ I am currently building my own startup antern.co,Antern is an EdTech Platform which leverages Artificial intelligence and AR/VR to build educational content more fun and engaging, we build comprehensive and in-depth courses which helped students to get placed in top companies like IBM, Google and etc.

  • ๐Ÿ“ I regularly write articles on https://www.analyticsvidhya.com/blog/author/ayush3987/ and [blog.zenml.io](ZenML Blog).

  • ๐Ÿ’ฌ Ask me about Machine Learning, Deep Learning, GANS, CNN, NLP

  • ๐Ÿ“ซ How to reach me [email protected]

  • ๐Ÿ“„ Know about my experiences https://www.linkedin.com/in/ayush-singh488/

Connect with me:

ayushsi69507942 ayush-singh488 ayushsingh488 intelligentprogrammer123 neweraa ayush488 intelligentprogrammer123

Languages and Tools:

bootstrap c css3 django flask git heroku html5 java mongodb mysql opencv python pytorch scikit_learn tensorflow

ย ayush714

ayush714

customer-satisfaction-mlops's People

Contributors

ayush714 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

customer-satisfaction-mlops's Issues

Error in model deployment

โ€”โ€”โ€”โ€”โ€”
Python == 3.11.8

mlflow == 2.10.2
mlserver == 1.5.0
mlserver-mlflow == 1.5.0
MarkupSafe == 2.1.5
numpy == 1.26.4
pandas == 2.2.1
scikit-learn == 1.4.1.post1
tqdm == 4.66.2
zenml == 0.55.5
โ€”โ€”โ€”โ€”โ€”
I have been following the code of the video lecture. The previous versions of the pipeline ran well. That was until trying to deploy the model.
I have made several virtual environments and used different stacks (deleted one stack and created another one and set that up (The latest stack used was: mlflow_customer_02.
I still cannot make the deployment work.

This is the main error:

ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8237): Max retries exceeded with 
url: /api/v1/runs/d1673d8a-89aa-42c0-a805-53d3fa8f99ac?hydrate=True (Caused by 
NewConnectionError('<urllib3.connection.HTTPConnection object at 0x28f196350>: Failed to 
establish a new connection: [Errno 61] Connection refused'))

Tried to do this as well and did not work:

% zenml down
% zenml disconnect
% zenml up
% python run_deployment.py --config deploy

โ€”โ€”โ€”โ€”โ€”
A summary of the steps retrieved to show that the pipeline works until the deployment phase:

% python run_deployment.py --config deploy
Initiating a new run for the pipeline: continuous_deployment_pipeline.
Reusing registered pipeline version: (version: 13).
Executing a new run.
Caching is disabled by default for continuous_deployment_pipeline.
Using user: default
Using stack: mlflow_stack_customer_02
  model_deployer: mlflow_customer_02
  experiment_tracker: mlflow_tracker_customer_02
  orchestrator: default
  artifact_store: default
Step ingest_df has started.
Ingesting data from /Users/luis/Documents/.../venv_0754_FCC_MLOPS_MLProd_Projects_311_01/data/olist_customers_dataset_copy01.csv
Step ingest_df has finished in 2.512s.
Step clean_df has started.
Data cleaning completed
Step clean_df has finished in 1.542s.
Step train_model has started.
Model training completed
Model Trained Successfully
Step train_model has finished in 3.099s.
Step evaluate_model has started.
Calculating MSE
MSE: 1.864077053397548
Calculating R2 Score
R2 Score: 0.017729030402295565
Calculating RMSE
RMSE: 1.3653120717980736
Step evaluate_model has finished in 0.683s.
Step deployment_trigger has started.
Step deployment_trigger has finished in 0.095s.
Caching disabled explicitly for mlflow_model_deployer_step.
Step mlflow_model_deployer_step has started.
Calling stop method...
stop method executed successfully.
Updating an existing MLflow deployment service: MLFlowDeploymentService[577b7471-9979-487c-94fb-cc6ede12b61d] (type: model-serving, flavor: mlflow)
Calling stop method...
stop method executed successfully.
Calling start method...
โ  Starting service 'MLFlowDeploymentService[577b7471-9979-487c-94fb-cc6ede12b61d] (type: 
model-serving, flavor: mlflow)'.

File "/Users/luis/miniforge3/envs/venv_0754_FCC_MLOPS_MLProd_Projects_311_02/lib/python3.11/site-packages/zenml/services/service.py", line 461, in start
    raise RuntimeError(
RuntimeError: Failed to start service MLFlowDeploymentService[577b7471-9979-487c-94fb-cc6ede12b61d] (type: model-serving, flavor: mlflow)
  Administrative state: active
  Operational state: inactive
  Last status message: 'service daemon is not running'
For more information on the service status, please see the following log file: /Users/luis/Library/Application Support/zenml/local_stores/19914fc0-6d0d-41d4-bca6-4924211935c1/577b7471-9979-487c-94fb-cc6ede12b61d/service.log

Retrying (Retry(total=9, connect=5, read=None, redirect=None, status=None)) after connection broken by 'RemoteDisconnected('Remote end closed connection without response')': /api/v1/steps/feeec1ee-8f5e-41ae-87f2-d803fd045f31

(โ€ฆ)

Retrying (Retry(total=9, connect=5, read=None, redirect=None, status=None)) after connection broken by 'RemoteDisconnected('Remote end closed connection without response')': /api/v1/steps/feeec1ee-8f5e-41ae-87f2-d803fd045f31

ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=8237): Max retries exceeded with 
url: /api/v1/runs/d1673d8a-89aa-42c0-a805-53d3fa8f99ac?hydrate=True (Caused by 
NewConnectionError('<urllib3.connection.HTTPConnection object at 0x28f196350>: Failed to 
establish a new connection: [Errno 61] Connection refused'))

โ€”โ€”โ€”โ€”โ€”
Below is more stack information
โ€”โ€”โ€”โ€”โ€”

% zenml stack describe
COMPONENT_TYPE COMPONENT_NAME
MODEL_DEPLOYER mlflow_customer_02
EXPERIMENT_TRACKER mlflow_tracker_customer_02
ORCHESTRATOR default
ARTIFACT_STORE default

'mlflow_stack_customer_02' stack (ACTIVE)
Stack 'mlflow_stack_customer_02' with id 'c314644e-6abc-45a8-b8fa-271fff858b6c' is
owned by user default.
Dashboard URL:
http://127.0.0.1:8237/workspaces/default/stacks/c314644e-6abc-45a8-b8fa-271fff858b
6c/configuration

โ€”โ€”โ€”โ€”โ€”

% zenml status

-----ZenML Server Status-----
Connected to a ZenML server: 'http://127.0.0.1:8237'
The active user is: 'default'
The active workspace is: 'default' (repository)
The active stack is: 'mlflow_stack_customer_02' (repository)
Active repository root: /Users/luis/Documents/.../venv_0754_FCC_MLOPS_MLProd_Projects_311_02
Using configuration from: '/Users/luis/Library/Application Support/zenml'
Local store files are located at: '/Users/luis/Library/Application
Support/zenml/local_stores'
The status of the local dashboard:

| ZenML server 'local' | |
| URL | http://127.0.0.1:8237 |
| STATUS | โœ… |
| STATUS_MESSAGE | |
| CONNECTED | โœ… |

โ€”โ€”โ€”โ€”โ€”

% zenml stack list
ACTIVE STACK NAME STACK ID OWNER MODEL_DEPLOYER EXPERIMENT_TRACKER ORCHESTRATOR ARTIFACT_STORE
๐Ÿ‘‰ mlflow_stack_customer_02 c314644e-6abc-45a8-b8fa-271fff858b6c default mlflow_customer_02 mlflow_tracker_customer_02 default default
default aeff7473-997f-47a9-87fd-9d771f7543b6 - default default
mlflow_stack_customer 6a772157-30ec-463b-999f-10299ce3ec95 default mlflow_customer mlflow_tracker_customer default default

โ€”โ€”โ€”โ€”โ€”

% zenml logs
INFO:     127.0.0.1:50527 - "GET 
/api/v1/steps?hydrate=False&sort_by=created&logical_operator=and&page=1&size=20&scope_workspac
e=fd2a5d49-22cc-4dc8-a986-fa27bc93b88d&pipeline_run_id=d1673d8a-89aa-42c0-a805-53d3fa8f99ac 
HTTP/1.1" 200 OK

INFO:     127.0.0.1:50527 - "POST /api/v1/steps HTTP/1.1" 200 OK
objc[5368]: +[__NSCFConstantString initialize] may have been in progress in another thread 
when fork() was called.

objc[5368]: +[__NSCFConstantString initialize] may have been in progress in another thread 
when fork() was called. We cannot safely call it or ignore it in the fork() child process. 
Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.

โ€”โ€”โ€”โ€”โ€”

Dependency issue

Collecting Mako (from alembic->optuna==2.10.0->-r requirements.txt (line 4))
Using cached Mako-1.2.4-py3-none-any.whl (78 kB)
Using cached Mako-1.2.3-py3-none-any.whl (78 kB)
Using cached Mako-1.2.2-py3-none-any.whl (78 kB)
Using cached Mako-1.2.1-py3-none-any.whl (78 kB)
Using cached Mako-1.2.0-py3-none-any.whl (78 kB)
Using cached Mako-1.1.6-py2.py3-none-any.whl (75 kB)
Using cached Mako-1.1.5-py2.py3-none-any.whl (75 kB)
Using cached Mako-1.1.4-py2.py3-none-any.whl (75 kB)
Using cached Mako-1.1.3-py2.py3-none-any.whl (75 kB)
Using cached Mako-1.1.2-py2.py3-none-any.whl (75 kB)
Using cached Mako-1.1.1.tar.gz (468 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.1.0.tar.gz (463 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.14.tar.gz (462 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.13.tar.gz (460 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.12.tar.gz (460 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.11.tar.gz (461 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.10.tar.gz (460 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.9.tar.gz (459 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.8.tar.gz (468 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.7.tar.gz (564 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.6.tar.gz (575 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.5.tar.gz (574 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.4.tar.gz (574 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.3.tar.gz (565 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.2.tar.gz (564 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.1.tar.gz (473 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-1.0.0.tar.gz (470 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-0.9.1.tar.gz (421 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-0.9.0.tar.gz (420 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-0.8.1.tar.gz (407 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-0.8.0.tar.gz (407 kB)
Preparing metadata (setup.py) ... done
Using cached Mako-0.7.3.tar.gz (401 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

ร— python setup.py egg_info did not run successfully.
โ”‚ exit code: 1
โ•ฐโ”€> [1 lines of output]
error in Mako setup command: use_2to3 is invalid.
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

ร— Encountered error while generating package metadata.
โ•ฐโ”€> See above for output.

note: This is an issue with the package mentioned above, not pip.

While installing the requirements, I am getting this error even I am using a virtual environment,
Can anyone explain how to resolve the issue?

Daemon functionality is currently not supported on Windows.

Got This Error While Running

python run_deployement.py --config deploy

Log

The BaseParameters class to define step parameters is deprecated. Check out our docs https://docs.zenml.io/how-to/use-configuration-files/how-to-use-config for information on how to parameterize your steps. As a quick fix to get rid of this warning, make sure your parameter class inherits from pydantic.BaseModel instead of the BaseParameters class.
The BaseParameters class to define step parameters is deprecated. Check out our docs https://docs.zenml.io/how-to/use-configuration-files/how-to-use-config for information on how to parameterize your steps. As a quick fix to get rid of this warning, make sure your parameter class inherits from pydantic.BaseModel instead of the BaseParameters class.
Reusing registered pipeline version: (version: 2).
Executing a new run.
Caching is disabled by default for continuous_deployement_pipeline.
Using user: default
Using stack: mlflow_stack
  model_deployer: mlflow
  orchestrator: default
  experiment_tracker: mlflow_tracker
  artifact_store: default
You can visualize your pipeline runs in the ZenML Dashboard. In order to try it locally, please run zenml up.
Step ingest_df has started.
Investing Data fromE:\Codes\MLOPS\CDE\data\olist_customers_dataset.csv
Step ingest_df has finished in 8.268s.
Step ingest_df completed successfully.
Step clean_df has started.
E:\Codes\MLOPS\CDE\src\data_cleaning.py:37: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  data["product_weight_g"].fillna(
E:\Codes\MLOPS\CDE\src\data_cleaning.py:39: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  data["product_length_cm"].fillna(
E:\Codes\MLOPS\CDE\src\data_cleaning.py:41: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  data["product_height_cm"].fillna(
E:\Codes\MLOPS\CDE\src\data_cleaning.py:43: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method.
The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.

For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.


  data["product_width_cm"].fillna(
Data Cleaning Completed
Step clean_df has finished in 3.396s.
Step clean_df completed successfully.
Step train_model has started.
2024/06/19 16:26:45 WARNING mlflow.utils.autologging_utils: You are using an unsupported version of sklearn. If you encounter errors during autologging, try upgrading / downgrading sklearn to a supported version, or try upgrading MLflow.
2024/06/19 16:26:51 WARNING mlflow.utils.autologging_utils: MLflow autologging encountered a warning: "E:\Codes\MLOPS\env_mlops\lib\site-packages\mlflow\types\utils.py:394: UserWarning: Hint: Inferred schema contains integer column(s). Integer columns in Python cannot represent missing values. If your input data contains missing values at inference time, it will be encoded as floats and will cause a schema enforcement error. The best way to avoid this problem is to infer the model schema based on a realistic data sample (training dataset) that includes missing values. Alternatively, you can declare integer columns as doubles (float64) whenever these columns may have missing values. See `Handling Integers With Missing Values <https://www.mlflow.org/docs/latest/models.html#handling-integers-with-missing-values>`_ for more details."
2024/06/19 16:26:51 WARNING mlflow.utils.autologging_utils: MLflow autologging encountered a warning: "E:\Codes\MLOPS\env_mlops\lib\site-packages\mlflow\types\utils.py:394: UserWarning: Hint: Inferred schema contains integer column(s). Integer columns in Python cannot represent missing values. If your input data contains missing values at inference time, it will be encoded as floats and will cause a schema enforcement error. The best way to avoid this problem is to infer the model schema based on a realistic data sample (training dataset) that includes missing values. Alternatively, you can declare integer columns as doubles (float64) whenever these columns may have missing values. See `Handling Integers With Missing Values <https://www.mlflow.org/docs/latest/models.html#handling-integers-with-missing-values>`_ for more details."
2024/06/19 16:27:18 WARNING mlflow.utils.autologging_utils: MLflow autologging encountered a warning: "E:\Codes\MLOPS\env_mlops\lib\site-packages\_distutils_hack\__init__.py:33: UserWarning: Setuptools is replacing distutils."
Model Training Completed
E:\Codes\MLOPS\env_mlops\lib\site-packages\zenml\integrations\mlflow\experiment_trackers\mlflow_experiment_tracker.py:254: FutureWarning: ``mlflow.gluon.autolog`` is deprecated since 2.5.0. This method will be removed in a future release.
  module.autolog(disable=True)
Step train_model has finished in 35.067s.
Step train_model completed successfully.
Step evaluion_model has started.
Calculating MSE
MSE: 1.8640770533975461
Calculating R2
R2: 0.017729030402296564
Calculating MSE
E:\Codes\MLOPS\env_mlops\lib\site-packages\sklearn\metrics\_regression.py:492: FutureWarning: 'squared' is deprecated in version 1.4 and will be removed in 1.6. To calculate the root mean squared error, use the function'root_mean_squared_error'.
  warnings.warn(
MSE: 1.365312071798073
E:\Codes\MLOPS\env_mlops\lib\site-packages\zenml\integrations\mlflow\experiment_trackers\mlflow_experiment_tracker.py:254: FutureWarning: ``mlflow.gluon.autolog`` is deprecated since 2.5.0. This method will be removed in a future release.
  module.autolog(disable=True)
Step evaluion_model has finished in 1.011s.
Step evaluion_model completed successfully.
Step deployment_trigger has started.
Step deployment_trigger has finished in 0.136s.
Step deployment_trigger completed successfully.
Caching disabled explicitly for mlflow_model_deployer_step.
Step mlflow_model_deployer_step has started.
Daemon functionality is currently not supported on Windows.
Daemon functionality is currently not supported on Windows.
Existing model server found for model with the exact same configuration. Returning the existing service named zenml-model.
Daemon functionality is currently not supported on Windows.
MLflow deployment service started and reachable at:
    None

Stopping existing services...
Calling stop method...
Daemon functionality is currently not supported on Windows.
Daemon functionality is currently not supported on Windows.
Daemon functionality is currently not supported on Windows.
stop method executed successfully.
Daemon functionality is currently not supported on Windows.
Step mlflow_model_deployer_step has finished in 1.523s.
Step mlflow_model_deployer_step completed successfully.
Pipeline run has finished in 50.718s.
You can run:
     mlflow ui --backend-store-uri 'file:C:\Users\jaysi\AppData\Roaming\zenml\local_stores\c0011160-7514-4297-b481-43839e52e0c0\mlruns
 ...to inspect your experiment runs within the MLflow UI.
You can find your runs tracked within the `mlflow_example_pipeline` experiment. There you'll also be able to compare two or more runs.


Daemon functionality is currently not supported on Windows.
Daemon functionality is currently not supported on Windows.
Daemon functionality is currently not supported on Windows.

Code

import numpy as np
import json
import pandas as pd
from zenml import pipeline, step
from zenml.config import DockerSettings
from zenml.constants import DEFAULT_SERVICE_START_STOP_TIMEOUT
from zenml.integrations.constants import MLFLOW
from zenml.integrations.mlflow.model_deployers.mlflow_model_deployer import (
    MLFlowModelDeployer,
)
from zenml.integrations.mlflow.services import MLFlowDeploymentService
from zenml.integrations.mlflow.steps import mlflow_model_deployer_step
from zenml.steps import BaseParameters, Output

from steps.clean_Data import clean_df
from steps.evalution import evaluion_model
from steps.ingest_Data import ingest_df
from steps.model_train import train_model

from .utils import get_data_for_test


docker_settings = DockerSettings(required_integrations=[MLFLOW])


class DeploymentTriggerConfig(BaseParameters):
    """Deployment Trigger Config"""
    min_accuracy: float = 0


@step(enable_cache=False)
def dynamic_importer() -> str:
    """Downloads the latest data from a mock API."""
    data = get_data_for_test()
    return data


@step
def deployment_trigger(
    accuracy: float,
    config: DeploymentTriggerConfig
):
    """Check If Model Accuracy Is Good Enough To Deploy Or Not"""
    return accuracy > config.min_accuracy


class MLFlowDeploymentLoaderStepParameters(BaseParameters):
    """MLflow deployment getter parameters

    Attributes:
        pipeline_name: name of the pipeline that deployed the MLflow prediction
            server
        step_name: the name of the step that deployed the MLflow prediction
            server
        running: when this flag is set, the step only returns a running service
        model_name: the name of the model that is deployed
    """

    pipeline_name: str
    step_name: str
    running: bool = True


@step(enable_cache=False)
def prediction_service_loader(
    pipeline_name: str,
    pipeline_step_name: str,
    running: bool = True,
    model_name: str = "model"
) -> MLFlowDeploymentService:
    """Get the prediction service started by the deployment pipeline.

 Args:
     pipeline_name: name of the pipeline that deployed the MLflow prediction
         server
     step_name: the name of the step that deployed the MLflow prediction
         server
     running: when this flag is set, the step only returns a running service
     model_name: the name of the model that is deployed
 """

    # GEt Empl Folw Depflyer Stack Component
    model_deployer = MLFlowModelDeployer.get_active_model_deployer()
    # fetch existing services with same pipeline name, step name and model name
    existing_services = model_deployer.find_model_server(
        pipeline_name=pipeline_name,
        pipeline_step_name=pipeline_step_name,
        model_name=model_name,
        running=running,
    )

    if not existing_services:
        raise RuntimeError(
            f"No MLflow prediction service deployed by the "
            f"{pipeline_step_name} step in the {pipeline_name} "
            f"pipeline for the '{model_name}' model is currently "
            f"running."
        )
    return existing_services[0]


@step
def predictor(
    service: MLFlowDeploymentService,
    data: str,
) -> np.ndarray:
    """Run an inference request against a prediction service"""

    service.start(timeout=10)  # should be a NOP if already started
    data = json.loads(data)
    data.pop("columns")
    data.pop("index")
    columns_for_df = [
        "payment_sequential",
        "payment_installments",
        "payment_value",
        "price",
        "freight_value",
        "product_name_lenght",
        "product_description_lenght",
        "product_photos_qty",
        "product_weight_g",
        "product_length_cm",
        "product_height_cm",
        "product_width_cm",
    ]
    df = pd.DataFrame(data["data"], columns=columns_for_df)
    json_list = json.loads(json.dumps(list(df.T.to_dict().values())))
    data = np.array(json_list)
    prediction = service.predict(data)
    return prediction


@pipeline(enable_cache=False, settings={"docker": docker_settings})
def continuous_deployement_pipeline(data_path: str, min_accuracy: float = 0,
                                    workers: int = 1,
                                    timeout: int = DEFAULT_SERVICE_START_STOP_TIMEOUT):
    df = ingest_df(data_path=data_path)
    X_train, X_test, y_train, y_test = clean_df(df)
    model = train_model(X_train, X_test, y_train, y_test)
    r2, rmse, mse = evaluion_model(model, X_test, y_test)
    deployment_decision = deployment_trigger(accuracy=r2)
    mlflow_model_deployer_step(
        model=model,
        deploy_decision=deployment_decision,
        workers=workers,
        timeout=timeout,
    )


@pipeline(enable_cache=False, settings={"docker": docker_settings})
def inference_pipeline(pipeline_name: str, pipeline_step_name: str):
    # Link all the steps artifacts together
    data = dynamic_importer()
    service = prediction_service_loader(
        pipeline_name=pipeline_name,
        pipeline_step_name=pipeline_step_name,
        running=False,
    )
    prediction = predictor(service=service, data=data)
    return prediction

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.