ImportMLModel

Imports a file that contains an ML model.

python · Machine Learning

Details

IDImportMLModel
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10116658
Tagsml

README

Imports a file that contains an ML model.

Script Data


Name Description
Script Type python3
Tags ml
Cortex XSOAR Version 5.0.0

Inputs


Argument Name Description
entryID ID of the entry that contains the ML model to import.
modelName The model name in which the ML model will be saved.
modelStoreType The method for storing the imported model.

Outputs


There are no outputs for this script.

import demistomock as demisto
from ImportMLModel import main

done = False


def test_main(mocker):
    mocker.patch.object(demisto, "args", return_value={"entryID": "id", "modelName": "model", "modelStoreType": "mlModel"})

    def get_file_path(entry_id):
        return {"path": "./TestData/entry_file"}

    def execute_command(command, args):
        if command == "createMLModel":
            key_args = ["modelData", "modelName", "modelLabels", "modelOverride"]
        if command == "evaluateMLModel":
            key_args = ["modelConfusionMatrix", "modelName"]
        assert all(k in args for k in key_args)
        return []

    def results(result):
        global done
        if result == "done":
            done = True

    # mocker.patch.object('read_file_content', side_effect=get_file_path)
    mocker.patch.object(demisto, "getFilePath", side_effect=get_file_path)
    mocker.patch.object(demisto, "executeCommand", side_effect=execute_command)
    mocker.patch.object(demisto, "results", side_effect=results)
    main()
    assert done