Package: oip-mlops-client
Open Innovation MLOps Client APIWelcome to the Open Innovation MLOps Client API documentation! This guide offers detailed instructions on how to install, set up, and use the client library.Installation and SetupTo use the Open Innovation MLOps Client in your project, follow these steps:Install the client library: Use the following pip command to add the Open Innovation MLOps Client to your Python environment:pip install oip-mlops-clientImport the library: Add the following import statement to your Python script to gain access to theMLOpsclass from the client library:fromoip_mlops_client.mlopsimportMLOpsClient Initialization and TrackingTo start using the Open Innovation MLOps Client in your application, you need to initialize it with specific details about your environment.api_host="api_host"username="your_username"password="your_password"workspace_name="target_workspace_name"MLOps.connect(api_host,username,password,workspace_name)Parametersapi_host(str, required): The hostname of the API server.username(str, required): Your username.password(str, required): Your password.workspace_name(str, required): The name of the workspace you want to connect to. This workspace should already exist on the platform's user interface (UI).OAfter initializing the client and establishing the connection, you can specify the experiment you want to track:experiment_name="target_experiment_name"MLOps.set_experiment(experiment_name)Parametersexperiment_name(str, required): The name of the experiment you want to track. This experiment should already exist on the platform's UI.Once the target experiment is set, the API client is ready to start tracking your runs.Compatibility with Mlflow for TrackingThe MLOps client provides access to all the methods available through the MLflow API. For instance:MLOps.autolog() is equivalent to mlflow.autolog()For more information about the available methods, refer to theMLflow official documentation.Advanced Artifacts TrackingIn addition to all the features offered by MLflow, our solution also enables tracking of specific types of artifacts like images, audio, video, figures, text, JSON, etc., for specific machine learning training tasks analysis. This allows for sophisticated and advanced analytics and visualizations through our platform UI.Image TrackingThelog_image_at_stepmethod accepts an image as anumpy.ndarrayorrom PIL.Image.Image:fromPILimportImage# Load or create your image as numpy.ndarray or PIL.Imageimage_data=Image.open("test_image.jpg")# Log image at specific stepextra={"description":"test image"}MLOps.log_image_at_step(image_data,'image_file.jpg',1,extra)Please note that for images, you can directly pass the path to the image file.Audio TrackingThelog_audio_at_stepmethod accepts audio data as anumpy.ndarray:importnumpyasnp# Create or load your audio data as a numpy arrayaudio_data=np.random.random(1000)# Log audio at specific stepMLOps.log_audio_at_step(audio_data,'audio_file.wav',1,rate=44100)The audio_data should be a numpy array. If the audio is stereo, the array should be 2-dimensional.Text TrackingThelog_text_at_stepmethod accepts text as astr:# Log text at specific steptext_data="This is a sample text."MLOps.log_text_at_step(text_data,'text_file.txt',1)Figure TrackingThelog_figure_at_stepmethod accepts a figure as amatplotlib.figure.Figureorplotly.graph_objects.Figure:importmatplotlib.pyplotasplt# Create a figurefig,ax=plt.subplots()ax.plot([1,2,3,4],[1,4,2,3])# Log figure at specific stepMLOps.log_figure_at_step(fig,'figure_file.jpg',1)The fig should be a matplotlib.figure.Figure object.JSON TrackingThe log_dict_at_step method accepts a dictionary or list to be logged as JSON:# Log dictionary at specific stepdict_data={"key1":"value1","key2":"value2"}MLOps.log_dict_at_step(dict_data,'dict_file.json',1)The dictionary or list will be saved as a JSON file.Extra ParametersNote: All log_*_at_step methods accept an optional extra parameter (of type dict) which can be used to log additional metadata about the artifact, and a file_name (of type str) that specifies the name of the artifact file. For log_audio_at_step, there is also a rate parameter (of type int) to specify the sample rate of the audio data.The extra parameter should be a dictionary with string keys. The values can be of types int, float, str, bool, list, or None.extra={"description":"This is a description of the artifact."}In the case of log_audio_at_step, there's also a rate parameter to specify the sample rate of the audio data.MLOps.log_audio_at_step(audio_data,'audio_file',1,rate=44100,extra=extra)