View on GitHub

skelebot

Machine Learning Project Development Tool

Home > API


Skelebot API

Version 2


SkeleYaml Module

The SkeleYaml module holds the class required for creating objects with the ability to be converted to and from YAML formatted Dicts for the sake of reading and persisting data to yaml format.


SkeleYaml (Class)

Import

from skelebot.objects.component import Activation

The SkeleYaml class is intended to be used as a Parent Class for any object that needs to be written to the skelebot.yaml file. As such, the Component class is also a child of the SkeleYaml class. This means that each Component is capable of having it’s attributes written into and read from the skelebot.yaml by default.

The ability to override the toDict method provides more flexibility for Plugin developers to augment their Components with further customization.

Attributes

NAME TYPE DESCRIPTION
schema Schema The Schema definition for the object’s attributes such that the Dict data can be validated prior to being loaded

load(cls, config)

return cls()

PARAMETER TYPE DESCRIPTION
config Dict The Dictionary representation of the skelebot.yaml data to be loaded into the object
The purpose of the `load` method is to instantiate a new instance of the class object based on the
Dict config data provided to the method. This data is loaded by Skelebot from the skelebot.yaml
from the corresponding component section of the yaml file.

The default logic of this function will allow for a simple object with non-object type attributes
to be loaded automatically. Unless there are objects within your SkeleYaml object, or some special
logic that is needed at load time, this method can be left to it's default implementation.

If this method is overridden, it must return the instantiated class object (`cls()`).

loadList(cls, config)

return cls()

PARAMETER TYPE DESCRIPTION
config List A List of Dictionary representations of the skelebot.yaml data to be loaded into a list of objects
The loadList is a convenience method that simply invokes the load method of the class in a loop
for each element in the config provided and returns a list of instantiated class objects.

validate(cls, config)

return cls()

PARAMETER TYPE DESCRIPTION
config Dict The Dictionary representation of the skelebot.yaml data to be validated prior to loading
The validate method utilizes the skeleYaml's schema attribute to perform validation on the provided
Dictionary config data prior to the data being loaded into the object.

This is called from the default implementation of the load method, and should always be invoked
prior to loading a SkeleYaml object.

toDict(self)

return Dict

The toDict method will convert the Child object into a Dict based on the names and values of it's
attributes.

The default implementation of this method will handle simple objects without any additional need
for custom logic. If your object requires specific conversion logic in order to match a certain
format for YAML output, this method can be overridden or augmented by retaining a 'super' call back
to the parent method.

This method must return a Dict such that it can be written as a YAML formatted file.