core.internals.task¶
Submodule of khiops.core.internals
Core API functions abstractions
Functions¶
Encodes an argument containing paths (str or dict) |
|
Direct access to the registry |
Classes¶
Specification of a Khiops Task |
|
Stores the versions of a task |
|
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_version
KhiopsVersion
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:
its name (str)
its type (
KhiopsTaskArgumentType
)
- kwargs_signaturelist
- A list of 3-tuples for each optional parameter of the task, containing:
its name (str)
its type (
KhiopsTaskArgumentType
)its default value
- 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:
- scenario
ConfigurableKhiopsScenario
Scenario object built from
scenario_template
.
- scenario
- write_execution_scenario(writer, args)¶
Writes a task’s execution scenario file contents for the specified arguments
- Parameters:
- writer
KhiopsOutputWriter
Writer object for the scenario file.
- argsdict
Task arguments. Includes mandatory and optional arguments.
- writer
- 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 endedIt is
None
if the task is still supported. May be set with either str orKhiopsVersion
orNone
.
- get_task(target_version)¶
Returns latest task object compatible with the specified version
- Parameters:
- target_versionstr or
KhiopsVersion
The target Khiops version.
- target_versionstr or
- 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:
- task
KhiopsTask
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.
- task
- 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
orNone
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.
- target_versionstr or
- Returns:
- list of
KhiopsTask
The list of compatible tasks with
target_version
.
- list of
- 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 orKhiopsVersion
.
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_type
KhiopsTaskArgumentType
The type of the argument. Must be either
StringLikeType
orDictType
StringLikeType
,StringLikeType
.
See also
encode_path_valued_arg
The underlying transformation function.
- khiops.core.internals.task.get_task_registry()¶
Direct access to the registry