Validators#
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:
objectBase 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:
BaseDescriptorDescriptor for DataProvider
- class gordo.machine.validators.ValidDataset[source]#
Bases:
BaseDescriptorDescriptor for attributes requiring type
gordo_core.time_series.TimeSeriesDataset
- class gordo.machine.validators.ValidDatasetKwargs[source]#
Bases:
BaseDescriptorDescriptor for attributes requiring type
gordo_core.time_series.TimeSeriesDataset
- class gordo.machine.validators.ValidDatetime[source]#
Bases:
BaseDescriptorDescriptor for attributes requiring valid datetime.datetime attribute
- class gordo.machine.validators.ValidMachineRuntime[source]#
Bases:
BaseDescriptorDescriptor 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:
BaseDescriptorDescriptor for attributes requiring type Optional[dict]
- class gordo.machine.validators.ValidModel[source]#
Bases:
BaseDescriptorDescriptor for attributes requiring type Union[dict, str]
- class gordo.machine.validators.ValidTagList[source]#
Bases:
BaseDescriptorDescriptor for attributes requiring a non-empty list of strings
- class gordo.machine.validators.ValidUrlString[source]#
Bases:
BaseDescriptorDescriptor 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 – 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_dictwith the any limits bumped to the corresponding request ifthey are both set.