ExportMLModel

Exports an existing ML model to a file.

python · Machine Learning

Details

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

README

Exports an existing ML model to a file.

Script Data


Name Description
Script Type python3
Tags ml
Cortex XSOAR Version 5.0.0

Inputs


Argument Name Description
modelName The name of the ML model to export to a file.

Outputs


There are no outputs for this script.

from CommonServerPython import *
from ExportMLModel import main

dummy_data = list(range(10))


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

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

    def execute_command(command, args):
        if command == "getMLModel":  # noqa: RET503
            key_args = ["modelName"]
            assert all(k in args for k in key_args)
            return [{"Contents": dummy_data, "Type": entryTypes["file"]}]

    def results(result):
        file_id = result["FileID"]
        with open(demisto.investigation()["id"] + "_" + file_id) as f:
            file_data_str = f.read()
        file_data = json.loads(file_data_str)
        assert all(x in file_data for x in dummy_data)
        assert all(x in dummy_data for x in file_data)

    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()