<gh_stars>100-1000
# - Generated by tools/entrypoint_compiler.py: do not edit by hand
"""
Models.OnnxTransformer
"""

import numbers

from ..utils.entrypoints import EntryPoint
from ..utils.utils import try_set, unlist


def models_onnxtransformer(
        model_file,
        data,
        output_data=None,
        model=None,
        input_columns=None,
        output_columns=None,
        gpu_device_id=None,
        fallback_to_cpu=False,
        **params):
    """
    **Description**
        Applies an ONNX model to a dataset.

    :param model_file: Path to the onnx model file. (inputs).
    :param input_columns: Name of the input column. (inputs).
    :param data: Input dataset (inputs).
    :param output_columns: Name of the output column. (inputs).
    :param gpu_device_id: GPU device id to run on (e.g. 0,1,..). Null
        for CPU. Requires CUDA 9.1. (inputs).
    :param fallback_to_cpu: If true, resumes execution on CPU upon
        GPU error. If false, will raise the GPU execption. (inputs).
    :param output_data: ONNX transformed dataset (outputs).
    :param model: Transform model (outputs).
    """

    entrypoint_name = 'Models.OnnxTransformer'
    inputs = {}
    outputs = {}

    if model_file is not None:
        inputs['ModelFile'] = try_set(
            obj=model_file,
            none_acceptable=False,
            is_of_type=str)
    if input_columns is not None:
        inputs['InputColumns'] = try_set(
            obj=input_columns,
            none_acceptable=True,
            is_of_type=list,
            is_column=True)
    if data is not None:
        inputs['Data'] = try_set(
            obj=data,
            none_acceptable=False,
            is_of_type=str)
    if output_columns is not None:
        inputs['OutputColumns'] = try_set(
            obj=output_columns,
            none_acceptable=True,
            is_of_type=list,
            is_column=True)
    if gpu_device_id is not None:
        inputs['GpuDeviceId'] = try_set(
            obj=gpu_device_id,
            none_acceptable=True,
            is_of_type=numbers.Real)
    if fallback_to_cpu is not None:
        inputs['FallbackToCpu'] = try_set(
            obj=fallback_to_cpu,
            none_acceptable=True,
            is_of_type=bool)
    if output_data is not None:
        outputs['OutputData'] = try_set(
            obj=output_data,
            none_acceptable=False,
            is_of_type=str)
    if model is not None:
        outputs['Model'] = try_set(
            obj=model,
            none_acceptable=False,
            is_of_type=str)

    input_variables = {
        x for x in unlist(inputs.values())
        if isinstance(x, str) and x.startswith("$")}
    output_variables = {
        x for x in unlist(outputs.values())
        if isinstance(x, str) and x.startswith("$")}

    entrypoint = EntryPoint(
        name=entrypoint_name, inputs=inputs, outputs=outputs,
        input_variables=input_variables,
        output_variables=output_variables)
    return entrypoint

# - Generated by tools/entrypoint_compiler.py: do not edit by hand
"""
Models.OnnxTransformer
"""

import numbers

from ..utils.entrypoints import EntryPoint
from ..utils.utils import try_set, unlist


def models_onnxtransformer(
        model_file,
        data,
        output_data=None,
        model=None,
        input_columns=None,
        output_columns=None,
        gpu_device_id=None,
        fallback_to_cpu=False,
        **params):
    """
    **Description**
        Applies an ONNX model to a dataset.

    :param model_file: Path to the onnx model file. (inputs).
    :param input_columns: Name of the input column. (inputs).
    :param data: Input dataset (inputs).
    :param output_columns: Name of the output column. (inputs).
    :param gpu_device_id: GPU device id to run on (e.g. 0,1,..). Null
        for CPU. Requires CUDA 9.1. (inputs).
    :param fallback_to_cpu: If true, resumes execution on CPU upon
        GPU error. If false, will raise the GPU execption. (inputs).
    :param output_data: ONNX transformed dataset (outputs).
    :param model: Transform model (outputs).
    """

    entrypoint_name = 'Models.OnnxTransformer'
    inputs = {}
    outputs = {}

    if model_file is not None:
        inputs['ModelFile'] = try_set(
            obj=model_file,
            none_acceptable=False,
            is_of_type=str)
    if input_columns is not None:
        inputs['InputColumns'] = try_set(
            obj=input_columns,
            none_acceptable=True,
            is_of_type=list,
            is_column=True)
    if data is not None:
        inputs['Data'] = try_set(
            obj=data,
            none_acceptable=False,
            is_of_type=str)
    if output_columns is not None:
        inputs['OutputColumns'] = try_set(
            obj=output_columns,
            none_acceptable=True,
            is_of_type=list,
            is_column=True)
    if gpu_device_id is not None:
        inputs['GpuDeviceId'] = try_set(
            obj=gpu_device_id,
            none_acceptable=True,
            is_of_type=numbers.Real)
    if fallback_to_cpu is not None:
        inputs['FallbackToCpu'] = try_set(
            obj=fallback_to_cpu,
            none_acceptable=True,
            is_of_type=bool)
    if output_data is not None:
        outputs['OutputData'] = try_set(
            obj=output_data,
            none_acceptable=False,
            is_of_type=str)
    if model is not None:
        outputs['Model'] = try_set(
            obj=model,
            none_acceptable=False,
            is_of_type=str)

    input_variables = {
        x for x in unlist(inputs.values())
        if isinstance(x, str) and x.startswith("$")}
    output_variables = {
        x for x in unlist(outputs.values())
        if isinstance(x, str) and x.startswith("$")}

    entrypoint = EntryPoint(
        name=entrypoint_name, inputs=inputs, outputs=outputs,
        input_variables=input_variables,
        output_variables=output_variables)
    return entrypoint
# - Generated by tools/entrypoint_compiler.py: do not edit by hand Models.OnnxTransformer **Description**         Applies an ONNX model to a dataset.      :param model_file: Path to the onnx model file. (inputs).     :param input_columns: Name of the input column. (inputs).     :param data: Input dataset (inputs).     :param output_columns: Name of the output column. (inputs).     :param gpu_device_id: GPU device id to run on (e.g. 0,1,..). Null         for CPU. Requires CUDA 9.1. (inputs).     :param fallback_to_cpu: If true, resumes execution on CPU upon         GPU error. If false, will raise the GPU execption. (inputs).     :param output_data: ONNX transformed dataset (outputs).     :param model: Transform model (outputs).