additory 0.1.0a4__py3-none-any.whl → 0.1.1a1__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.
- additory/__init__.py +58 -14
- additory/common/__init__.py +31 -147
- additory/common/column_selector.py +255 -0
- additory/common/distributions.py +286 -613
- additory/common/extractors.py +313 -0
- additory/common/knn_imputation.py +332 -0
- additory/common/result.py +380 -0
- additory/common/strategy_parser.py +243 -0
- additory/common/unit_conversions.py +338 -0
- additory/common/validation.py +283 -103
- additory/core/__init__.py +34 -22
- additory/core/backend.py +258 -0
- additory/core/config.py +177 -305
- additory/core/logging.py +230 -24
- additory/core/memory_manager.py +157 -495
- additory/expressions/__init__.py +2 -23
- additory/expressions/compiler.py +457 -0
- additory/expressions/engine.py +264 -487
- additory/expressions/integrity.py +179 -0
- additory/expressions/loader.py +263 -0
- additory/expressions/parser.py +363 -167
- additory/expressions/resolver.py +274 -0
- additory/functions/__init__.py +1 -0
- additory/functions/analyze/__init__.py +144 -0
- additory/functions/analyze/cardinality.py +58 -0
- additory/functions/analyze/correlations.py +66 -0
- additory/functions/analyze/distributions.py +53 -0
- additory/functions/analyze/duplicates.py +49 -0
- additory/functions/analyze/features.py +61 -0
- additory/functions/analyze/imputation.py +66 -0
- additory/functions/analyze/outliers.py +65 -0
- additory/functions/analyze/patterns.py +65 -0
- additory/functions/analyze/presets.py +72 -0
- additory/functions/analyze/quality.py +59 -0
- additory/functions/analyze/timeseries.py +53 -0
- additory/functions/analyze/types.py +45 -0
- additory/functions/expressions/__init__.py +161 -0
- additory/functions/snapshot/__init__.py +82 -0
- additory/functions/snapshot/filter.py +119 -0
- additory/functions/synthetic/__init__.py +113 -0
- additory/functions/synthetic/mode_detector.py +47 -0
- additory/functions/synthetic/strategies/__init__.py +1 -0
- additory/functions/synthetic/strategies/advanced.py +35 -0
- additory/functions/synthetic/strategies/augmentative.py +160 -0
- additory/functions/synthetic/strategies/generative.py +168 -0
- additory/functions/synthetic/strategies/presets.py +116 -0
- additory/functions/to/__init__.py +188 -0
- additory/functions/to/lookup.py +351 -0
- additory/functions/to/merge.py +189 -0
- additory/functions/to/sort.py +91 -0
- additory/functions/to/summarize.py +170 -0
- additory/functions/transform/__init__.py +140 -0
- additory/functions/transform/datetime.py +79 -0
- additory/functions/transform/extract.py +85 -0
- additory/functions/transform/harmonize.py +105 -0
- additory/functions/transform/knn.py +62 -0
- additory/functions/transform/onehotencoding.py +68 -0
- additory/functions/transform/transpose.py +42 -0
- additory-0.1.1a1.dist-info/METADATA +83 -0
- additory-0.1.1a1.dist-info/RECORD +62 -0
- additory/analysis/__init__.py +0 -48
- additory/analysis/cardinality.py +0 -126
- additory/analysis/correlations.py +0 -124
- additory/analysis/distributions.py +0 -376
- additory/analysis/quality.py +0 -158
- additory/analysis/scan.py +0 -400
- additory/common/backend.py +0 -371
- additory/common/column_utils.py +0 -191
- additory/common/exceptions.py +0 -62
- additory/common/lists.py +0 -229
- additory/common/patterns.py +0 -240
- additory/common/resolver.py +0 -567
- additory/common/sample_data.py +0 -182
- additory/core/ast_builder.py +0 -165
- additory/core/backends/__init__.py +0 -23
- additory/core/backends/arrow_bridge.py +0 -483
- additory/core/backends/cudf_bridge.py +0 -355
- additory/core/column_positioning.py +0 -358
- additory/core/compiler_polars.py +0 -166
- additory/core/enhanced_cache_manager.py +0 -1119
- additory/core/enhanced_matchers.py +0 -473
- additory/core/enhanced_version_manager.py +0 -325
- additory/core/executor.py +0 -59
- additory/core/integrity_manager.py +0 -477
- additory/core/loader.py +0 -190
- additory/core/namespace_manager.py +0 -657
- additory/core/parser.py +0 -176
- additory/core/polars_expression_engine.py +0 -601
- additory/core/registry.py +0 -177
- additory/core/sample_data_manager.py +0 -492
- additory/core/user_namespace.py +0 -751
- additory/core/validator.py +0 -27
- additory/dynamic_api.py +0 -352
- additory/expressions/proxy.py +0 -549
- additory/expressions/registry.py +0 -313
- additory/expressions/samples.py +0 -492
- additory/synthetic/__init__.py +0 -13
- additory/synthetic/column_name_resolver.py +0 -149
- additory/synthetic/deduce.py +0 -259
- additory/synthetic/distributions.py +0 -22
- additory/synthetic/forecast.py +0 -1132
- additory/synthetic/linked_list_parser.py +0 -415
- additory/synthetic/namespace_lookup.py +0 -129
- additory/synthetic/smote.py +0 -320
- additory/synthetic/strategies.py +0 -926
- additory/synthetic/synthesizer.py +0 -713
- additory/utilities/__init__.py +0 -53
- additory/utilities/encoding.py +0 -600
- additory/utilities/games.py +0 -300
- additory/utilities/keys.py +0 -8
- additory/utilities/lookup.py +0 -103
- additory/utilities/matchers.py +0 -216
- additory/utilities/resolvers.py +0 -286
- additory/utilities/settings.py +0 -167
- additory/utilities/units.py +0 -749
- additory/utilities/validators.py +0 -153
- additory-0.1.0a4.dist-info/METADATA +0 -311
- additory-0.1.0a4.dist-info/RECORD +0 -72
- additory-0.1.0a4.dist-info/licenses/LICENSE +0 -21
- {additory-0.1.0a4.dist-info → additory-0.1.1a1.dist-info}/WHEEL +0 -0
- {additory-0.1.0a4.dist-info → additory-0.1.1a1.dist-info}/top_level.txt +0 -0
additory/core/parser.py
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
# parser.py
|
|
2
|
-
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
from typing import Dict, Optional, List, Any
|
|
5
|
-
|
|
6
|
-
import yaml
|
|
7
|
-
|
|
8
|
-
from .logging import log_info, log_warning
|
|
9
|
-
from .ast_builder import build_ast_from_expression # <-- NEW: your AST builder
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
# ------------------------------------------------------------
|
|
13
|
-
# Parsed Expression Structure
|
|
14
|
-
# ------------------------------------------------------------
|
|
15
|
-
|
|
16
|
-
@dataclass
|
|
17
|
-
class ParsedExpression:
|
|
18
|
-
name: str
|
|
19
|
-
metadata: Dict[str, Any]
|
|
20
|
-
expression: str
|
|
21
|
-
raw_text: str
|
|
22
|
-
ast: Optional[Dict[str, Any]] = None # <-- NEW
|
|
23
|
-
sample_clean: Optional[Dict[str, List[Any]]] = None
|
|
24
|
-
sample_unclean: Optional[Dict[str, List[Any]]] = None
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
# ------------------------------------------------------------
|
|
28
|
-
# Public API
|
|
29
|
-
# ------------------------------------------------------------
|
|
30
|
-
|
|
31
|
-
def parse_expression(text: str) -> ParsedExpression:
|
|
32
|
-
"""
|
|
33
|
-
Parses a .add expression file.
|
|
34
|
-
Supports two formats:
|
|
35
|
-
1. YAML-style (new)
|
|
36
|
-
2. Legacy metadata + expression block (old)
|
|
37
|
-
"""
|
|
38
|
-
|
|
39
|
-
if not text.strip():
|
|
40
|
-
log_warning("[parser] Empty expression file")
|
|
41
|
-
return ParsedExpression(
|
|
42
|
-
name="unknown",
|
|
43
|
-
metadata={},
|
|
44
|
-
expression="",
|
|
45
|
-
raw_text=text,
|
|
46
|
-
ast=None,
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
# Detect YAML-style format
|
|
50
|
-
if _looks_like_yaml(text):
|
|
51
|
-
parsed = _parse_yaml_style(text)
|
|
52
|
-
else:
|
|
53
|
-
parsed = _parse_legacy_style(text)
|
|
54
|
-
|
|
55
|
-
# --------------------------------------------------------
|
|
56
|
-
# NEW: Build AST from parsed.expression
|
|
57
|
-
# --------------------------------------------------------
|
|
58
|
-
try:
|
|
59
|
-
parsed.ast = build_ast_from_expression(parsed.expression)
|
|
60
|
-
except Exception as e:
|
|
61
|
-
log_warning(f"[parser] Failed to build AST: {e}")
|
|
62
|
-
parsed.ast = None
|
|
63
|
-
|
|
64
|
-
return parsed
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
# ------------------------------------------------------------
|
|
68
|
-
# YAML-STYLE PARSER
|
|
69
|
-
# ------------------------------------------------------------
|
|
70
|
-
|
|
71
|
-
def _looks_like_yaml(text: str) -> bool:
|
|
72
|
-
lowered = text.lower()
|
|
73
|
-
return ("formula:" in lowered) or ("sample:" in lowered)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def _parse_yaml_style(text: str) -> ParsedExpression:
|
|
77
|
-
try:
|
|
78
|
-
parsed = yaml.safe_load(text)
|
|
79
|
-
except Exception as e:
|
|
80
|
-
log_warning(f"[parser] YAML parse failed, falling back to legacy: {e}")
|
|
81
|
-
return _parse_legacy_style(text)
|
|
82
|
-
|
|
83
|
-
formula = parsed.get("formula", {})
|
|
84
|
-
sample = parsed.get("sample", {})
|
|
85
|
-
expression_block = formula.get("expression")
|
|
86
|
-
|
|
87
|
-
if not expression_block:
|
|
88
|
-
log_warning("[parser] YAML file missing 'formula.expression' block")
|
|
89
|
-
expression_block = ""
|
|
90
|
-
|
|
91
|
-
name = formula.get("name", "unknown")
|
|
92
|
-
|
|
93
|
-
return ParsedExpression(
|
|
94
|
-
name=name,
|
|
95
|
-
metadata=formula,
|
|
96
|
-
expression=_normalize_expression(expression_block),
|
|
97
|
-
raw_text=text,
|
|
98
|
-
sample_clean=sample.get("clean"),
|
|
99
|
-
sample_unclean=sample.get("unclean"),
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def _normalize_expression(expr):
|
|
104
|
-
if isinstance(expr, list):
|
|
105
|
-
return "\n".join(expr)
|
|
106
|
-
return str(expr).strip()
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
# ------------------------------------------------------------
|
|
110
|
-
# LEGACY PARSER
|
|
111
|
-
# ------------------------------------------------------------
|
|
112
|
-
|
|
113
|
-
def _parse_legacy_style(text: str) -> ParsedExpression:
|
|
114
|
-
lines = _preprocess(text)
|
|
115
|
-
metadata = _parse_metadata(lines)
|
|
116
|
-
expression = _parse_expression_block(lines)
|
|
117
|
-
|
|
118
|
-
name = metadata.get("name", "unknown")
|
|
119
|
-
|
|
120
|
-
return ParsedExpression(
|
|
121
|
-
name=name,
|
|
122
|
-
metadata=metadata,
|
|
123
|
-
expression=expression,
|
|
124
|
-
raw_text=text,
|
|
125
|
-
)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
# ------------------------------------------------------------
|
|
129
|
-
# Internal Helpers
|
|
130
|
-
# ------------------------------------------------------------
|
|
131
|
-
|
|
132
|
-
def _preprocess(text: str) -> List[str]:
|
|
133
|
-
cleaned = []
|
|
134
|
-
for line in text.splitlines():
|
|
135
|
-
stripped = line.strip()
|
|
136
|
-
if not stripped:
|
|
137
|
-
continue
|
|
138
|
-
if stripped.startswith("#"):
|
|
139
|
-
continue
|
|
140
|
-
cleaned.append(stripped)
|
|
141
|
-
return cleaned
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
def _parse_metadata(lines: List[str]) -> Dict[str, str]:
|
|
145
|
-
metadata = {}
|
|
146
|
-
|
|
147
|
-
for line in lines:
|
|
148
|
-
if line.lower().startswith("expression:"):
|
|
149
|
-
break
|
|
150
|
-
|
|
151
|
-
if ":" not in line:
|
|
152
|
-
log_warning(f"[parser] Invalid metadata line: {line}")
|
|
153
|
-
continue
|
|
154
|
-
|
|
155
|
-
key, value = line.split(":", 1)
|
|
156
|
-
metadata[key.strip()] = value.strip()
|
|
157
|
-
|
|
158
|
-
return metadata
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
def _parse_expression_block(lines: List[str]) -> str:
|
|
162
|
-
expr_lines = []
|
|
163
|
-
in_expr = False
|
|
164
|
-
|
|
165
|
-
for line in lines:
|
|
166
|
-
if line.lower().startswith("expression:"):
|
|
167
|
-
in_expr = True
|
|
168
|
-
continue
|
|
169
|
-
|
|
170
|
-
if in_expr:
|
|
171
|
-
expr_lines.append(line)
|
|
172
|
-
|
|
173
|
-
if not expr_lines:
|
|
174
|
-
log_warning("[parser] No expression block found")
|
|
175
|
-
|
|
176
|
-
return "\n".join(expr_lines).strip()
|