hyrax.verbs.engine
==================

.. py:module:: hyrax.verbs.engine


Attributes
----------

.. autoapisummary::

   hyrax.verbs.engine.logger


Classes
-------

.. autoapisummary::

   hyrax.verbs.engine.Engine


Module Contents
---------------

.. py:data:: logger

.. py:class:: Engine(config)

   Bases: :py:obj:`hyrax.verbs.verb_registry.Verb`


   This verb drives inference with an ONNX model in production.

   .. py:method:: __init__

   Overall initialization for all verbs that saves the config


   .. py:attribute:: cli_name
      :value: 'engine'



   .. py:attribute:: add_parser_kwargs


   .. py:attribute:: description
      :value: 'Run inference with an ONNX model.'



   .. py:method:: setup_parser(parser)
      :staticmethod:


      Setup parser for engine verb



   .. py:method:: run_cli(args=None)

      CLI stub for Engine verb



   .. py:method:: run(model_directory: str = None)

      Run inference with an ONNX model.

      This method performs the following steps:
      - Read in the user config
      - Prepare all the datasets requested
      - Implement a simple strategy for reading in batches of data samples
      - Process the samples with any custom collate functions as well as a default collate function
      - Pass the collated batch to the appropriate to_tensor function
      - Send that output to the ONNX-ified model
      - Persist the results of inference

      :param model_directory: Directory containing the ONNX model. If not provided, uses the config file
                              or finds the most recent ONNX export directory.
      :type model_directory: str, optional



   .. py:method:: create_ort_inputs(prepared_batch)

      Create the inputs array for the ONNX model using the expected inputs
      from the loaded ONNX model and the type and shape of the prepared batch.



   .. py:method:: run_onnx_batch(ort_inputs)

      Run the batch using our onnx runtime session

      Only split out because this is when data is mutated and we need to be able to trace it.



   .. py:method:: _setup_trace(prepare_inputs_fn)


