|
10 | 10 |
|
11 | 11 | from .compat import BaseModel |
12 | 12 | from .output_targets import FilePathTarget, UCSchemaTarget |
| 13 | +from .validation import ValidationResult |
13 | 14 |
|
14 | 15 |
|
15 | 16 | logger = logging.getLogger(__name__) |
@@ -41,71 +42,6 @@ class TableDefinition(BaseModel): |
41 | 42 | columns: list[ColumnDefinition] |
42 | 43 |
|
43 | 44 |
|
44 | | -class ValidationResult: |
45 | | - """Container for validation results that collects errors and warnings during spec validation. |
46 | | -
|
47 | | - This class accumulates validation issues found while checking a DatagenSpec configuration. |
48 | | - It distinguishes between errors (which prevent data generation) and warnings (which |
49 | | - indicate potential issues but don't block generation). |
50 | | -
|
51 | | - .. note:: |
52 | | - Validation passes if there are no errors, even if warnings are present |
53 | | - """ |
54 | | - |
55 | | - def __init__(self) -> None: |
56 | | - """Initialize an empty ValidationResult with no errors or warnings.""" |
57 | | - self.errors: list[str] = [] |
58 | | - self.warnings: list[str] = [] |
59 | | - |
60 | | - def add_error(self, message: str) -> None: |
61 | | - """Add an error message to the validation results. |
62 | | -
|
63 | | - Errors indicate critical issues that will prevent successful data generation. |
64 | | -
|
65 | | - :param message: Descriptive error message explaining the validation failure |
66 | | - """ |
67 | | - self.errors.append(message) |
68 | | - |
69 | | - def add_warning(self, message: str) -> None: |
70 | | - """Add a warning message to the validation results. |
71 | | -
|
72 | | - Warnings indicate potential issues or non-optimal configurations that may affect |
73 | | - data generation but won't prevent it from completing. |
74 | | -
|
75 | | - :param message: Descriptive warning message explaining the potential issue |
76 | | - """ |
77 | | - self.warnings.append(message) |
78 | | - |
79 | | - def is_valid(self) -> bool: |
80 | | - """Check if validation passed without errors. |
81 | | -
|
82 | | - :returns: True if there are no errors (warnings are allowed), False otherwise |
83 | | - """ |
84 | | - return len(self.errors) == 0 |
85 | | - |
86 | | - def __str__(self) -> str: |
87 | | - """Generate a formatted string representation of all validation results. |
88 | | -
|
89 | | - :returns: Multi-line string containing formatted errors and warnings with counts |
90 | | - """ |
91 | | - lines = [] |
92 | | - if self.is_valid(): |
93 | | - lines.append("✓ Validation passed successfully") |
94 | | - else: |
95 | | - lines.append("✗ Validation failed") |
96 | | - |
97 | | - if self.errors: |
98 | | - lines.append(f"\nErrors ({len(self.errors)}):") |
99 | | - for i, error in enumerate(self.errors, 1): |
100 | | - lines.append(f" {i}. {error}") |
101 | | - |
102 | | - if self.warnings: |
103 | | - lines.append(f"\nWarnings ({len(self.warnings)}):") |
104 | | - for i, warning in enumerate(self.warnings, 1): |
105 | | - lines.append(f" {i}. {warning}") |
106 | | - |
107 | | - return "\n".join(lines) |
108 | | - |
109 | 45 | class DatagenSpec(BaseModel): |
110 | 46 | """Top-level specification for synthetic data generation across one or more tables. |
111 | 47 |
|
|
0 commit comments