Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
- Example: 10.2.1.4 is the 5th version that supports khiops 10.2.1.
- Internals: Changes in *Internals* sections are unlikely to be of interest for data scientists.

## Unreleased

### Fixed
- (`core`) Fix a RuntimeException error when automatically correcting deprecated data paths in task args

## 11.0.1.0 - 2026-07-02

### Added
Expand Down
17 changes: 11 additions & 6 deletions khiops/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def _preprocess_arguments(args):

.. note:: This function *mutates* the input `args` dictionary.
"""
# Execute the preprocess of common task arguments
# Execute the preprocessing of common task arguments
task_is_called_with_domain = _preprocess_task_arguments(args)

# Create a command line options object
Expand Down Expand Up @@ -222,6 +222,9 @@ def _deprecate_legacy_data_path(data_path_task_arg_name, task_args):
"""Detect and replace legacy data path with the current syntax

.. note:: The function mutates task_args.
.. note:: A similar logic is repeated in `DictionaryDomain`
but cannot be factored out in a simple way
because no `DictionaryDomain` object is built here
"""
if (
data_path_task_arg_name in task_args
Expand All @@ -233,7 +236,9 @@ def _deprecate_legacy_data_path(data_path_task_arg_name, task_args):
else:
current_dictionary_name = task_args["train_dictionary_name"]

for kdic_path in task_args[data_path_task_arg_name].keys():
# Iterate through the keys of a clone to avoid any error
# while modifying the dict in-place
for kdic_path in task_args[data_path_task_arg_name].copy().keys():
if isinstance(kdic_path, str):
deprecated_data_path_separator = "`"
data_path_separator = "/"
Expand All @@ -255,7 +260,7 @@ def _deprecate_legacy_data_path(data_path_task_arg_name, task_args):
source_dictionary_name = kdic_path_parts[0]
if source_dictionary_name == current_dictionary_name:
# Escape any "/" char in the path parts except for the
# current dictionary, which is is skipped from the new path
# current dictionary, which is skipped from the new path
new_kdic_path_parts = []
for kdic_path_part in kdic_path_parts[1:]:
new_kdic_path_parts.append(
Expand All @@ -273,7 +278,7 @@ def _deprecate_legacy_data_path(data_path_task_arg_name, task_args):
deprecation_message(
"'`'-based dictionary data path: "
f"'{kdic_path_for_warning}'",
"11.0.1",
"11.1.0",
replacement=(
"'/'-based dictionary data path "
f"convention: '{new_kdic_path}'"
Expand Down Expand Up @@ -317,7 +322,7 @@ def _preprocess_task_arguments(task_args):
warnings.warn(
deprecation_message(
"'results_dir'",
"11.0.1",
"11.1.0",
replacement=file_path_arg_name,
quote=False,
)
Expand Down Expand Up @@ -1935,7 +1940,7 @@ def simplify_coclustering(
warnings.warn(
deprecation_message(
results_dir,
"11.0.1",
"11.1.0",
replacement="simplified_coclustering_file_path",
quote=False,
)
Expand Down
2 changes: 1 addition & 1 deletion khiops/core/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def get_dictionary_at_data_path(self, data_path):
warnings.warn(
deprecation_message(
"'`'-based dictionary data path convention",
"11.0.1",
"11.1.0",
replacement="'/'-based dictionary data path convention",
quote=False,
)
Expand Down
2 changes: 1 addition & 1 deletion khiops/sklearn/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def _init_tables_from_mapping(self, X):
warnings.warn(
deprecation_message(
"This multi-table dataset specification format",
"11.0.1",
"11.1.0",
replacement=(
"the new data-path-based format, as documented in "
":doc:`multi_table_primer`."
Expand Down
34 changes: 34 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import khiops.core as kh
import khiops.core.internals.filesystems as fs
from khiops.core import KhiopsRuntimeError
from khiops.core.api import _deprecate_legacy_data_path
from khiops.core.internals.io import KhiopsOutputWriter
from khiops.core.internals.runner import KhiopsLocalRunner, KhiopsRunner
from khiops.core.internals.scenario import ConfigurableKhiopsScenario
Expand Down Expand Up @@ -2569,6 +2570,39 @@ def test_dictionary_get_dictionary_at_legacy_data_path_deprecation(self):
domain.get_dictionary_at_data_path(data_path),
)

def test_deprecated_legacy_data_path_in_task_args(self):
"""Tests the automatic correction of deprecated data paths in task args"""
data_path_task_arg_name = "additional_data_tables"
task_args = {
"dictionary_name": "SpliceJunction",
"additional_data_tables": {"SpliceJunction`DNA": "SpliceJunctionDNA.txt"},
}
with warnings.catch_warnings(record=True) as warning_list:
_deprecate_legacy_data_path(data_path_task_arg_name, task_args)
self.assertTrue(len(warning_list) > 0)
deprecation_warning_found = False
for warning in warning_list:
warning_message = warning.message
if (
issubclass(warning.category, UserWarning)
and len(warning_message.args) == 1
and "'`'-based dictionary data path" in warning_message.args[0]
and "deprecated" in warning_message.args[0]
):
deprecation_warning_found = True
break
self.assertTrue(deprecation_warning_found)
self.assertNotIn(
"SpliceJunction`DNA",
task_args["additional_data_tables"],
"Deprecated data path should have been removed",
)
self.assertEqual(
{"DNA": "SpliceJunctionDNA.txt"},
task_args["additional_data_tables"],
"Deprecated data path should have been corrected",
)


class ScenarioWriterRunner(KhiopsRunner):
"""A khiops runner that only generates scenarios to a specific subdirectory"""
Expand Down
Loading