Descriptors¶
Collection of descriptors to verify types and conditions of the Machine attributes when loading.
And example of which is if the machine name is set to a value which isn’t
a valid URL string, thus causing early failure before k8s itself discovers that the
name isn’t valid. (See: gordo.machine.validators.ValidUrlString
)
-
class
gordo.machine.validators.
BaseDescriptor
[source]¶ Bases:
object
Base descriptor class
New object should override __set__(self, instance, value) method to check if ‘value’ meets required needs.
-
class
gordo.machine.validators.
ValidDataProvider
[source]¶ Bases:
gordo.machine.validators.BaseDescriptor
Descriptor for DataProvider
-
class
gordo.machine.validators.
ValidDataset
[source]¶ Bases:
gordo.machine.validators.BaseDescriptor
Descriptor for attributes requiring type
gordo.workflow.config_elements.Dataset
-
class
gordo.machine.validators.
ValidDatasetKwargs
[source]¶ Bases:
gordo.machine.validators.BaseDescriptor
Descriptor for attributes requiring type
gordo.workflow.config_elements.Dataset
-
class
gordo.machine.validators.
ValidDatetime
[source]¶ Bases:
gordo.machine.validators.BaseDescriptor
Descriptor for attributes requiring valid datetime.datetime attribute
-
class
gordo.machine.validators.
ValidMachineRuntime
[source]¶ Bases:
gordo.machine.validators.BaseDescriptor
Descriptor for runtime dict in a machine object. Must be a valid runtime, but also must contain server.resources.limits/requests.memory/cpu to be valid.
-
class
gordo.machine.validators.
ValidMetadata
[source]¶ Bases:
gordo.machine.validators.BaseDescriptor
Descriptor for attributes requiring type Optional[dict]
-
class
gordo.machine.validators.
ValidModel
[source]¶ Bases:
gordo.machine.validators.BaseDescriptor
Descriptor for attributes requiring type Union[dict, str]
-
class
gordo.machine.validators.
ValidTagList
[source]¶ Bases:
gordo.machine.validators.BaseDescriptor
Descriptor for attributes requiring a non-empty list of strings
-
class
gordo.machine.validators.
ValidUrlString
[source]¶ Bases:
gordo.machine.validators.BaseDescriptor
Descriptor for use in objects which require valid URL values. Where ‘valid URL values’ is Gordo’s version: alphanumeric with dashes.
Use:
class MySpecialClass: url_attribute = ValidUrlString() ... myspecialclass = MySpecialClass() myspecialclass.url_attribute = 'this-is-ok' myspecialclass.url_attribute = 'this will r@ise a ValueError'
-
gordo.machine.validators.
fix_resource_limits
(resources: dict) → dict[source]¶ Resource limitations must be higher or equal to resource requests, if they are both specified. This bumps any limits to the corresponding request if they are both set.
- Parameters
resources (dict) – Dictionary with possible requests/limits
Examples
>>> fix_resource_limits({"requests": {"cpu": 10}, "limits":{"cpu":9}}) {'requests': {'cpu': 10}, 'limits': {'cpu': 10}} >>> fix_resource_limits({"requests": {"cpu": 10}}) {'requests': {'cpu': 10}}
- Returns
A copy of resource_dict with the any limits bumped to the corresponding request if they are both set.
- Return type
dict