Skip to main content
Version: 1.0

aixplain.factories.metric_factory

__author__

Copyright 2022 The aiXplain SDK authors

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Author: Duraikrishna Selvaraju, Thiago Castro Ferreira, Shreyas Sharma and Lucas Pavanelli Date: December 1st 2022 Description: Metric Factory Class

MetricFactory Objects

class MetricFactory()

[view_source]

A static factory class for creating and managing Metric objects.

This class provides functionality to create, retrieve, and list Metric objects through the backend API. It includes methods for fetching individual metrics by ID and listing metrics with various filtering options.

Attributes:

  • backend_url str - The URL endpoint for the backend API.

get

@classmethod
def get(cls, metric_id: Text, api_key: str = None) -> Metric

[view_source]

Create a Metric object from a metric ID.

Arguments:

  • metric_id Text - The unique identifier of the metric to retrieve.
  • api_key str, optional - API key for authentication. Defaults to None.

Returns:

  • Metric - The retrieved Metric object.

Raises:

  • Exception - If the metric creation fails, with status code and error message.

list

@classmethod
def list(cls,
model_id: Text = None,
is_source_required: Optional[bool] = None,
is_reference_required: Optional[bool] = None,
page_number: int = 0,
page_size: int = 20,
api_key: str = None) -> List[Metric]

[view_source]

Get a list of supported metrics based on the given filters.

Arguments:

  • model_id Text, optional - ID of model for which metric is to be used. Defaults to None.
  • is_source_required bool, optional - Should the metric use source. Defaults to None.
  • is_reference_required bool, optional - Should the metric use reference. Defaults to None.
  • page_number int, optional - page number. Defaults to 0.
  • page_size int, optional - page size. Defaults to 20.
  • api_key str, optional - API key for authentication. Defaults to None.

Returns:

  • Dict - A dictionary containing:
    • results (List[Metric]): List of filtered metrics
    • page_total (int): Number of items in the current page
    • page_number (int): Current page number
    • total (int): Total number of items matching the filters

Raises:

  • Exception - If there is an error retrieving the metrics list.