data-designer 0.3.7__py3-none-any.whl → 0.3.8rc1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data_designer/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '0.3.7'
32
- __version_tuple__ = version_tuple = (0, 3, 7)
31
+ __version__ = version = '0.3.8rc1'
32
+ __version_tuple__ = version_tuple = (0, 3, 8, 'rc1')
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -55,6 +55,9 @@ class ColumnGeneratorWithModelChatCompletion(ColumnGeneratorWithModel[TaskConfig
55
55
  )
56
56
 
57
57
  def generate(self, data: dict) -> dict:
58
+ # Deserialize input data from previous columns so Jinja2 templates can access nested fields
59
+ # Example: If prev column stored '{"key": "value"}', templates can use {{ prev_column.key }}
60
+ # Note: This creates a new dict and doesn't mutate the original `data` argument
58
61
  deserialized_record = deserialize_json_values(data)
59
62
 
60
63
  multi_modal_context = None
@@ -81,13 +84,18 @@ class ColumnGeneratorWithModelChatCompletion(ColumnGeneratorWithModel[TaskConfig
81
84
  purpose=f"running generation for column '{self.config.name}'",
82
85
  )
83
86
 
84
- data[self.config.name] = deserialize_json_values(self.response_recipe.serialize_output(response))
87
+ serialized_output = self.response_recipe.serialize_output(response)
88
+ data[self.config.name] = self._process_serialized_output(serialized_output)
85
89
 
86
90
  if reasoning_trace:
87
91
  data[self.config.name + REASONING_TRACE_COLUMN_POSTFIX] = reasoning_trace
88
92
 
89
93
  return data
90
94
 
95
+ def _process_serialized_output(self, serialized_output: str) -> str | dict | list:
96
+ """Process the serialized output from the model. Subclasses can override to customize deserialization."""
97
+ return serialized_output
98
+
91
99
 
92
100
  class LLMTextCellGenerator(ColumnGeneratorWithModelChatCompletion[LLMTextColumnConfig]): ...
93
101
 
@@ -95,7 +103,11 @@ class LLMTextCellGenerator(ColumnGeneratorWithModelChatCompletion[LLMTextColumnC
95
103
  class LLMCodeCellGenerator(ColumnGeneratorWithModelChatCompletion[LLMCodeColumnConfig]): ...
96
104
 
97
105
 
98
- class LLMStructuredCellGenerator(ColumnGeneratorWithModelChatCompletion[LLMStructuredColumnConfig]): ...
106
+ class LLMStructuredCellGenerator(ColumnGeneratorWithModelChatCompletion[LLMStructuredColumnConfig]):
107
+ def _process_serialized_output(self, serialized_output: str) -> dict | list:
108
+ return deserialize_json_values(serialized_output)
99
109
 
100
110
 
101
- class LLMJudgeCellGenerator(ColumnGeneratorWithModelChatCompletion[LLMJudgeColumnConfig]): ...
111
+ class LLMJudgeCellGenerator(ColumnGeneratorWithModelChatCompletion[LLMJudgeColumnConfig]):
112
+ def _process_serialized_output(self, serialized_output: str) -> dict | list:
113
+ return deserialize_json_values(serialized_output)
@@ -5,9 +5,10 @@ from __future__ import annotations
5
5
 
6
6
  import logging
7
7
 
8
- from data_designer.config.column_configs import SeedDatasetColumnConfig
8
+ from data_designer.config.column_configs import SamplerColumnConfig, SeedDatasetColumnConfig
9
9
  from data_designer.config.data_designer_config import DataDesignerConfig
10
10
  from data_designer.config.errors import InvalidConfigError
11
+ from data_designer.config.sampler_params import UUIDSamplerParams
11
12
  from data_designer.engine.resources.resource_provider import ResourceProvider
12
13
  from data_designer.engine.resources.seed_reader import SeedReader
13
14
  from data_designer.engine.validation import ViolationLevel, rich_print_violations, validate_data_designer_config
@@ -17,6 +18,7 @@ logger = logging.getLogger(__name__)
17
18
 
18
19
  def compile_data_designer_config(config: DataDesignerConfig, resource_provider: ResourceProvider) -> DataDesignerConfig:
19
20
  _resolve_and_add_seed_columns(config, resource_provider.seed_reader)
21
+ _add_internal_row_id_column_if_needed(config)
20
22
  _validate(config)
21
23
  return config
22
24
 
@@ -41,6 +43,35 @@ def _resolve_and_add_seed_columns(config: DataDesignerConfig, seed_reader: SeedR
41
43
  config.columns.extend([SeedDatasetColumnConfig(name=col_name) for col_name in seed_col_names])
42
44
 
43
45
 
46
+ def _add_internal_row_id_column_if_needed(config: DataDesignerConfig) -> None:
47
+ """Adds a UUID sampler column named '_internal_row_id' (set to drop) if needed to enable generation.
48
+
49
+ Generation requires either:
50
+ - At least one sampler column (which can generate data from scratch), OR
51
+ - A seed dataset (which provides initial data rows)
52
+
53
+ If neither exists, a UUID sampler column '_internal_row_id' is automatically added and marked for drop
54
+ to enable the generation process to start.
55
+
56
+ Args:
57
+ config: The DataDesigner configuration to potentially modify.
58
+ """
59
+ has_sampler_column = any(isinstance(col, SamplerColumnConfig) for col in config.columns)
60
+ has_seed_dataset_column = any(isinstance(col, SeedDatasetColumnConfig) for col in config.columns)
61
+
62
+ if not has_sampler_column and not has_seed_dataset_column:
63
+ logger.warning(
64
+ "🔔 No sampler column or seed dataset detected. Adding UUID column '_internal_row_id' (marked for drop) to enable generation."
65
+ )
66
+ id_column = SamplerColumnConfig(
67
+ name="_internal_row_id",
68
+ sampler_type="uuid",
69
+ params=UUIDSamplerParams(),
70
+ drop=True,
71
+ )
72
+ config.columns.insert(0, id_column)
73
+
74
+
44
75
  def _validate(config: DataDesignerConfig) -> None:
45
76
  allowed_references = _get_allowed_references(config)
46
77
  violations = validate_data_designer_config(
@@ -4,6 +4,7 @@
4
4
  from __future__ import annotations
5
5
 
6
6
  import ast
7
+ import copy
7
8
  import json
8
9
  import logging
9
10
  import re
@@ -50,6 +51,8 @@ def deserialize_json_values(data: T) -> T: ...
50
51
  def deserialize_json_values(data):
51
52
  """De-serialize JSON strings in various input formats.
52
53
 
54
+ This function creates a deep copy of the input data and does not mutate the original.
55
+
53
56
  Args:
54
57
  data: Input data in one of four formats:
55
58
  - Single string (JSON string to deserialize)
@@ -63,18 +66,22 @@ def deserialize_json_values(data):
63
66
  - List of dictionaries (when input is a list of strings)
64
67
  - Dictionary (when input is a dictionary, with nested JSON strings deserialized)
65
68
  - The original object (if there is no deserialization to perform)
69
+
66
70
  """
71
+ # Create a deep copy to avoid mutating the original data
72
+ data_copy = copy.deepcopy(data)
73
+
67
74
  # Case 1: Single string input
68
- if isinstance(data, str):
75
+ if isinstance(data_copy, str):
69
76
  try:
70
- return json.loads(data)
77
+ return json.loads(data_copy)
71
78
  except json.JSONDecodeError:
72
- return data
79
+ return data_copy
73
80
 
74
81
  # Case 2: List of strings input
75
- elif isinstance(data, list):
82
+ elif isinstance(data_copy, list):
76
83
  result = []
77
- for item in data:
84
+ for item in data_copy:
78
85
  if isinstance(item, str):
79
86
  try:
80
87
  result.append(json.loads(item))
@@ -86,9 +93,9 @@ def deserialize_json_values(data):
86
93
  return result
87
94
 
88
95
  # Case 3: Dictionary input with potential nested JSON strings
89
- elif isinstance(data, dict):
96
+ elif isinstance(data_copy, dict):
90
97
  result = {}
91
- for key, value in data.items():
98
+ for key, value in data_copy.items():
92
99
  if isinstance(value, str):
93
100
  try:
94
101
  result[key] = json.loads(value)
@@ -103,7 +110,7 @@ def deserialize_json_values(data):
103
110
 
104
111
  # Fallback for other data types
105
112
  else:
106
- return data
113
+ return data_copy
107
114
 
108
115
 
109
116
  def parse_list_string(text: str) -> list[str]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: data-designer
3
- Version: 0.3.7
3
+ Version: 0.3.8rc1
4
4
  Summary: General framework for synthetic data generation
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -1,5 +1,5 @@
1
1
  data_designer/__init__.py,sha256=iLr6FpW41-DFbGexuXCJ6gN1xBMNUZ2jfj9XxySmQhk,502
2
- data_designer/_version.py,sha256=CszCydqJjxQ_CbTrTy0L1k2j2gCfwJlahui0bCcdNp4,704
2
+ data_designer/_version.py,sha256=NQlgQnitduzFb4wWkqWxIRTi5E5gw_xAEogbRRBMSzA,714
3
3
  data_designer/errors.py,sha256=r1pBvmvRBAsPmb7oF_veubhkxZ2uPo9cGEDwykLziX4,220
4
4
  data_designer/lazy_heavy_imports.py,sha256=wULSEPQRUOZXvOnb0tdf6wNbRBpaaczYfAjY-pstCBM,1512
5
5
  data_designer/logging.py,sha256=gRi9BOqm95UC1-u4pn6n-G4EySy9HhwKVyKLRO4aqm4,5382
@@ -72,7 +72,7 @@ data_designer/config/utils/numerical_helpers.py,sha256=DIubKzc8q2_Bw7xRjyOGwxYul
72
72
  data_designer/config/utils/type_helpers.py,sha256=XyVup24F4Bl7uNze_yUW9oD6EzFbfsJWKhpeMN2901A,4059
73
73
  data_designer/config/utils/visualization.py,sha256=_0Mn-jva0Oz1tVTQH1mnWSARpqZ2kh1JSzJEuikyy9s,18491
74
74
  data_designer/engine/__init__.py,sha256=XLO09Ei8g0lU7hYlzKCvhvQhLFBe5CBwE4v2PqK9xWY,142
75
- data_designer/engine/compiler.py,sha256=4a6ayCQjpULrGU2CXaBMDs-RU0TszT2oEkMK-vn51zk,2757
75
+ data_designer/engine/compiler.py,sha256=4QAeCJjINtH0afSXygdhiKMyq2KIfaDthK3ApZLgrQ0,4152
76
76
  data_designer/engine/configurable_task.py,sha256=6R4FPXPzIeK0lqNVSEXzRDtK14B3dFz38lplr-nkvRE,2539
77
77
  data_designer/engine/errors.py,sha256=YXI7ny83BQ16sOK43CpTm384hJTKuZkPTEAjlHlDIfA,1303
78
78
  data_designer/engine/model_provider.py,sha256=_uU5Bw7yrGlMROjHL4dN1mMTg1eN-LVW5JWcQxovhAA,2823
@@ -92,7 +92,7 @@ data_designer/engine/column_generators/generators/__init__.py,sha256=XLO09Ei8g0l
92
92
  data_designer/engine/column_generators/generators/base.py,sha256=QElk5KsaUQ3EYwlv40NcZgQsw3HIkX3YQV_0S3erl7Q,4209
93
93
  data_designer/engine/column_generators/generators/embedding.py,sha256=uB0jgHlCgctgIUf9ZfMqG1YThbJ0g-GCX3VdNbdDSko,1407
94
94
  data_designer/engine/column_generators/generators/expression.py,sha256=BiQcfVTinvQl3OI9nkdhB9B7FGBueWiHJwxTA8uNVuY,2330
95
- data_designer/engine/column_generators/generators/llm_completion.py,sha256=TGVCV0Sp2AI5KwJ7lG9Co7-zF6gVy-vmVg9eEKmiazE,3873
95
+ data_designer/engine/column_generators/generators/llm_completion.py,sha256=3S3ikNLLLGnutUdcuswL5dUfcLgT_-he8DiRZ9K706U,4721
96
96
  data_designer/engine/column_generators/generators/samplers.py,sha256=gNzURmu9K8Zb5MHamKvZPIxmWlFgl2W4FIVgaFcy4f0,3371
97
97
  data_designer/engine/column_generators/generators/seed_dataset.py,sha256=CoQPbz4Ww7pBLaGw8-CYqIk1sjfkBaoRMKZQexdfgKY,6824
98
98
  data_designer/engine/column_generators/generators/validation.py,sha256=YfYbk-8_ZUye0No6_Q7hIqpZv_tunnEZ6HkLSMFXlDE,6659
@@ -127,7 +127,7 @@ data_designer/engine/models/parsers/tag_parsers.py,sha256=HNAIBfXW1Wjdkw4IX-P9sH
127
127
  data_designer/engine/models/parsers/types.py,sha256=wEt80al1FykbMplZVjJ5uXFtacMx-a9GE4_QoqDJ6Us,2631
128
128
  data_designer/engine/models/recipes/base.py,sha256=AQg3Ay_E0hBEVg-sqSNVVZNMJfJ3r1eT14-b9yqymnQ,2630
129
129
  data_designer/engine/models/recipes/response_recipes.py,sha256=UX9m-8RTDj3sXkzEdKpkSj5z7jO-fQhdca3MSByb_Js,10189
130
- data_designer/engine/processing/utils.py,sha256=iu7JJ4foI3Gfd29ppIBGn9c0syO64PTyvW9CiaLVAHE,5201
130
+ data_designer/engine/processing/utils.py,sha256=g82KsdDR20g_isadpmgHnneQSX0W21aCVhkp5TIWEhw,5443
131
131
  data_designer/engine/processing/ginja/__init__.py,sha256=XLO09Ei8g0lU7hYlzKCvhvQhLFBe5CBwE4v2PqK9xWY,142
132
132
  data_designer/engine/processing/ginja/ast.py,sha256=w62yt434RDnJYrcfofIDThGv0C5H9XJE3VHOnxEzJVM,1964
133
133
  data_designer/engine/processing/ginja/environment.py,sha256=wJRbzPuUCQGvCi4zS4g8sYzihgu_6fn-tE_nYSL1AoU,18974
@@ -189,8 +189,8 @@ data_designer/plugins/registry.py,sha256=Cnt33Q25o9bS2v2YDbV3QPM57VNrtIBKAb4ERQR
189
189
  data_designer/plugins/testing/__init__.py,sha256=yyxrrH_i3q0Xb56QO9Ma35WtHlQ5PJF1b2pQoKa16xU,296
190
190
  data_designer/plugins/testing/stubs.py,sha256=9tUF209ayZR6f0Q1LsRDW4kEOTgPoIxV8jlq4QoWuW0,3498
191
191
  data_designer/plugins/testing/utils.py,sha256=a9LEgK827cnIzHEkgXOdgywrKDLBE36cyttrpG1ctT4,973
192
- data_designer-0.3.7.dist-info/METADATA,sha256=-Ibzqy6fzBp72fF6Xo99QdJG1Urz1tysoWf00226uIU,8119
193
- data_designer-0.3.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
194
- data_designer-0.3.7.dist-info/entry_points.txt,sha256=NWWWidyDxN6CYX6y664PhBYMhbaYTQTyprqfYAgkyCg,57
195
- data_designer-0.3.7.dist-info/licenses/LICENSE,sha256=cSWJDwVqHyQgly8Zmt3pqXJ2eQbZVYwN9qd0NMssxXY,11336
196
- data_designer-0.3.7.dist-info/RECORD,,
192
+ data_designer-0.3.8rc1.dist-info/METADATA,sha256=YrRgO4uKxDznFADcGj2TqIucRNvbYIGk5_4R9Pqq2Qc,8122
193
+ data_designer-0.3.8rc1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
194
+ data_designer-0.3.8rc1.dist-info/entry_points.txt,sha256=NWWWidyDxN6CYX6y664PhBYMhbaYTQTyprqfYAgkyCg,57
195
+ data_designer-0.3.8rc1.dist-info/licenses/LICENSE,sha256=cSWJDwVqHyQgly8Zmt3pqXJ2eQbZVYwN9qd0NMssxXY,11336
196
+ data_designer-0.3.8rc1.dist-info/RECORD,,