additory 0.1.0a3__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.
Files changed (120) hide show
  1. additory/__init__.py +58 -14
  2. additory/common/__init__.py +31 -147
  3. additory/common/column_selector.py +255 -0
  4. additory/common/distributions.py +286 -613
  5. additory/common/extractors.py +313 -0
  6. additory/common/knn_imputation.py +332 -0
  7. additory/common/result.py +380 -0
  8. additory/common/strategy_parser.py +243 -0
  9. additory/common/unit_conversions.py +338 -0
  10. additory/common/validation.py +283 -103
  11. additory/core/__init__.py +34 -22
  12. additory/core/backend.py +258 -0
  13. additory/core/config.py +177 -305
  14. additory/core/logging.py +230 -24
  15. additory/core/memory_manager.py +157 -495
  16. additory/expressions/__init__.py +2 -23
  17. additory/expressions/compiler.py +457 -0
  18. additory/expressions/engine.py +264 -487
  19. additory/expressions/integrity.py +179 -0
  20. additory/expressions/loader.py +263 -0
  21. additory/expressions/parser.py +363 -167
  22. additory/expressions/resolver.py +274 -0
  23. additory/functions/__init__.py +1 -0
  24. additory/functions/analyze/__init__.py +144 -0
  25. additory/functions/analyze/cardinality.py +58 -0
  26. additory/functions/analyze/correlations.py +66 -0
  27. additory/functions/analyze/distributions.py +53 -0
  28. additory/functions/analyze/duplicates.py +49 -0
  29. additory/functions/analyze/features.py +61 -0
  30. additory/functions/analyze/imputation.py +66 -0
  31. additory/functions/analyze/outliers.py +65 -0
  32. additory/functions/analyze/patterns.py +65 -0
  33. additory/functions/analyze/presets.py +72 -0
  34. additory/functions/analyze/quality.py +59 -0
  35. additory/functions/analyze/timeseries.py +53 -0
  36. additory/functions/analyze/types.py +45 -0
  37. additory/functions/expressions/__init__.py +161 -0
  38. additory/functions/snapshot/__init__.py +82 -0
  39. additory/functions/snapshot/filter.py +119 -0
  40. additory/functions/synthetic/__init__.py +113 -0
  41. additory/functions/synthetic/mode_detector.py +47 -0
  42. additory/functions/synthetic/strategies/__init__.py +1 -0
  43. additory/functions/synthetic/strategies/advanced.py +35 -0
  44. additory/functions/synthetic/strategies/augmentative.py +160 -0
  45. additory/functions/synthetic/strategies/generative.py +168 -0
  46. additory/functions/synthetic/strategies/presets.py +116 -0
  47. additory/functions/to/__init__.py +188 -0
  48. additory/functions/to/lookup.py +351 -0
  49. additory/functions/to/merge.py +189 -0
  50. additory/functions/to/sort.py +91 -0
  51. additory/functions/to/summarize.py +170 -0
  52. additory/functions/transform/__init__.py +140 -0
  53. additory/functions/transform/datetime.py +79 -0
  54. additory/functions/transform/extract.py +85 -0
  55. additory/functions/transform/harmonize.py +105 -0
  56. additory/functions/transform/knn.py +62 -0
  57. additory/functions/transform/onehotencoding.py +68 -0
  58. additory/functions/transform/transpose.py +42 -0
  59. additory-0.1.1a1.dist-info/METADATA +83 -0
  60. additory-0.1.1a1.dist-info/RECORD +62 -0
  61. additory/analysis/__init__.py +0 -48
  62. additory/analysis/cardinality.py +0 -126
  63. additory/analysis/correlations.py +0 -124
  64. additory/analysis/distributions.py +0 -376
  65. additory/analysis/quality.py +0 -158
  66. additory/analysis/scan.py +0 -400
  67. additory/common/backend.py +0 -371
  68. additory/common/column_utils.py +0 -191
  69. additory/common/exceptions.py +0 -62
  70. additory/common/lists.py +0 -229
  71. additory/common/patterns.py +0 -240
  72. additory/common/resolver.py +0 -567
  73. additory/common/sample_data.py +0 -182
  74. additory/core/ast_builder.py +0 -165
  75. additory/core/backends/__init__.py +0 -23
  76. additory/core/backends/arrow_bridge.py +0 -483
  77. additory/core/backends/cudf_bridge.py +0 -355
  78. additory/core/column_positioning.py +0 -358
  79. additory/core/compiler_polars.py +0 -166
  80. additory/core/enhanced_cache_manager.py +0 -1119
  81. additory/core/enhanced_matchers.py +0 -473
  82. additory/core/enhanced_version_manager.py +0 -325
  83. additory/core/executor.py +0 -59
  84. additory/core/integrity_manager.py +0 -477
  85. additory/core/loader.py +0 -190
  86. additory/core/namespace_manager.py +0 -657
  87. additory/core/parser.py +0 -176
  88. additory/core/polars_expression_engine.py +0 -601
  89. additory/core/registry.py +0 -176
  90. additory/core/sample_data_manager.py +0 -492
  91. additory/core/user_namespace.py +0 -751
  92. additory/core/validator.py +0 -27
  93. additory/dynamic_api.py +0 -304
  94. additory/expressions/proxy.py +0 -549
  95. additory/expressions/registry.py +0 -313
  96. additory/expressions/samples.py +0 -492
  97. additory/synthetic/__init__.py +0 -13
  98. additory/synthetic/column_name_resolver.py +0 -149
  99. additory/synthetic/distributions.py +0 -22
  100. additory/synthetic/forecast.py +0 -1132
  101. additory/synthetic/linked_list_parser.py +0 -415
  102. additory/synthetic/namespace_lookup.py +0 -129
  103. additory/synthetic/smote.py +0 -320
  104. additory/synthetic/strategies.py +0 -850
  105. additory/synthetic/synthesizer.py +0 -713
  106. additory/utilities/__init__.py +0 -53
  107. additory/utilities/encoding.py +0 -600
  108. additory/utilities/games.py +0 -300
  109. additory/utilities/keys.py +0 -8
  110. additory/utilities/lookup.py +0 -103
  111. additory/utilities/matchers.py +0 -216
  112. additory/utilities/resolvers.py +0 -286
  113. additory/utilities/settings.py +0 -167
  114. additory/utilities/units.py +0 -749
  115. additory/utilities/validators.py +0 -153
  116. additory-0.1.0a3.dist-info/METADATA +0 -288
  117. additory-0.1.0a3.dist-info/RECORD +0 -71
  118. additory-0.1.0a3.dist-info/licenses/LICENSE +0 -21
  119. {additory-0.1.0a3.dist-info → additory-0.1.1a1.dist-info}/WHEEL +0 -0
  120. {additory-0.1.0a3.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()