-
class
MMARTensorboardHandler
Bases:
automl.components.handlers.handler.Handler
Logs to Tensorboard each recommendation for an automl run along with the run ID so it can be kept track of.
-
start_automl
(ctx: automl.defs.Context) Update Tensorboard with new job id and recommendation at beginning of the beginning of job. Note: in the configuration for config_automl, this needs to be after MMARHandler in order to have RUN_ROOT :param ctx: job context
-
start_job
(ctx: automl.defs.Context) At the beginning of each individual job, log the job’s recommendation information to Tensorboard :param ctx: job context
-
-
class
Handler
Bases:
object
This class defines the abstract behavior required of a Handler.
A handler is an object that listens to certain AutoML workflow events and takes actions on such events.
-
end_automl
(ctx: automl.defs.Context) AUTOML process has ended. Called from the engine thread. :param ctx: the main context
Returns:
-
end_job
(ctx: automl.defs.Context) The job execution has ended. Called from the job thread. See notes in start_job method. You can check the job status from prop ContextKey.JOB_STATUS in the ctx.
NOTE: if the start_job is called, it is guaranteed that end_job will be called.
- Parameters
ctx – the job context
Returns:
-
handle_event
(event: str, ctx: automl.defs.Context) The default event handler that calls a predefined method for each event type.
- Parameters
event – event to be handled
ctx – context for cross-component data sharing
Returns:
-
recommendations_available
(ctx: automl.defs.Context) The recommendations are available. Called from the main thread. You can get recommendations from prop ContextKey.RECOMMENDATIONS in the ctx.
- Parameters
ctx – main context
Returns:
-
search_space_available
(ctx: automl.defs.Context) The search space is available. Called from the main thread. You can get the search space from prop ContextKey.SEARCH_SPACE in the ctx.
- Parameters
ctx – main context
Returns:
-
shutdown
(ctx: automl.defs.Context) The handler is being shutdown. Use this method to clean up the handler.
NOTE: this method is called in the reverse order of handler chain. If your handler depends on other handlers, your handler will be shutdown before the handlers you depend on.
- Parameters
ctx –
Returns:
-
start_automl
(ctx: automl.defs.Context) AUTOML process is about to start. Called from the engine thread.
- Parameters
ctx – the main context
Returns:
-
start_job
(ctx: automl.defs.Context) The job execution is about to start. Called from the job thread.
NOTE: this method could be called from multiple job threads at the same time. If you want to store across-job state data in the handler, you should ensure thread safety when updating such state data.
NOTE: the ctx is a per-job context, hence it is not subject to multi-thread access. Consider using the ctx to store per-job state data.
- Parameters
ctx – the job context
Returns:
-
startup
(ctx: automl.defs.Context) The handler is being started up. Use this method to initialize the handler based on info in the context.
NOTE: this method is called in the order of handler chain. If your handler depends on some info provided by previous handlers, you can get such info from the ctx.
- Parameters
ctx – main context
Returns:
-
-
fire_event
(event: str, handlers: list, ctx: automl.defs.Context) Fires the specified event and invokes the list of handlers.
- Parameters
event – the event to be fired
handlers – handlers to be invoked
ctx – context for cross-component data sharing
Returns:
-
class
MMARStatsHandler
(stats_file_name='automl_stats_log.json') Bases:
automl.components.handlers.handler.Handler
Defines a stats handler that writes to a json file the search space and recommendations as well as the job stats after each job is finished.
If a new set of recommendations is made available, a new file will be written to for each set of recommendations as a workaround for now to avoid overwriting the recommendations in the original json.
- Parameters
stats_file_name – string of file to write output of json stats to, relative to this run’s root directory
-
end_job
(ctx: automl.defs.Context) Update json stats with stats of the round after each round is completed
- Parameters
ctx – job context
-
recommendations_available
(ctx: automl.defs.Context) Update stats json with recommendations :param ctx: job context
-
search_space_available
(ctx: automl.defs.Context) Initialize file to write to, and write out search space to it
- Parameters
ctx – job context
-
class
npEncoder
(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None) Bases:
json.encoder.JSONEncoder
Constructor 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 OverflowError). 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
None
and (‘,’, ‘: ‘) 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
(o) 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
StatsHandler
Bases:
automl.components.handlers.handler.Handler
Defines a simple stats handler that collects job execution stats.
For each worker, it computes things like the number of jobs started, number of jobs finished and unfinished, and total amount of time the worker worked. It also shows the total amount of time used by the whole workflow.
-
end_automl
(ctx: automl.defs.Context) Print worker stats and overall stats
- Parameters
ctx – main context
Returns:
-
end_job
(ctx: automl.defs.Context) Update job stats of the worker
- Parameters
ctx – job context
Returns:
-
start_automl
(ctx: automl.defs.Context) Record the start time of AutoML
- Parameters
ctx – AutoML main context
Returns:
-
start_job
(ctx: automl.defs.Context) Record the start time of the job in ctx; count total number of jobs started
- Parameters
ctx – job context
Returns:
-
-
class
WorkerStats
Bases:
object
Define a simple stats structure for workers: only keep job count and total work time of a worker