automl.components.handlers package
- 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 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