Machine#
A gordo.machine.Machine is the central unity of a model, dataset, metadata and everything
needed to create and build a ML model.
- class gordo.machine.machine.Machine(name: str, model: dict, dataset: GordoBaseDataset, project_name: str, evaluation: dict | None = None, metadata: Metadata | None = None, runtime: dict | None = None)[source]#
Bases:
objectRepresents a single machine in a config file
- dataset#
Descriptor for attributes requiring type
gordo_core.time_series.TimeSeriesDataset
- classmethod from_config(config: dict[str, Any], project_name: str | None = None, config_globals: GlobalsConfig | None = None, back_compatibles: dict[tuple[Optional[str], str], tuple[Optional[str], str]] | None = None, default_data_provider: str | None = None)[source]#
Construct an instance from a block of YAML config file which represents a single Machine; loaded as a
dict.- Parameters:
config – The loaded block of config which represents a ‘Machine’ in YAML
project_name – Name of the project this Machine belongs to.
globals (config_globals The block of config within the YAML file within) –
back_compatibles – See gordo_core.import_utils.prepare_back_compatible_locations() function for reference.
default_data_provider –
- classmethod from_dict(d: ModelConfig, back_compatibles: dict[tuple[Optional[str], str], tuple[Optional[str], str]] | None = None, default_data_provider: str | None = None) Machine[source]#
Create A dict taken from either gordo config or
to_dict().
- host#
- 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'
- metadata#
Descriptor for attributes requiring type Optional[dict]
- model#
Descriptor for attributes requiring type Union[dict, str]
- name#
- 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'
- normalize_sensor_tags(tag_list: List[Dict | List | str | SensorTag]) List[SensorTag][source]#
Finding assets for all of the tags according to information from the dataset metadata
- Parameters:
tag_list –
- project_name#
- 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'
- report()[source]#
Run any reporters in the machine’s runtime for the current state.
Reporters implement the
gordo.reporters.base.BaseReporterand can be specified in a config file of the machine for example:runtime: reporters: - gordo.reporters.postgres.PostgresReporter: host: my-special-host
- runtime#
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.
- to_dict()[source]#
Convert to a
dictrepresentation along with all attributes which can also be converted to adict. Can reload withfrom_dict()
- class gordo.machine.encoders.MachineJSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]#
Bases:
JSONEncoderA JSONEncoder for machine objects, handling datetime.datetime objects as strings and
SensorTagas a dict representation of aMachineConstructor for JSONEncoder, with sensible defaults.
If skipkeys is false, then it is a TypeError to attempt encoding of keys that are not str, int, float or None. If skipkeys is True, such items are simply skipped.
If ensure_ascii is true, the output is guaranteed to be str objects with all incoming non-ASCII characters escaped. If ensure_ascii is false, the output can contain non-ASCII characters.
If check_circular is true, then lists, dicts, and custom encoded objects will be checked for circular references during encoding to prevent an infinite recursion (which would cause an RecursionError). Otherwise, no such check takes place.
If allow_nan is true, then NaN, Infinity, and -Infinity will be encoded as such. This behavior is not JSON specification compliant, but is consistent with most JavaScript based encoders and decoders. Otherwise, it will be a ValueError to encode such floats.
If sort_keys is true, then the output of dictionaries will be sorted by key; this is useful for regression tests to ensure that JSON serializations can be compared on a day-to-day basis.
If indent is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines. None is the most compact representation.
If specified, separators should be an (item_separator, key_separator) tuple. The default is (’, ‘, ‘: ‘) if indent is
Noneand (‘,’, ‘: ‘) otherwise. To get the most compact JSON representation, you should specify (‘,’, ‘:’) to eliminate whitespace.If specified, default is a function that gets called for objects that can’t otherwise be serialized. It should return a JSON encodable version of the object or raise a
TypeError.- default(obj: Any) Any[source]#
Implement this method in a subclass such that it returns a serializable object for
o, or calls the base implementation (to raise aTypeError).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- class gordo.machine.encoders.MachineSafeDumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True)[source]#
Bases:
SafeDumper- yaml_representers = {<class 'NoneType'>: <function SafeRepresenter.represent_none>, <class 'str'>: <function SafeRepresenter.represent_str>, <class 'bytes'>: <function SafeRepresenter.represent_binary>, <class 'bool'>: <function SafeRepresenter.represent_bool>, <class 'int'>: <function SafeRepresenter.represent_int>, <class 'float'>: <function SafeRepresenter.represent_float>, <class 'list'>: <function SafeRepresenter.represent_list>, <class 'tuple'>: <function SafeRepresenter.represent_list>, <class 'dict'>: <function SafeRepresenter.represent_dict>, <class 'set'>: <function SafeRepresenter.represent_set>, <class 'datetime.date'>: <function SafeRepresenter.represent_date>, <class 'datetime.datetime'>: <function _datetime_representer>, None: <function SafeRepresenter.represent_undefined>, <class 'gordo.machine.encoders.multiline_str'>: <function _multiline_str_representer>, <class 'gordo_core.sensor_tag.SensorTag'>: <function _sensor_tag_representer>}#