relationalai 1.0.0a3__py3-none-any.whl → 1.0.0a5__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 (118) hide show
  1. relationalai/config/config.py +47 -21
  2. relationalai/config/connections/__init__.py +5 -2
  3. relationalai/config/connections/duckdb.py +2 -2
  4. relationalai/config/connections/local.py +31 -0
  5. relationalai/config/connections/snowflake.py +0 -1
  6. relationalai/config/external/raiconfig_converter.py +235 -0
  7. relationalai/config/external/raiconfig_models.py +202 -0
  8. relationalai/config/external/utils.py +31 -0
  9. relationalai/config/shims.py +1 -0
  10. relationalai/semantics/__init__.py +10 -8
  11. relationalai/semantics/backends/sql/sql_compiler.py +1 -4
  12. relationalai/semantics/experimental/__init__.py +0 -0
  13. relationalai/semantics/experimental/builder.py +295 -0
  14. relationalai/semantics/experimental/builtins.py +154 -0
  15. relationalai/semantics/frontend/base.py +67 -42
  16. relationalai/semantics/frontend/core.py +34 -6
  17. relationalai/semantics/frontend/front_compiler.py +209 -37
  18. relationalai/semantics/frontend/pprint.py +6 -2
  19. relationalai/semantics/metamodel/__init__.py +7 -0
  20. relationalai/semantics/metamodel/metamodel.py +2 -0
  21. relationalai/semantics/metamodel/metamodel_analyzer.py +58 -16
  22. relationalai/semantics/metamodel/pprint.py +6 -1
  23. relationalai/semantics/metamodel/rewriter.py +11 -7
  24. relationalai/semantics/metamodel/typer.py +116 -41
  25. relationalai/semantics/reasoners/__init__.py +11 -0
  26. relationalai/semantics/reasoners/graph/__init__.py +35 -0
  27. relationalai/semantics/reasoners/graph/core.py +9028 -0
  28. relationalai/semantics/std/__init__.py +30 -10
  29. relationalai/semantics/std/aggregates.py +641 -12
  30. relationalai/semantics/std/common.py +146 -13
  31. relationalai/semantics/std/constraints.py +71 -1
  32. relationalai/semantics/std/datetime.py +904 -21
  33. relationalai/semantics/std/decimals.py +143 -2
  34. relationalai/semantics/std/floats.py +57 -4
  35. relationalai/semantics/std/integers.py +98 -4
  36. relationalai/semantics/std/math.py +857 -35
  37. relationalai/semantics/std/numbers.py +216 -20
  38. relationalai/semantics/std/re.py +213 -5
  39. relationalai/semantics/std/strings.py +437 -44
  40. relationalai/shims/executor.py +60 -52
  41. relationalai/shims/fixtures.py +85 -0
  42. relationalai/shims/helpers.py +26 -2
  43. relationalai/shims/hoister.py +28 -9
  44. relationalai/shims/mm2v0.py +204 -173
  45. relationalai/tools/cli/cli.py +192 -10
  46. relationalai/tools/cli/components/progress_reader.py +1 -1
  47. relationalai/tools/cli/docs.py +394 -0
  48. relationalai/tools/debugger.py +11 -4
  49. relationalai/tools/qb_debugger.py +435 -0
  50. relationalai/tools/typer_debugger.py +1 -2
  51. relationalai/util/dataclasses.py +3 -5
  52. relationalai/util/docutils.py +1 -2
  53. relationalai/util/error.py +2 -5
  54. relationalai/util/python.py +23 -0
  55. relationalai/util/runtime.py +1 -2
  56. relationalai/util/schema.py +2 -4
  57. relationalai/util/structures.py +4 -2
  58. relationalai/util/tracing.py +8 -2
  59. {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/METADATA +8 -5
  60. {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/RECORD +118 -95
  61. {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/WHEEL +1 -1
  62. v0/relationalai/__init__.py +1 -1
  63. v0/relationalai/clients/client.py +52 -18
  64. v0/relationalai/clients/exec_txn_poller.py +122 -0
  65. v0/relationalai/clients/local.py +23 -8
  66. v0/relationalai/clients/resources/azure/azure.py +36 -11
  67. v0/relationalai/clients/resources/snowflake/__init__.py +4 -4
  68. v0/relationalai/clients/resources/snowflake/cli_resources.py +12 -1
  69. v0/relationalai/clients/resources/snowflake/direct_access_resources.py +124 -100
  70. v0/relationalai/clients/resources/snowflake/engine_service.py +381 -0
  71. v0/relationalai/clients/resources/snowflake/engine_state_handlers.py +35 -29
  72. v0/relationalai/clients/resources/snowflake/error_handlers.py +43 -2
  73. v0/relationalai/clients/resources/snowflake/snowflake.py +277 -179
  74. v0/relationalai/clients/resources/snowflake/use_index_poller.py +8 -0
  75. v0/relationalai/clients/types.py +5 -0
  76. v0/relationalai/errors.py +19 -1
  77. v0/relationalai/semantics/lqp/algorithms.py +173 -0
  78. v0/relationalai/semantics/lqp/builtins.py +199 -2
  79. v0/relationalai/semantics/lqp/executor.py +68 -37
  80. v0/relationalai/semantics/lqp/ir.py +28 -2
  81. v0/relationalai/semantics/lqp/model2lqp.py +215 -45
  82. v0/relationalai/semantics/lqp/passes.py +13 -658
  83. v0/relationalai/semantics/lqp/rewrite/__init__.py +12 -0
  84. v0/relationalai/semantics/lqp/rewrite/algorithm.py +385 -0
  85. v0/relationalai/semantics/lqp/rewrite/constants_to_vars.py +70 -0
  86. v0/relationalai/semantics/lqp/rewrite/deduplicate_vars.py +104 -0
  87. v0/relationalai/semantics/lqp/rewrite/eliminate_data.py +108 -0
  88. v0/relationalai/semantics/lqp/rewrite/extract_keys.py +25 -3
  89. v0/relationalai/semantics/lqp/rewrite/period_math.py +77 -0
  90. v0/relationalai/semantics/lqp/rewrite/quantify_vars.py +65 -31
  91. v0/relationalai/semantics/lqp/rewrite/unify_definitions.py +317 -0
  92. v0/relationalai/semantics/lqp/utils.py +11 -1
  93. v0/relationalai/semantics/lqp/validators.py +14 -1
  94. v0/relationalai/semantics/metamodel/builtins.py +2 -1
  95. v0/relationalai/semantics/metamodel/compiler.py +2 -1
  96. v0/relationalai/semantics/metamodel/dependency.py +12 -3
  97. v0/relationalai/semantics/metamodel/executor.py +11 -1
  98. v0/relationalai/semantics/metamodel/factory.py +2 -2
  99. v0/relationalai/semantics/metamodel/helpers.py +7 -0
  100. v0/relationalai/semantics/metamodel/ir.py +3 -2
  101. v0/relationalai/semantics/metamodel/rewrite/dnf_union_splitter.py +30 -20
  102. v0/relationalai/semantics/metamodel/rewrite/flatten.py +50 -13
  103. v0/relationalai/semantics/metamodel/rewrite/format_outputs.py +9 -3
  104. v0/relationalai/semantics/metamodel/typer/checker.py +6 -4
  105. v0/relationalai/semantics/metamodel/typer/typer.py +4 -3
  106. v0/relationalai/semantics/metamodel/visitor.py +4 -3
  107. v0/relationalai/semantics/reasoners/optimization/solvers_dev.py +1 -1
  108. v0/relationalai/semantics/reasoners/optimization/solvers_pb.py +336 -86
  109. v0/relationalai/semantics/rel/compiler.py +2 -1
  110. v0/relationalai/semantics/rel/executor.py +3 -2
  111. v0/relationalai/semantics/tests/lqp/__init__.py +0 -0
  112. v0/relationalai/semantics/tests/lqp/algorithms.py +345 -0
  113. v0/relationalai/tools/cli.py +339 -186
  114. v0/relationalai/tools/cli_controls.py +216 -67
  115. v0/relationalai/tools/cli_helpers.py +410 -6
  116. v0/relationalai/util/format.py +5 -2
  117. {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/entry_points.txt +0 -0
  118. {relationalai-1.0.0a3.dist-info → relationalai-1.0.0a5.dist-info}/top_level.txt +0 -0
@@ -1,18 +1,23 @@
1
1
 
2
+ """
3
+ The RelationalAI Semantics Standard Library.
4
+ """
2
5
  from ..frontend.base import Variable, Literal, Expression
3
- from ...util.error import warn, exc, source
6
+ from ...util.error import warn, exc, source, Part
4
7
  from ...util.source import SourcePos
5
8
  from decimal import Decimal as PyDecimal
6
9
  import datetime as dt
7
10
  from typing import Any, Union
8
11
 
12
+ __include_in_docs__ = True
13
+
9
14
  #------------------------------------------------------
10
15
  # Helpers
11
16
  #------------------------------------------------------
12
17
 
13
18
  def _deprecated_library(library, replacement=None, example=None):
14
19
  replacement_message = ""
15
- parts = [source(SourcePos.new())]
20
+ parts: list[Part] = [source(SourcePos.new())]
16
21
  if replacement is not None:
17
22
  replacement_message = f" Use '{replacement}' instead."
18
23
  if example is not None:
@@ -21,7 +26,7 @@ def _deprecated_library(library, replacement=None, example=None):
21
26
 
22
27
  def _deprecated_function(func_name, replacement=None, example=None):
23
28
  replacement_message = ""
24
- parts = [source(SourcePos.new())]
29
+ parts: list[Part] = [source(SourcePos.new())]
25
30
  if replacement is not None:
26
31
  replacement_message = f" Use '{replacement}' instead."
27
32
  if example is not None:
@@ -29,15 +34,28 @@ def _deprecated_function(func_name, replacement=None, example=None):
29
34
  warn("Deprecated function", f"The function '{func_name}' is deprecated.{replacement_message}", parts)
30
35
 
31
36
  def _function_not_implemented(func_name: str):
32
- parts = [source(SourcePos.new())]
37
+ parts: list[Part] = [source(SourcePos.new())]
33
38
  exc("Function not implemented", f"The function '{func_name}' is not yet implemented in PyRel.", parts)
34
39
 
35
- StringValue = Union[Variable, str]
36
- IntegerValue = Union[Variable, int]
37
- DateValue = Union[Variable, dt.date]
38
40
  DateTimeValue = Union[Variable, dt.datetime]
39
- NumberValue = Union[Variable, float, int, PyDecimal]
41
+ """ A type representing a datetime value, which can be a literal `datetime.datetime` or a `Variable` resulting from
42
+ some other expression which will evaluate to a datetime. """
43
+ DateValue = Union[Variable, dt.date]
44
+ """ A type representing a date value, which can be a literal `datetime.date` or a `Variable` resulting from
45
+ some other expression which will evaluate to a date. """
40
46
  FloatValue = Union[Variable, float]
47
+ """ A type representing a float value, which can be a literal `float` or a `Variable` resulting from
48
+ some other expression which will evaluate to a float. """
49
+ IntegerValue = Union[Variable, int]
50
+ """ A type representing an integer value, which can be a literal `int` or a `Variable` resulting from
51
+ some other expression which will evaluate to an integer. """
52
+ NumberValue = Union[Variable, float, int, PyDecimal]
53
+ """ A type representing a number value, which can be a literal `float`, `int`, or `Decimal`, or a `Variable` resulting from
54
+ some other expression which will evaluate to a number. """
55
+ StringValue = Union[Variable, str]
56
+ """ A type representing a string value, which can be a literal `str` or a `Variable` resulting from
57
+ some other expression which will evaluate to a string. """
58
+
41
59
 
42
60
  def _get_number_value(value: Any) -> Union[float, int, PyDecimal, None]:
43
61
  """ If the value is a number literal, return its value as a Python number. """
@@ -51,7 +69,9 @@ def _get_number_value(value: Any) -> Union[float, int, PyDecimal, None]:
51
69
  #------------------------------------------------------
52
70
  # Libraries
53
71
  #------------------------------------------------------
54
- from . import aggregates, common, datetime, decimals, integers, math, numbers, re, strings, constraints
72
+ # Import submodules after type aliases are defined to avoid circular imports
73
+ from . import aggregates, common, datetime, decimals, integers, math, numbers, re, strings, constraints # noqa: E402
74
+
55
75
  __all__ = [
56
76
  "aggregates",
57
77
  "common",
@@ -70,5 +90,5 @@ __all__ = [
70
90
  #------------------------------------------------------
71
91
 
72
92
  def range(*args: IntegerValue) -> Expression:
73
- _deprecated_function("std.range", "common.range")
93
+ _deprecated_function("std.range", "std.common.range")
74
94
  return common.range(*args)