Coverage for ocp_resources/trustyai_service.py: 0%
28 statements
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 10:48 +0200
« prev ^ index » next coverage.py v7.6.10, created at 2025-01-30 10:48 +0200
1from ocp_resources.resource import NamespacedResource, MissingRequiredArgumentError
2from typing import Optional, Any, Dict
5class TrustyAIService(NamespacedResource):
6 """
7 https://github.com/trustyai-explainability/trustyai-service-operator/blob/main/api/v1alpha1/trustyaiservice_types.go
8 """
10 api_group: str = NamespacedResource.ApiGroup.TRUSTYAI_OPENDATAHUB_IO
12 def __init__(
13 self,
14 storage: Optional[Dict[str, Any]] = None,
15 data: Optional[Dict[str, Any]] = None,
16 metrics: Optional[Dict[str, Any]] = None,
17 replicas: Optional[int] = None,
18 image: Optional[str] = None,
19 tag: Optional[str] = None,
20 **kwargs,
21 ) -> None:
22 """
23 TrustyAIService object
25 Args:
26 storage (Optional[Dic[str, Any]], mandatory if not passing yaml_file): TrustyAIService storage config (format, folder and size).
27 data (Optional[Dict[str, Any]], mandatory if not passing yaml_file): TrustyAIService data config (filename and format).
28 metrics (Optional[Dict[str, Any]], mandatory if not passing yaml_file): TrustyAIService metrics config.
29 replicas (Optional[int]): Number of replicas for the TrustyAIService.
30 image (Optional[str]): Pull url of the TrustyAIService.
31 tag (Optional[str]): Tag of the image.
32 """
33 super().__init__(**kwargs)
34 self.storage = storage
35 self.data = data
36 self.metrics = metrics
37 self.replicas = replicas
38 self.image = image
39 self.tag = tag
41 def to_dict(self) -> None:
42 super().to_dict()
44 if not self.kind_dict and not self.yaml_file:
45 if not (self.storage or self.data or self.metrics):
46 raise MissingRequiredArgumentError(argument="'storage' or 'data' or 'metrics'")
48 self.res["spec"] = {}
49 _spec = self.res["spec"]
51 _spec["storage"] = self.storage
52 _spec["data"] = self.data
53 _spec["metrics"] = self.metrics
55 if self.replicas:
56 _spec["replicas"] = self.replicas
58 if self.image:
59 _spec["image"] = self.image
61 if self.tag:
62 _spec["tag"] = self.tag