idmtools.core.task_factory module#

Define our tasks factory. This is crucial to build tasks when fetching from the server.

Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.

class idmtools.core.task_factory.DynamicTaskSpecification(task_type: Type[ITask], description: str = '')[source]#

Bases: TaskSpecification

This class allows users to quickly define a spec for special tasks.

__init__(task_type: Type[ITask], description: str = '')[source]#

Initialize our specification.

Parameters:
  • task_type – Task type to register

  • description – Description to register with task

get(configuration: dict) ITask[source]#

Get an instance of our task using configuration.

Parameters:

configuration – Configuration keyword args.

Returns:

Task with configuration specified

get_description() str[source]#

Get description of our plugin.

Returns:

Returns the user-defined plugin description.

get_type() Type[ITask][source]#

Get our task type.

Returns:

Returns our task type

class idmtools.core.task_factory.TaskFactory[source]#

Bases: object

TaskFactory allows creation of tasks that are derived from plugins.

DEFAULT_KEY = 'idmtools.entities.command_task.CommandTask'#
__init__()[source]#

Initialize our Factory.

register(spec: TaskSpecification) NoReturn[source]#

Register a TaskSpecification dynamically.

Parameters:

spec – Specification to register

Returns:

None

register_task(task: Type[ITask]) NoReturn[source]#

Dynamically register a class using the DynamicTaskSpecification.

Parameters:

task – Task to register

Returns:

None

create(key, fallback=None, **kwargs) ITask[source]#

Create a task of type key.

Parameters:
  • key – Type of task to create

  • fallback – Fallback task type. Default to DEFAULT_KEY if not provided

  • **kwargs – Optional arguments to pass to the task

Returns:

Task with option specified