Task

The task entity represents the model training process. When users train a model, a task is created for that process, using a Dataset as the input for the model.

When creating a Task, set the training configuration (e.g. target metric, ensemble size), which will determine the way the model is trained.

One of the outputs of a Task is an Ensemble; a combination of one or more models optimized for the Dataset and configuration. In addition, it is possible to use Ensembles to perform predictions, as well as other purposes.

‘Task’ API includes creating a task and querying existing tasks (Get, List, Delete and Get configuration).

class fireflyai.resources.task.Task[source]
classmethod add_additional_time_to_completed_task(id: int, new_time_budget: int, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Add addition time to train completed_task.

Parameters:
  • id (int) – Task ID.
  • new_time_budget (int) – Time in seconds.
  • api_key (Optional[str]) – Explicit api_key, not required if fireflyai.authenticate was run prior.
Returns:

“submitted” if operation was successful, raises FireflyClientError otherwise.

Return type:

FireflyResponse

classmethod cancel_task(task_id: int, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Cancels a running task.

Parameters:
  • task_id (int) – Task ID.
  • api_key (Optional[str]) – Explicit api_key, not required if fireflyai.authenticate was run prior.
Returns:

“submitted” if operation was successful, raises FireflyClientError otherwise.

Return type:

FireflyResponse

classmethod create(name: str, dataset_id: int, estimators: List[fireflyai.enums.Estimator] = None, target_metric: fireflyai.enums.TargetMetric = None, splitting_strategy: fireflyai.enums.SplittingStrategy = None, notes: str = None, ensemble_size: int = None, max_models_num: int = None, single_model_timeout: int = None, pipeline: List[fireflyai.enums.Pipeline] = None, prediction_latency: int = None, interpretability_level: fireflyai.enums.InterpretabilityLevel = None, timeout: int = 7200, cost_matrix_weights: List[List[str]] = None, train_size: float = None, test_size: float = None, validation_size: float = None, fold_size: int = None, n_folds: int = None, horizon: int = None, validation_strategy: fireflyai.enums.ValidationStrategy = None, cv_strategy: fireflyai.enums.CVStrategy = None, forecast_horizon: int = None, model_life_time: int = None, refit_on_all: bool = None, wait: bool = False, skip_if_exists: bool = False, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Create and run a training task.

A task is responsible for searching for hyper-parameters that would maximize the model scores. The task constructs ensembles made of selected models. Seeking ways to combine different models allows us a smarter decision making.

Parameters:
  • name (str) – Task’s name.
  • dataset_id (int) – Dataset ID of the training data.
  • estimators (List[Estimator]) – Estimators to use in the train task.
  • target_metric (TargetMetric) – The target metric is the metric the model hyperparameter search process attempts to optimize.
  • splitting_strategy (SplittingStrategy) – Splitting strategy of the data.
  • notes (Optional[str]) – Notes of the task.
  • ensemble_size (Optional[int]) – Maximum number for models in ensemble.
  • max_models_num (Optional[int]) – Maximum number of models to train.
  • single_model_timeout (Optional[int]) – Maximum time for training one model.
  • pipeline (Optional[List[Pipeline]) – Possible pipeline steps.
  • prediction_latency (Optional[int]) – Maximum number of seconds ensemble prediction should take.
  • interpretability_level (Optional[InterpretabilityLevel]) – Determines how interpertable your ensemble is. Higher level of interpretability leads to more interpretable ensembles
  • timeout (Optional[int]) – timeout in seconds for the search process (default: 2 hours).
  • cost_matrix_weights (Optional[List[List[str]]]) – For classification and anomaly detection problems, the weights allow determining a custom cost metric, which assigns different weights to the entries of the confusion matrix.
  • train_size (Optional[int]) – The ratio of data taken for the train set of the model.
  • test_size (Optional[int]) – The ratio of data taken for the test set of the model.
  • validation_size (Optional[int]) – The ratio of data taken for the validation set of the model.
  • fold_size (Optional[int]) – Fold size where performing cross-validation splitting.s
  • n_folds (Optional[int]) – Number of folds when performing cross-validation splitting. validation_strategy (Optional[ValidationStrategy]): Validation strategy used for the train task.
  • cv_strategy (Optional[CVStrategy]) – Cross-validation strategy to use for the train task.
  • horizon (Optional[int]) – DEPRECATED. Please use forecast_horizon and model_life_time.
  • forecast_horizon (Optional[int]) – Something related to time-series models.
  • model_life_time (Optional[int]) – Something related to time-series models.
  • refit_on_all (Optional[bool]) – Determines if the final ensemble will be refit on all data after search process is done.
  • wait (Optional[bool]) – Should the call be synchronous or not.
  • skip_if_exists (Optional[bool]) – Check if a Datasource with same name exists and skip if true.
  • api_key (Optional[str]) – Explicit api_key, not required if fireflyai.authenticate was run prior.
Returns:

Task ID, if successful and wait=False or Task if successful and wait=True; raises FireflyError otherwise.

Return type:

FireflyResponse

classmethod delete(id: int, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Deletes a specific Task.

Parameters:
  • id (int) – Task ID.
  • api_key (Optional[str]) – Explicit api_key, not required, if fireflyai.authenticate() was run prior.
Returns:

“true” if deleted successfuly, raises FireflyClientError otherwise.

Return type:

FireflyResponse

classmethod edit_notes(id: int, notes: str, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Edits notes of the Task.

Parameters:
  • id (int) – Task ID.
  • notes (str) – New notes value.
  • api_key (Optional[str]) – Explicit api_key, not required if fireflyai.authenticate was run prior.
Returns:

task_id value if successful, raises FireflyError otherwise.

Return type:

FireflyResponse

classmethod get(id: int, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Get information on a specific Task.

Information includes the state of the Task and other attributes.

Parameters:
  • id (int) – Task ID.
  • api_key (Optional[str]) – Explicit api_key, not required if fireflyai.authenticate was run prior.
Returns:

Information about the Task.

Return type:

FireflyResponse

classmethod get_by_name(name: str, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Gets information on a specific Task identified by its name.

Information includes the state of the Task and other attributes. Similar to calling fireflyai.Task.list(filters_={‘name’: [NAME]}).

Parameters:
  • name (str) – Task name.
  • api_key (Optional[str]) – Explicit api_key, not required if fireflyai.authenticate was run prior.
Returns:

Information about the Task.

Return type:

FireflyResponse

classmethod get_task_progress(id: int, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Lists existing Ensembles` scores.

Get the Ensembles’ scores produced thus far by the task. Enables you to track the progress of the task.

Parameters:
  • id (int) – Task ID.
  • api_key (Optional[str]) – Explicit api_key, not required if fireflyai.authenticate was run prior.
Returns:

List of all the Task’s Ensembles’ scores.

Return type:

FireflyResponse

classmethod get_task_result(id: int, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Gets full results of the Task.

Parameters:
  • id (int) – Task ID.
  • api_key (Optional[str]) – Explicit api_key, not required if fireflyai.authenticate was run prior.
Returns:

Task’s full results.

Return type:

FireflyResponse

classmethod list(search_term: str = None, page: int = None, page_size: int = None, sort: Dict[KT, VT] = None, filter_: Dict[KT, VT] = None, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

List the existing Tasks - supports filtering, sorting and pagination.

Parameters:
  • search_term (Optional[str]) – Return only records that contain the search_term in any field.
  • page (Optional[int]) – For pagination, which page to return.
  • page_size (Optional[int]) – For pagination, how many records will appear in a single page.
  • sort (Optional[Dict[str, Union[str, int]]]) – Dictionary of rules to sort the results by.
  • filter (Optional[Dict[str, Union[str, int]]]) – Dictionary of rules to filter the results by.
  • api_key (Optional[str]) – Explicit api_key, not required, if fireflyai.authenticate() was run prior.
Returns:

Tasks are represented as nested dictionaries under hits.

Return type:

FireflyResponse

classmethod pause_task(task_id: int, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Pauses a running task.

Parameters:
  • task_id (int) – Task ID.
  • api_key (Optional[str]) – Explicit api_key, not required if fireflyai.authenticate was run prior.
Returns:

“submitted” if operation was successful, raises FireflyClientError otherwise.

Return type:

FireflyResponse

classmethod refit(id: int, datasource_id: int, wait: bool = False, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Refits the chosen Ensemble of a Task on a specific Datasource.

A refit trains the chosen Ensemble’s models with the data of the given Datasource. The model training is done from scratch and uses all the given data. A new Ensemble is created that is made of all the refitted models of the chosen Ensemble and their original combination.

Parameters:
  • id (int) – Task ID.
  • datasource_id (int) – Datasource ID.
  • wait (Optional[bool]) – Should the call be synchronous or not.
  • api_key (Optional[str]) – Explicit api_key, not required if fireflyai.authenticate was run prior.
Returns:

Ensemble ID, if successful and wait=False or Ensemble if successful and wait=True; raises FireflyError otherwise.

Return type:

FireflyResponse

classmethod rerun_task(task_id: int, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Reruns a task that has been completed or stopped.

Parameters:
  • task_id (int) – Task ID.
  • api_key (Optional[str]) – Explicit api_key, not required if fireflyai.authenticate was run prior.
Returns:

“submitted” if operation was successful, raises FireflyClientError otherwise.

Return type:

FireflyResponse

classmethod resume_task(task_id: int, api_key: str = None) → fireflyai.firefly_response.FireflyResponse[source]

Resumes a paused task.

Parameters:
  • task_id (int) – Task ID.
  • api_key (Optional[str]) – Explicit api_key, not required if fireflyai.authenticate was run prior.
Returns:

“submitted” if operation was successful, raises FireflyClientError otherwise.

Return type:

FireflyResponse