core.internals.task#

Submodule of khiops.core.internals

Core API functions abstractions

Functions#

encode_path_valued_arg

Encodes an argument containing paths (str or dict)

get_task_registry

Direct access to the registry

Classes#

KhiopsTask

Specification of a Khiops Task

KhiopsTaskFamily

Stores the versions of a task

KhiopsTaskRegistry

Registry of Khiops tasks

class khiops.core.internals.task.KhiopsTask(name, tool_name, intro_version, args_signature, kwargs_signature, path_valued_arg_names, scenario_template)#

Bases: object

Specification of a Khiops Task

Parameters:
namestr

Name of the task.

tool_namestr

Name of the tool to execute the task (ex. “khiops”, “khiops_coclustering”).

intro_versionKhiopsVersion or str

Khiops version where this task object was introduced.

args_signaturelist
A list of 2-tuples for each mandatory parameter of the task, containing:
kwargs_signaturelist
A list of 3-tuples for each optional parameter of the task, containing:
path_valued_arg_nameslist of str

A list of the parameters that contain paths. They must be contained either in args_signature or kwargs_signature. The only accepted types are StringLikeType or containers thereof.

scenario_templatestr

A Khiops scenario template. The template mini-language is described above.

Attributes:
scenarioConfigurableKhiopsScenario

Scenario object built from scenario_template.

write_execution_scenario(writer, args)#

Writes a task’s execution scenario file contents for the specified arguments

Parameters:
writerKhiopsOutputWriter

Writer object for the scenario file.

argsdict

Task arguments. Includes mandatory and optional arguments.

class khiops.core.internals.task.KhiopsTaskFamily(task_name, end_version=None)#

Bases: object

Stores the versions of a task

Parameters:
task_namestr

The name of the task defining this family.

end_versionstr or KhiopsVersion

The Khiops version where the support for this task ended.

property all_intro_versions#

list of KhiopsVersion : A sorted list of the task introduction versions.

The list is sorted in reverse order.

property end_version#

KhiopsVersion : Khiops version where support for this task ended

It is None if the task is still supported. May be set with either str or KhiopsVersion or None.

get_task(target_version)#

Returns latest task object compatible with the specified version

Parameters:
target_versionstr or KhiopsVersion

The target Khiops version.

Returns:
KhiopsTask

The latest task object compatible with the target_version.

Raises:
TypeError

If target_version is not str or KhiopsVersion.

property latest_intro_version#

KhiopsVersion : The latest introduction version of the task.

Raises:
ValueError

If there are no task objects registered in this family.

register_task(task, overwrite=False)#

Registers a task to this family

Parameters:
taskKhiopsTask

The task to be registered. Must have the same name of the family.

overwritebool, default False

If True it does not raise an error if a task with the same version is already registered.

Raises:
ValueError

If:

  • The task name is not the same as that of this family.

  • The specified version already exists and overwrite is not set.

property start_version#

KhiopsVersion : Khiops version where the support for this task started

Raises:
ValueError

If there are no task registered in this family.

unregister_task(intro_version)#

Unregister the task from the family with the specified introduction version

Parameters:
intro_versionstr

The introduction version of the task to be unregistered.

Returns:
KhiopsTask

The removed task object.

Raises:
ValueError

If there is no task with the specified introduction version.

class khiops.core.internals.task.KhiopsTaskRegistry#

Bases: object

Registry of Khiops tasks

Tasks are indexed by name and version.

get_task(task_name, target_version)#

Retrieves the latest task object for the specified task and version

Parameters:
task_namestr

The name of the task to be retrieved.

target_versionstr or KhiopsVersion

The target Khiops version.

Returns:
KhiopsTask

The latest task object for the specified task and version.

Raises:
ValueError

If there are no tasks registered with the specified name.

get_task_end_version(task_name)#

Returns the version where the support of the specified task ended

Parameters:
task_namestr

Name of the task.

Returns:
KhiopsVersion or None

Either the end version for this task or None if it is still supported.

Raises:
TypeError

If task_name is not of type str.

ValueError

If there are no registered tasks with the specified name.

get_tasks(target_version)#

Retrieves the latest Khiops tasks compatible with the specified version

Parameters:
target_versionstr or KhiopsVersion

The target Khiops version for the tasks to be retrieved.

Returns:
list of KhiopsTask

The list of compatible tasks with target_version.

property latest_intro_version#

KhiopsVersion : Latest introduction version overall tasks

set_task_end_version(task_name, end_version)#

Sets the version where the support of the specified task ended

Parameters:
task_namestr

Name of the task.

end_versionstr or KhiopsVersion

Version where the support of the specified task ended.

Raises:
TypeError
  • If task_name is not of type str.

  • If end_version is not of type str or KhiopsVersion.

ValueError

If there are no registered tasks with the specified name.

property task_names#

list of str: Names of all task families

khiops.core.internals.task.encode_path_valued_arg(arg, arg_name, arg_type)#

Encodes an argument containing paths (str or dict)

Parameters:
argstr or dict

The value of a path valued argument.

arg_namestr

The name of the argument.

arg_typeKhiopsTaskArgumentType

The type of the argument. Must be either StringLikeType or DictType StringLikeType , StringLikeType .

See also

encode_path_valued_arg

The underlying transformation function.

khiops.core.internals.task.get_task_registry()#

Direct access to the registry