core.internals.runner¶
Submodule of khiops.core.internals
Classes implementing Khiops Python’ backend runners
Functions¶
Returns the current KhiopsRunner of the module |
|
Sets the current KhiopsRunner of the module |
Classes¶
Implementation of a local Khiops runner |
|
Abstract Khiops Python runner to be re-implemented |
- class khiops.core.internals.runner.KhiopsLocalRunner¶
Bases:
KhiopsRunnerImplementation of a local Khiops runner
Requires either:
This package installed through Conda and run from a Conda environment, or
the
khiops-coreLinux native package installed on the local machine, orthe Windows Khiops desktop application installed on the local machine
Samples directory settings
Default values for the
samples_dirattribute:The value of the
KHIOPS_SAMPLES_DIRenvironment variable (path to the Khiops sample datasets directory).Otherwise:
Windows:
%PUBLIC%\khiops_data\samples%if it exists and is a directory%USERPROFILE%\khiops_data\samples%otherwise
Linux and macOS:
$HOME/khiops_data/samples
- property khiops_coclustering_path¶
str: Path to the
MODL_CoclusteringKhiops Coclustering binarySet by the
khiops_envscript from thekhiops-corepackage.
- property khiops_path¶
str: Path to the
MODL*Khiops binarySet by the
khiops_envscript from thekhiops-corepackage.
- raw_run(tool_name, command_line_args=None, use_mpi=True, trace=False)¶
Execute a Khiops tool with given command line arguments
- Parameters:
- tool_name{“khiops”, “khiops_coclustering”}
Name of the tool to execute.
- command_line_argslist of str, optional
Command line arguments of Khiops.
- use_mpibool, optional
Whether to execute the application with MPI
- tracebool, default False
If
Trueprint the trace of the process.
Examples
>>> raw_run("khiops", ["-b", "-i" , "scenario._kh"])
is equivalent to execute in a shell:
> khiops -b -i scenario._kh
- class khiops.core.internals.runner.KhiopsRunner¶
Bases:
ABCAbstract Khiops Python runner to be re-implemented
- create_temp_dir(prefix)¶
Creates a unique directory in the runner’s root temporary directory
- Parameters:
- prefixstr
Prefix for the directory’s name.
- Returns:
- str
A unique directory path within the root temporary directory. The directory is created only in the case of a local filesystem.
- create_temp_file(prefix, suffix)¶
Creates a unique temporary file in the runner’s root temporary directory
Note
For remote filesystems no actual file is created, just a (highly probable) unique path is returned.
- Parameters:
- prefixstr
Prefix for the file’s name.
- suffixstr
Suffix for the file’s name.
- Returns:
- str
A unique path within the root temporary directory. The file is created only in the case of a local filesystem.
- property khiops_version¶
KhiopsVersion: The version of the Khiops backend of this runner
- print_status()¶
Prints the status of the runner to stdout
- property root_temp_dir¶
str: The runner’s temporary directory
The temporary scenarios/templates and dictionary files created by the Khiops Python library are stored here.
- Default value:
Windows:
%TEMP%\khiops\pythonLinux:
$TMP/khiops/python
When set to a local path it tries to create the specified directory if it doesn’t exist.
- Raises:
KhiopsEnvironmentErrorIf set to a local path: if it is a file or if it does not have
+rwxpermissions.
- run(task, task_args, command_line_options=None, trace=False, system_settings=None, stdout_file_path='', stderr_file_path='', force_ansi_scenario=False, **kwargs)¶
Runs a Khiops Task
- Parameters:
- task
KhiopsTask Khiops task to be run.
- task_argsdict
Arguments for the task.
- command_line_options
CommandLineOptions, optional Command line options for all tasks. If not set the default values are used. See the
CommandLineOptionsfor more information.- tracebool, default
False If True prints the command line executed of the process and does not delete any temporary files created.
- system_settings
SystemSettings, optional Advanced: System settings for all tasks. See the
SystemSettingsclass for more information.- stdout_file_pathstr, default “”
Advanced Path to a file where the Khiops process writes its stdout stream. Normally Khiops should not write to this stream but MPI, filesystems plugins or debug versions may do it. The stream is captured with a UTF-8 encoding and replacing encoding errors. If equal to “” then it writes no file.
- stderr_file_pathstr, default “”
Advanced Path to a file where the Khiops process writes its stderr stream. Normally Khiops should not write to this stream but MPI, filesystems plugins or debug versions may do it. The stream is captured with a UTF-8 encoding and replacing encoding errors. If equal to “” then it writes no file.
- force_ansi_scenariobool, default
False Advanced: If True the internal scenario generated by Khiops will force characters such as accentuated ones to be decoded with the UTF8->ANSI khiops transformation.
- task
- Raises:
ValueErrorUnknown keyword argument
Files or executable not found
Errors in the execution of the Khiops tool
TypeErrorInvalid type of a keyword argument
When the search/replace pairs are not strings
- property samples_dir¶
str: Location of the Khiops’ sample datasets directory. May be an URL/URI
- khiops.core.internals.runner.get_runner()¶
Returns the current KhiopsRunner of the module
- Returns:
KhiopsRunnerThe current Khiops Python runner of the module.
- khiops.core.internals.runner.set_runner(runner)¶
Sets the current KhiopsRunner of the module