abacusai.prediction_operator — AbacusAI documentation

# abacusai.prediction_operator

## Classes

`CodeSource` | Code source for python-based custom feature groups and models
`PredictionOperatorVersion` | A prediction operator version.
`RefreshSchedule` | A refresh schedule for an object. Defines when the next version of the object will be created
`AbstractApiClass` |
`PredictionOperator` | A prediction operator.

## Module Contents

class abacusai.prediction_operator.CodeSource(client, sourceType=None, sourceCode=None, applicationConnectorId=None, applicationConnectorInfo=None, packageRequirements=None, status=None, error=None, publishingMsg=None, moduleDependencies=None)

  Bases: `abacusai.return_class.AbstractApiClass`

  Code source for python-based custom feature groups and models

  Parameters:

    - client (ApiClient) – An authenticated API Client instance

    - sourceType (str) – The type of the source, one of TEXT, PYTHON, FILE_UPLOAD, or APPLICATION_CONNECTOR

    - sourceCode (str) – If the type of the source is TEXT, the raw text of the function

    - applicationConnectorId (str) – The Application Connector to fetch the code from

    - applicationConnectorInfo (str) – Args passed to the application connector to fetch the code

    - packageRequirements (list) – The pip package dependencies required to run the code

    - status (str) – The status of the code and validations

    - error (str) – If the status is failed, an error message describing what went wrong

    - publishingMsg (dict) – Warnings in the source code

    - moduleDependencies (list) – The list of internal modules dependencies required to run the code

  __repr__()

    Return repr(self).

  to_dict()

    Get a dict representation of the parameters in this class

    Returns:

      The dict value representation of the class parameters

    Return type:

      dict

  import_as_cell()

    Adds the source code as an unexecuted cell in the notebook.

class abacusai.prediction_operator.PredictionOperatorVersion(client, predictionOperatorId=None, predictionOperatorVersion=None, createdAt=None, updatedAt=None, sourceCode=None, memory=None, useGpu=None, featureGroupIds=None, featureGroupVersions=None, status=None, error=None, codeSource={})

  Bases: `abacusai.return_class.AbstractApiClass`

  A prediction operator version.

  Parameters:

    - client (ApiClient) – An authenticated API Client instance

    - predictionOperatorId (str) – The unique identifier of the prediction operator.

    - predictionOperatorVersion (str) – The unique identifier of the prediction operator version.

    - createdAt (str) – Date and time at which the prediction operator was created.

    - updatedAt (str) – Date and time at which the prediction operator was updated.

    - sourceCode (str) – Python code used to make the prediction operator.

    - memory (int) – Memory in GB specified for the prediction operator version.

    - useGpu (bool) – Whether this prediction operator version is using gpu.

    - featureGroupIds (list) – A list of Feature Group IDs used for initializing.

    - featureGroupVersions (list) – A list of Feature Group version IDs used for initializing.

    - status (str) – The current status of the prediction operator version.

    - error (str) – The error message if the status failed.

    - codeSource (CodeSource) – If a python model, information on the source code.

  __repr__()

    Return repr(self).

  to_dict()

    Get a dict representation of the parameters in this class

    Returns:

      The dict value representation of the class parameters

    Return type:

      dict

  delete()

    Delete a prediction operator version.

    Parameters:

      prediction_operator_version (str) – The unique ID of the prediction operator version.

class abacusai.prediction_operator.RefreshSchedule(client, refreshPolicyId=None, nextRunTime=None, cron=None, refreshType=None, error=None)

  Bases: `abacusai.return_class.AbstractApiClass`

  A refresh schedule for an object. Defines when the next version of the object will be created

  Parameters:

    - client (ApiClient) – An authenticated API Client instance

    - refreshPolicyId (str) – The unique identifier of the refresh policy

    - nextRunTime (str) – The next run time of the refresh policy. If null, the policy is paused.

    - cron (str) – A cron-style string that describes the when this refresh policy is to be executed in UTC

    - refreshType (str) – The type of refresh that will be run

    - error (str) – An error message for the last pipeline run of a policy

  __repr__()

    Return repr(self).

  to_dict()

    Get a dict representation of the parameters in this class

    Returns:

      The dict value representation of the class parameters

    Return type:

      dict

class abacusai.prediction_operator.AbstractApiClass(client, id)
  __eq__(other)

    Return self==value.

  _get_attribute_as_dict(attribute)

class abacusai.prediction_operator.PredictionOperator(client, name=None, predictionOperatorId=None, createdAt=None, updatedAt=None, projectId=None, predictFunctionName=None, sourceCode=None, initializeFunctionName=None, notebookId=None, memory=None, useGpu=None, featureGroupIds=None, featureGroupTableNames=None, codeSource={}, refreshSchedules={}, latestPredictionOperatorVersion={})

  Bases: `abacusai.return_class.AbstractApiClass`

  A prediction operator.

  Parameters:

    - client (ApiClient) – An authenticated API Client instance

    - name (str) – The name for the prediction operator.

    - predictionOperatorId (str) – The unique identifier of the prediction operator.

    - createdAt (str) – Date and time at which the prediction operator was created.

    - updatedAt (str) – Date and time at which the prediction operator was updated.

    - projectId (str) – The project this prediction operator belongs to.

    - predictFunctionName (str) – Name of the function found in the source code that will be executed to run predictions.

    - sourceCode (str) – Python code used to make the prediction operator.

    - initializeFunctionName (str) – Name of the optional initialize function found in the source code. This function will generate anything used by predictions, based on input feature groups.

    - notebookId (str) – The unique string identifier of the notebook used to create or edit the prediction operator.

    - memory (int) – Memory in GB specified for the prediction operator.

    - useGpu (bool) – Whether this prediction operator is using gpu.

    - featureGroupIds (list) – A list of Feature Group IDs used for initializing.

    - featureGroupTableNames (list) – A list of Feature Group table names used for initializing.

    - codeSource (CodeSource) – If a python model, information on the source code.

    - latestPredictionOperatorVersion (PredictionOperatorVersion) – The unique string identifier of the latest version.

    - refreshSchedules (RefreshSchedule) – List of refresh schedules that indicate when the next prediction operator version will be processed

  __repr__()

    Return repr(self).

  to_dict()

    Get a dict representation of the parameters in this class

    Returns:

      The dict value representation of the class parameters

    Return type:

      dict

  refresh()

    Calls describe and refreshes the current object’s fields

    Returns:

      The current object

    Return type:

      PredictionOperator

  describe()

    Describe an existing prediction operator.

    Parameters:

      prediction_operator_id (str) – The unique ID of the prediction operator.

    Returns:

      The requested prediction operator object.

    Return type:

      PredictionOperator

  update(name=None, feature_group_ids=None, source_code=None, initialize_function_name=None, predict_function_name=None, cpu_size=None, memory=None, package_requirements=None, use_gpu=None)

    Update an existing prediction operator.

    Parameters:

      - name (str) – Name of the prediction operator.

      - feature_group_ids (List) – List of feature groups that are supplied to the initialize function as parameters. Each of the parameters are materialized Dataframes. The order should match the initialize function’s parameters.

      - source_code (str) – Contents of a valid Python source code file. The source code should contain the function predictFunctionName, and the function ‘initializeFunctionName’ if defined.

      - initialize_function_name (str) – Name of the optional initialize function found in the source code. This function will generate anything used by predictions, based on input feature groups.

      - predict_function_name (str) – Name of the function found in the source code that will be executed to run predictions.

      - cpu_size (str) – Size of the CPU for the prediction operator.

      - memory (int) – Memory (in GB) for the prediction operator.

      - package_requirements (list) – List of package requirement strings. For example: [‘numpy==1.2.3’, ‘pandas>=1.4.0’]

      - use_gpu (bool) – Whether this prediction operator needs gpu.

    Returns:

      The updated prediction operator object.

    Return type:

      PredictionOperator

  delete()

    Delete an existing prediction operator.

    Parameters:

      prediction_operator_id (str) – The unique ID of the prediction operator.

  deploy(auto_deploy=True)

    Deploy the prediction operator.

    Parameters:

      auto_deploy (bool) – Flag to enable the automatic deployment when a new prediction operator version is created.

    Returns:

      The created deployment object.

    Return type:

      Deployment

  create_version()

    Create a new version of the prediction operator.

    Parameters:

      prediction_operator_id (str) – The unique ID of the prediction operator.

    Returns:

      The created prediction operator version object.

    Return type:

      PredictionOperatorVersion

  list_versions()

    List all the prediction operator versions for a prediction operator.

    Parameters:

      prediction_operator_id (str) – The unique ID of the prediction operator.

    Returns:

      A list of prediction operator version objects.

    Return type:

      list[PredictionOperatorVersion]