Skip to content

Commit

Permalink
ENG-4278 Complete the Cloud API
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-quintero committed Dec 20, 2023
1 parent 14e361c commit fe96810
Show file tree
Hide file tree
Showing 7 changed files with 912 additions and 69 deletions.
18 changes: 18 additions & 0 deletions nextmv/cloud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
"""Functionality for interacting with the Nextmv Cloud."""

from .acceptance_test import AcceptanceTest as AcceptanceTest
from .acceptance_test import AcceptanceTestParams as AcceptanceTestParams
from .acceptance_test import Comparison as Comparison
from .acceptance_test import ComparisonInstance as ComparisonInstance
from .acceptance_test import Metric as Metric
from .acceptance_test import MetricType as MetricType
from .application import Application as Application
from .application import DownloadURL as DownloadURL
from .application import ErrorLog as ErrorLog
from .application import Metadata as Metadata
from .application import PollingOptions as PollingOptions
from .application import RunInformation as RunInformation
from .application import RunResult as RunResult
from .application import UploadURL as UploadURL
from .batch_experiment import BatchExperiment as BatchExperiment
from .batch_experiment import BatchExperimentInformation as BatchExperimentInformation
from .batch_experiment import BatchExperimentMetadata as BatchExperimentMetadata
from .batch_experiment import BatchExperimentRun as BatchExperimentRun
from .client import Client as Client
from .input_set import InputSet as InputSet
90 changes: 90 additions & 0 deletions nextmv/cloud/acceptance_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
"""This module contains definitions for acceptance tests."""

from datetime import datetime
from enum import Enum

from nextmv.base_model import BaseModel


class MetricType(str, Enum):
"""Type of metric when doing a comparison."""

absolute_threshold = "absolute-threshold"
"""Absolute threshold metric type."""
difference_threshold = "difference-threshold"
"""Difference threshold metric type."""
direct_comparison = "direct-comparison"
"""Direct comparison metric type."""


class Comparison(str, Enum):
"""Comparison to use for two metrics."""

equal_to = "eq"
"""Equal to metric type."""
greater_than = "gt"
"""Greater than metric type."""
greater_than_or_equal_to = "ge"
"""Greater than or equal to metric type."""
less_than = "lt"
"""Less than metric type."""
less_than_or_equal_to = "le"
"""Less than or equal to metric type."""
not_equal_to = "ne"
"""Not equal to metric type."""


class AcceptanceTestParams(BaseModel):
"""Parameters of an acceptance test."""

operator: Comparison
"""Operator used to compare two metrics."""


class Metric(BaseModel):
"""A metric is a key performance indicator that is used to evaluate the
performance of a test."""

field: str
"""Field of the metric."""
metric_type: MetricType
"""Type of the metric."""
params: AcceptanceTestParams
"""Parameters of the metric."""
statistic: str
"""Statistic of the metric."""


class ComparisonInstance(BaseModel):
"""An instance used for a comparison."""

instance_id: str
"""ID of the instance."""
version_id: str
"""ID of the version."""


class AcceptanceTest(BaseModel):
"""An acceptance test gives a go/no-go decision criteria for a set of
metrics. It relies on a batch experiment."""

id: str
"""ID of the acceptance test."""
name: str
"""Name of the acceptance test."""
description: str
"""Description of the acceptance test."""
app_id: str
"""ID of the app that owns the acceptance test."""
experiment_id: str
"""ID of the batch experiment underlying in the acceptance test."""
control: ComparisonInstance
"""Control instance of the acceptance test."""
candidate: ComparisonInstance
"""Candidate instance of the acceptance test."""
metrics: list[Metric]
"""Metrics of the acceptance test."""
created_at: datetime
"""Creation date of the acceptance test."""
updated_at: datetime
"""Last update date of the acceptance test."""
Loading

0 comments on commit fe96810

Please sign in to comment.