relationalai 0.13.5__py3-none-any.whl → 1.0.0a2__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.
- relationalai/__init__.py +1 -256
- relationalai/config/__init__.py +56 -0
- relationalai/config/config.py +289 -0
- relationalai/config/config_fields.py +86 -0
- relationalai/config/connections/__init__.py +46 -0
- relationalai/config/connections/base.py +23 -0
- relationalai/config/connections/duckdb.py +29 -0
- relationalai/config/connections/snowflake.py +243 -0
- relationalai/config/external/__init__.py +17 -0
- relationalai/config/external/dbt_converter.py +101 -0
- relationalai/config/external/dbt_models.py +93 -0
- relationalai/config/external/snowflake_converter.py +41 -0
- relationalai/config/external/snowflake_models.py +85 -0
- relationalai/config/external/utils.py +19 -0
- relationalai/config/shims.py +1 -0
- relationalai/semantics/__init__.py +146 -22
- relationalai/semantics/backends/lqp/annotations.py +11 -0
- relationalai/semantics/backends/sql/sql_compiler.py +327 -0
- relationalai/semantics/frontend/base.py +1719 -0
- relationalai/semantics/frontend/core.py +179 -0
- relationalai/semantics/frontend/front_compiler.py +1316 -0
- relationalai/semantics/frontend/pprint.py +408 -0
- relationalai/semantics/metamodel/__init__.py +6 -40
- relationalai/semantics/metamodel/builtins.py +206 -772
- relationalai/semantics/metamodel/metamodel.py +465 -0
- relationalai/semantics/metamodel/metamodel_analyzer.py +519 -0
- relationalai/semantics/metamodel/pprint.py +414 -0
- relationalai/semantics/metamodel/rewriter.py +266 -0
- relationalai/semantics/metamodel/typer.py +1213 -0
- relationalai/semantics/std/__init__.py +60 -40
- relationalai/semantics/std/aggregates.py +148 -0
- relationalai/semantics/std/common.py +44 -0
- relationalai/semantics/std/constraints.py +37 -43
- relationalai/semantics/std/datetime.py +249 -135
- relationalai/semantics/std/decimals.py +45 -52
- relationalai/semantics/std/floats.py +13 -5
- relationalai/semantics/std/integers.py +26 -11
- relationalai/semantics/std/math.py +183 -112
- relationalai/semantics/std/numbers.py +86 -0
- relationalai/semantics/std/re.py +80 -62
- relationalai/semantics/std/strings.py +101 -46
- relationalai/shims/executor.py +179 -0
- relationalai/shims/helpers.py +126 -0
- relationalai/shims/hoister.py +221 -0
- relationalai/shims/mm2v0.py +1394 -0
- relationalai/tools/cli/__init__.py +6 -0
- relationalai/tools/cli/cli.py +90 -0
- relationalai/tools/cli/components/__init__.py +5 -0
- relationalai/tools/cli/components/progress_reader.py +1524 -0
- relationalai/tools/cli/components/utils.py +58 -0
- relationalai/tools/cli/config_template.py +45 -0
- relationalai/tools/cli/dev.py +19 -0
- relationalai/tools/debugger.py +289 -183
- relationalai/tools/typer_debugger.py +93 -0
- relationalai/util/dataclasses.py +43 -0
- relationalai/util/docutils.py +40 -0
- relationalai/util/error.py +199 -0
- relationalai/util/format.py +48 -109
- relationalai/util/naming.py +145 -0
- relationalai/util/python.py +35 -0
- relationalai/util/runtime.py +156 -0
- relationalai/util/schema.py +197 -0
- relationalai/util/source.py +185 -0
- relationalai/util/structures.py +163 -0
- relationalai/util/tracing.py +261 -0
- relationalai-1.0.0a2.dist-info/METADATA +44 -0
- relationalai-1.0.0a2.dist-info/RECORD +489 -0
- relationalai-1.0.0a2.dist-info/WHEEL +5 -0
- relationalai-1.0.0a2.dist-info/entry_points.txt +3 -0
- relationalai-1.0.0a2.dist-info/top_level.txt +2 -0
- v0/relationalai/__init__.py +216 -0
- v0/relationalai/clients/__init__.py +5 -0
- v0/relationalai/clients/azure.py +477 -0
- v0/relationalai/clients/client.py +912 -0
- v0/relationalai/clients/config.py +673 -0
- v0/relationalai/clients/direct_access_client.py +118 -0
- v0/relationalai/clients/hash_util.py +31 -0
- v0/relationalai/clients/local.py +571 -0
- v0/relationalai/clients/profile_polling.py +73 -0
- v0/relationalai/clients/result_helpers.py +420 -0
- v0/relationalai/clients/snowflake.py +3869 -0
- v0/relationalai/clients/types.py +113 -0
- v0/relationalai/clients/use_index_poller.py +980 -0
- v0/relationalai/clients/util.py +356 -0
- v0/relationalai/debugging.py +389 -0
- v0/relationalai/dsl.py +1749 -0
- v0/relationalai/early_access/builder/__init__.py +30 -0
- v0/relationalai/early_access/builder/builder/__init__.py +35 -0
- v0/relationalai/early_access/builder/snowflake/__init__.py +12 -0
- v0/relationalai/early_access/builder/std/__init__.py +25 -0
- v0/relationalai/early_access/builder/std/decimals/__init__.py +12 -0
- v0/relationalai/early_access/builder/std/integers/__init__.py +12 -0
- v0/relationalai/early_access/builder/std/math/__init__.py +12 -0
- v0/relationalai/early_access/builder/std/strings/__init__.py +14 -0
- v0/relationalai/early_access/devtools/__init__.py +12 -0
- v0/relationalai/early_access/devtools/benchmark_lqp/__init__.py +12 -0
- v0/relationalai/early_access/devtools/extract_lqp/__init__.py +12 -0
- v0/relationalai/early_access/dsl/adapters/orm/adapter_qb.py +427 -0
- v0/relationalai/early_access/dsl/adapters/orm/parser.py +636 -0
- v0/relationalai/early_access/dsl/adapters/owl/adapter.py +176 -0
- v0/relationalai/early_access/dsl/adapters/owl/parser.py +160 -0
- v0/relationalai/early_access/dsl/bindings/common.py +402 -0
- v0/relationalai/early_access/dsl/bindings/csv.py +170 -0
- v0/relationalai/early_access/dsl/bindings/legacy/binding_models.py +143 -0
- v0/relationalai/early_access/dsl/bindings/snowflake.py +64 -0
- v0/relationalai/early_access/dsl/codegen/binder.py +411 -0
- v0/relationalai/early_access/dsl/codegen/common.py +79 -0
- v0/relationalai/early_access/dsl/codegen/helpers.py +23 -0
- v0/relationalai/early_access/dsl/codegen/relations.py +700 -0
- v0/relationalai/early_access/dsl/codegen/weaver.py +417 -0
- v0/relationalai/early_access/dsl/core/builders/__init__.py +47 -0
- v0/relationalai/early_access/dsl/core/builders/logic.py +19 -0
- v0/relationalai/early_access/dsl/core/builders/scalar_constraint.py +11 -0
- v0/relationalai/early_access/dsl/core/constraints/predicate/atomic.py +455 -0
- v0/relationalai/early_access/dsl/core/constraints/predicate/universal.py +73 -0
- v0/relationalai/early_access/dsl/core/constraints/scalar.py +310 -0
- v0/relationalai/early_access/dsl/core/context.py +13 -0
- v0/relationalai/early_access/dsl/core/cset.py +132 -0
- v0/relationalai/early_access/dsl/core/exprs/__init__.py +116 -0
- v0/relationalai/early_access/dsl/core/exprs/relational.py +18 -0
- v0/relationalai/early_access/dsl/core/exprs/scalar.py +412 -0
- v0/relationalai/early_access/dsl/core/instances.py +44 -0
- v0/relationalai/early_access/dsl/core/logic/__init__.py +193 -0
- v0/relationalai/early_access/dsl/core/logic/aggregation.py +98 -0
- v0/relationalai/early_access/dsl/core/logic/exists.py +223 -0
- v0/relationalai/early_access/dsl/core/logic/helper.py +163 -0
- v0/relationalai/early_access/dsl/core/namespaces.py +32 -0
- v0/relationalai/early_access/dsl/core/relations.py +276 -0
- v0/relationalai/early_access/dsl/core/rules.py +112 -0
- v0/relationalai/early_access/dsl/core/std/__init__.py +45 -0
- v0/relationalai/early_access/dsl/core/temporal/recall.py +6 -0
- v0/relationalai/early_access/dsl/core/types/__init__.py +270 -0
- v0/relationalai/early_access/dsl/core/types/concepts.py +128 -0
- v0/relationalai/early_access/dsl/core/types/constrained/__init__.py +267 -0
- v0/relationalai/early_access/dsl/core/types/constrained/nominal.py +143 -0
- v0/relationalai/early_access/dsl/core/types/constrained/subtype.py +124 -0
- v0/relationalai/early_access/dsl/core/types/standard.py +92 -0
- v0/relationalai/early_access/dsl/core/types/unconstrained.py +50 -0
- v0/relationalai/early_access/dsl/core/types/variables.py +203 -0
- v0/relationalai/early_access/dsl/ir/compiler.py +318 -0
- v0/relationalai/early_access/dsl/ir/executor.py +260 -0
- v0/relationalai/early_access/dsl/ontologies/constraints.py +88 -0
- v0/relationalai/early_access/dsl/ontologies/export.py +30 -0
- v0/relationalai/early_access/dsl/ontologies/models.py +453 -0
- v0/relationalai/early_access/dsl/ontologies/python_printer.py +303 -0
- v0/relationalai/early_access/dsl/ontologies/readings.py +60 -0
- v0/relationalai/early_access/dsl/ontologies/relationships.py +322 -0
- v0/relationalai/early_access/dsl/ontologies/roles.py +87 -0
- v0/relationalai/early_access/dsl/ontologies/subtyping.py +55 -0
- v0/relationalai/early_access/dsl/orm/constraints.py +438 -0
- v0/relationalai/early_access/dsl/orm/measures/dimensions.py +200 -0
- v0/relationalai/early_access/dsl/orm/measures/initializer.py +16 -0
- v0/relationalai/early_access/dsl/orm/measures/measure_rules.py +275 -0
- v0/relationalai/early_access/dsl/orm/measures/measures.py +299 -0
- v0/relationalai/early_access/dsl/orm/measures/role_exprs.py +268 -0
- v0/relationalai/early_access/dsl/orm/models.py +256 -0
- v0/relationalai/early_access/dsl/orm/object_oriented_printer.py +344 -0
- v0/relationalai/early_access/dsl/orm/printer.py +469 -0
- v0/relationalai/early_access/dsl/orm/reasoners.py +480 -0
- v0/relationalai/early_access/dsl/orm/relations.py +19 -0
- v0/relationalai/early_access/dsl/orm/relationships.py +251 -0
- v0/relationalai/early_access/dsl/orm/types.py +42 -0
- v0/relationalai/early_access/dsl/orm/utils.py +79 -0
- v0/relationalai/early_access/dsl/orm/verb.py +204 -0
- v0/relationalai/early_access/dsl/physical_metadata/tables.py +133 -0
- v0/relationalai/early_access/dsl/relations.py +170 -0
- v0/relationalai/early_access/dsl/rulesets.py +69 -0
- v0/relationalai/early_access/dsl/schemas/__init__.py +450 -0
- v0/relationalai/early_access/dsl/schemas/builder.py +48 -0
- v0/relationalai/early_access/dsl/schemas/comp_names.py +51 -0
- v0/relationalai/early_access/dsl/schemas/components.py +203 -0
- v0/relationalai/early_access/dsl/schemas/contexts.py +156 -0
- v0/relationalai/early_access/dsl/schemas/exprs.py +89 -0
- v0/relationalai/early_access/dsl/schemas/fragments.py +464 -0
- v0/relationalai/early_access/dsl/serialization.py +79 -0
- v0/relationalai/early_access/dsl/serialize/exporter.py +163 -0
- v0/relationalai/early_access/dsl/snow/api.py +104 -0
- v0/relationalai/early_access/dsl/snow/common.py +76 -0
- v0/relationalai/early_access/dsl/state_mgmt/__init__.py +129 -0
- v0/relationalai/early_access/dsl/state_mgmt/state_charts.py +125 -0
- v0/relationalai/early_access/dsl/state_mgmt/transitions.py +130 -0
- v0/relationalai/early_access/dsl/types/__init__.py +40 -0
- v0/relationalai/early_access/dsl/types/concepts.py +12 -0
- v0/relationalai/early_access/dsl/types/entities.py +135 -0
- v0/relationalai/early_access/dsl/types/values.py +17 -0
- v0/relationalai/early_access/dsl/utils.py +102 -0
- v0/relationalai/early_access/graphs/__init__.py +13 -0
- v0/relationalai/early_access/lqp/__init__.py +12 -0
- v0/relationalai/early_access/lqp/compiler/__init__.py +12 -0
- v0/relationalai/early_access/lqp/constructors/__init__.py +18 -0
- v0/relationalai/early_access/lqp/executor/__init__.py +12 -0
- v0/relationalai/early_access/lqp/ir/__init__.py +12 -0
- v0/relationalai/early_access/lqp/passes/__init__.py +12 -0
- v0/relationalai/early_access/lqp/pragmas/__init__.py +12 -0
- v0/relationalai/early_access/lqp/primitives/__init__.py +12 -0
- v0/relationalai/early_access/lqp/types/__init__.py +12 -0
- v0/relationalai/early_access/lqp/utils/__init__.py +12 -0
- v0/relationalai/early_access/lqp/validators/__init__.py +12 -0
- v0/relationalai/early_access/metamodel/__init__.py +58 -0
- v0/relationalai/early_access/metamodel/builtins/__init__.py +12 -0
- v0/relationalai/early_access/metamodel/compiler/__init__.py +12 -0
- v0/relationalai/early_access/metamodel/dependency/__init__.py +12 -0
- v0/relationalai/early_access/metamodel/factory/__init__.py +17 -0
- v0/relationalai/early_access/metamodel/helpers/__init__.py +12 -0
- v0/relationalai/early_access/metamodel/ir/__init__.py +14 -0
- v0/relationalai/early_access/metamodel/rewrite/__init__.py +7 -0
- v0/relationalai/early_access/metamodel/typer/__init__.py +3 -0
- v0/relationalai/early_access/metamodel/typer/typer/__init__.py +12 -0
- v0/relationalai/early_access/metamodel/types/__init__.py +15 -0
- v0/relationalai/early_access/metamodel/util/__init__.py +15 -0
- v0/relationalai/early_access/metamodel/visitor/__init__.py +12 -0
- v0/relationalai/early_access/rel/__init__.py +12 -0
- v0/relationalai/early_access/rel/executor/__init__.py +12 -0
- v0/relationalai/early_access/rel/rel_utils/__init__.py +12 -0
- v0/relationalai/early_access/rel/rewrite/__init__.py +7 -0
- v0/relationalai/early_access/solvers/__init__.py +19 -0
- v0/relationalai/early_access/sql/__init__.py +11 -0
- v0/relationalai/early_access/sql/executor/__init__.py +3 -0
- v0/relationalai/early_access/sql/rewrite/__init__.py +3 -0
- v0/relationalai/early_access/tests/logging/__init__.py +12 -0
- v0/relationalai/early_access/tests/test_snapshot_base/__init__.py +12 -0
- v0/relationalai/early_access/tests/utils/__init__.py +12 -0
- v0/relationalai/environments/__init__.py +35 -0
- v0/relationalai/environments/base.py +381 -0
- v0/relationalai/environments/colab.py +14 -0
- v0/relationalai/environments/generic.py +71 -0
- v0/relationalai/environments/ipython.py +68 -0
- v0/relationalai/environments/jupyter.py +9 -0
- v0/relationalai/environments/snowbook.py +169 -0
- v0/relationalai/errors.py +2478 -0
- v0/relationalai/experimental/SF.py +38 -0
- v0/relationalai/experimental/inspect.py +47 -0
- v0/relationalai/experimental/pathfinder/__init__.py +158 -0
- v0/relationalai/experimental/pathfinder/api.py +160 -0
- v0/relationalai/experimental/pathfinder/automaton.py +584 -0
- v0/relationalai/experimental/pathfinder/bridge.py +226 -0
- v0/relationalai/experimental/pathfinder/compiler.py +416 -0
- v0/relationalai/experimental/pathfinder/datalog.py +214 -0
- v0/relationalai/experimental/pathfinder/diagnostics.py +56 -0
- v0/relationalai/experimental/pathfinder/filter.py +236 -0
- v0/relationalai/experimental/pathfinder/glushkov.py +439 -0
- v0/relationalai/experimental/pathfinder/options.py +265 -0
- v0/relationalai/experimental/pathfinder/rpq.py +344 -0
- v0/relationalai/experimental/pathfinder/transition.py +200 -0
- v0/relationalai/experimental/pathfinder/utils.py +26 -0
- v0/relationalai/experimental/paths/api.py +143 -0
- v0/relationalai/experimental/paths/benchmarks/grid_graph.py +37 -0
- v0/relationalai/experimental/paths/examples/basic_example.py +40 -0
- v0/relationalai/experimental/paths/examples/minimal_engine_warmup.py +3 -0
- v0/relationalai/experimental/paths/examples/movie_example.py +77 -0
- v0/relationalai/experimental/paths/examples/paths_benchmark.py +115 -0
- v0/relationalai/experimental/paths/examples/paths_example.py +116 -0
- v0/relationalai/experimental/paths/examples/pattern_to_automaton.py +28 -0
- v0/relationalai/experimental/paths/find_paths_via_automaton.py +85 -0
- v0/relationalai/experimental/paths/graph.py +185 -0
- v0/relationalai/experimental/paths/path_algorithms/find_paths.py +280 -0
- v0/relationalai/experimental/paths/path_algorithms/one_sided_ball_repetition.py +26 -0
- v0/relationalai/experimental/paths/path_algorithms/one_sided_ball_upto.py +111 -0
- v0/relationalai/experimental/paths/path_algorithms/single.py +59 -0
- v0/relationalai/experimental/paths/path_algorithms/two_sided_balls_repetition.py +39 -0
- v0/relationalai/experimental/paths/path_algorithms/two_sided_balls_upto.py +103 -0
- v0/relationalai/experimental/paths/path_algorithms/usp-old.py +130 -0
- v0/relationalai/experimental/paths/path_algorithms/usp-tuple.py +183 -0
- v0/relationalai/experimental/paths/path_algorithms/usp.py +150 -0
- v0/relationalai/experimental/paths/product_graph.py +93 -0
- v0/relationalai/experimental/paths/rpq/automaton.py +584 -0
- v0/relationalai/experimental/paths/rpq/diagnostics.py +56 -0
- v0/relationalai/experimental/paths/rpq/rpq.py +378 -0
- v0/relationalai/experimental/paths/tests/tests_limit_sp_max_length.py +90 -0
- v0/relationalai/experimental/paths/tests/tests_limit_sp_multiple.py +119 -0
- v0/relationalai/experimental/paths/tests/tests_limit_sp_single.py +104 -0
- v0/relationalai/experimental/paths/tests/tests_limit_walks_multiple.py +113 -0
- v0/relationalai/experimental/paths/tests/tests_limit_walks_single.py +149 -0
- v0/relationalai/experimental/paths/tests/tests_one_sided_ball_repetition_multiple.py +70 -0
- v0/relationalai/experimental/paths/tests/tests_one_sided_ball_repetition_single.py +64 -0
- v0/relationalai/experimental/paths/tests/tests_one_sided_ball_upto_multiple.py +115 -0
- v0/relationalai/experimental/paths/tests/tests_one_sided_ball_upto_single.py +75 -0
- v0/relationalai/experimental/paths/tests/tests_single_paths.py +152 -0
- v0/relationalai/experimental/paths/tests/tests_single_walks.py +208 -0
- v0/relationalai/experimental/paths/tests/tests_single_walks_undirected.py +297 -0
- v0/relationalai/experimental/paths/tests/tests_two_sided_balls_repetition_multiple.py +107 -0
- v0/relationalai/experimental/paths/tests/tests_two_sided_balls_repetition_single.py +76 -0
- v0/relationalai/experimental/paths/tests/tests_two_sided_balls_upto_multiple.py +76 -0
- v0/relationalai/experimental/paths/tests/tests_two_sided_balls_upto_single.py +110 -0
- v0/relationalai/experimental/paths/tests/tests_usp_nsp_multiple.py +229 -0
- v0/relationalai/experimental/paths/tests/tests_usp_nsp_single.py +108 -0
- v0/relationalai/experimental/paths/tree_agg.py +168 -0
- v0/relationalai/experimental/paths/utilities/iterators.py +27 -0
- v0/relationalai/experimental/paths/utilities/prefix_sum.py +91 -0
- v0/relationalai/experimental/solvers.py +1087 -0
- v0/relationalai/loaders/csv.py +195 -0
- v0/relationalai/loaders/loader.py +177 -0
- v0/relationalai/loaders/types.py +23 -0
- v0/relationalai/rel_emitter.py +373 -0
- v0/relationalai/rel_utils.py +185 -0
- v0/relationalai/semantics/__init__.py +29 -0
- v0/relationalai/semantics/devtools/benchmark_lqp.py +536 -0
- v0/relationalai/semantics/devtools/compilation_manager.py +294 -0
- v0/relationalai/semantics/devtools/extract_lqp.py +110 -0
- v0/relationalai/semantics/internal/internal.py +3785 -0
- v0/relationalai/semantics/internal/snowflake.py +325 -0
- v0/relationalai/semantics/lqp/builtins.py +16 -0
- v0/relationalai/semantics/lqp/compiler.py +22 -0
- v0/relationalai/semantics/lqp/constructors.py +68 -0
- v0/relationalai/semantics/lqp/executor.py +474 -0
- v0/relationalai/semantics/lqp/intrinsics.py +24 -0
- v0/relationalai/semantics/lqp/ir.py +124 -0
- v0/relationalai/semantics/lqp/model2lqp.py +877 -0
- v0/relationalai/semantics/lqp/passes.py +680 -0
- v0/relationalai/semantics/lqp/primitives.py +252 -0
- v0/relationalai/semantics/lqp/result_helpers.py +202 -0
- v0/relationalai/semantics/lqp/rewrite/__init__.py +18 -0
- v0/relationalai/semantics/lqp/rewrite/annotate_constraints.py +57 -0
- v0/relationalai/semantics/lqp/rewrite/cdc.py +216 -0
- v0/relationalai/semantics/lqp/rewrite/extract_common.py +338 -0
- v0/relationalai/semantics/lqp/rewrite/extract_keys.py +490 -0
- v0/relationalai/semantics/lqp/rewrite/function_annotations.py +114 -0
- v0/relationalai/semantics/lqp/rewrite/functional_dependencies.py +314 -0
- v0/relationalai/semantics/lqp/rewrite/quantify_vars.py +296 -0
- v0/relationalai/semantics/lqp/rewrite/splinter.py +76 -0
- v0/relationalai/semantics/lqp/types.py +101 -0
- v0/relationalai/semantics/lqp/utils.py +160 -0
- v0/relationalai/semantics/lqp/validators.py +57 -0
- v0/relationalai/semantics/metamodel/__init__.py +40 -0
- v0/relationalai/semantics/metamodel/builtins.py +776 -0
- v0/relationalai/semantics/metamodel/compiler.py +133 -0
- v0/relationalai/semantics/metamodel/dependency.py +862 -0
- v0/relationalai/semantics/metamodel/executor.py +61 -0
- v0/relationalai/semantics/metamodel/factory.py +287 -0
- v0/relationalai/semantics/metamodel/helpers.py +361 -0
- v0/relationalai/semantics/metamodel/ir.py +923 -0
- v0/relationalai/semantics/metamodel/rewrite/__init__.py +7 -0
- v0/relationalai/semantics/metamodel/rewrite/discharge_constraints.py +39 -0
- v0/relationalai/semantics/metamodel/rewrite/dnf_union_splitter.py +210 -0
- v0/relationalai/semantics/metamodel/rewrite/extract_nested_logicals.py +78 -0
- v0/relationalai/semantics/metamodel/rewrite/flatten.py +554 -0
- v0/relationalai/semantics/metamodel/rewrite/format_outputs.py +165 -0
- v0/relationalai/semantics/metamodel/typer/checker.py +353 -0
- v0/relationalai/semantics/metamodel/typer/typer.py +1395 -0
- v0/relationalai/semantics/metamodel/util.py +505 -0
- v0/relationalai/semantics/metamodel/visitor.py +944 -0
- v0/relationalai/semantics/reasoners/__init__.py +10 -0
- v0/relationalai/semantics/reasoners/graph/__init__.py +37 -0
- v0/relationalai/semantics/reasoners/graph/core.py +9019 -0
- v0/relationalai/semantics/reasoners/optimization/__init__.py +68 -0
- v0/relationalai/semantics/reasoners/optimization/common.py +88 -0
- v0/relationalai/semantics/reasoners/optimization/solvers_dev.py +568 -0
- v0/relationalai/semantics/reasoners/optimization/solvers_pb.py +1163 -0
- v0/relationalai/semantics/rel/builtins.py +40 -0
- v0/relationalai/semantics/rel/compiler.py +989 -0
- v0/relationalai/semantics/rel/executor.py +359 -0
- v0/relationalai/semantics/rel/rel.py +482 -0
- v0/relationalai/semantics/rel/rel_utils.py +276 -0
- v0/relationalai/semantics/snowflake/__init__.py +3 -0
- v0/relationalai/semantics/sql/compiler.py +2503 -0
- v0/relationalai/semantics/sql/executor/duck_db.py +52 -0
- v0/relationalai/semantics/sql/executor/result_helpers.py +64 -0
- v0/relationalai/semantics/sql/executor/snowflake.py +145 -0
- v0/relationalai/semantics/sql/rewrite/denormalize.py +222 -0
- v0/relationalai/semantics/sql/rewrite/double_negation.py +49 -0
- v0/relationalai/semantics/sql/rewrite/recursive_union.py +127 -0
- v0/relationalai/semantics/sql/rewrite/sort_output_query.py +246 -0
- v0/relationalai/semantics/sql/sql.py +504 -0
- v0/relationalai/semantics/std/__init__.py +54 -0
- v0/relationalai/semantics/std/constraints.py +43 -0
- v0/relationalai/semantics/std/datetime.py +363 -0
- v0/relationalai/semantics/std/decimals.py +62 -0
- v0/relationalai/semantics/std/floats.py +7 -0
- v0/relationalai/semantics/std/integers.py +22 -0
- v0/relationalai/semantics/std/math.py +141 -0
- v0/relationalai/semantics/std/pragmas.py +11 -0
- v0/relationalai/semantics/std/re.py +83 -0
- v0/relationalai/semantics/std/std.py +14 -0
- v0/relationalai/semantics/std/strings.py +63 -0
- v0/relationalai/semantics/tests/__init__.py +0 -0
- v0/relationalai/semantics/tests/test_snapshot_abstract.py +143 -0
- v0/relationalai/semantics/tests/test_snapshot_base.py +9 -0
- v0/relationalai/semantics/tests/utils.py +46 -0
- v0/relationalai/std/__init__.py +70 -0
- v0/relationalai/tools/__init__.py +0 -0
- v0/relationalai/tools/cli.py +1940 -0
- v0/relationalai/tools/cli_controls.py +1826 -0
- v0/relationalai/tools/cli_helpers.py +390 -0
- v0/relationalai/tools/debugger.py +183 -0
- v0/relationalai/tools/debugger_client.py +109 -0
- v0/relationalai/tools/debugger_server.py +302 -0
- v0/relationalai/tools/dev.py +685 -0
- v0/relationalai/tools/qb_debugger.py +425 -0
- v0/relationalai/util/clean_up_databases.py +95 -0
- v0/relationalai/util/format.py +123 -0
- v0/relationalai/util/list_databases.py +9 -0
- v0/relationalai/util/otel_configuration.py +25 -0
- v0/relationalai/util/otel_handler.py +484 -0
- v0/relationalai/util/snowflake_handler.py +88 -0
- v0/relationalai/util/span_format_test.py +43 -0
- v0/relationalai/util/span_tracker.py +207 -0
- v0/relationalai/util/spans_file_handler.py +72 -0
- v0/relationalai/util/tracing_handler.py +34 -0
- frontend/debugger/dist/.gitignore +0 -2
- frontend/debugger/dist/assets/favicon-Dy0ZgA6N.png +0 -0
- frontend/debugger/dist/assets/index-Cssla-O7.js +0 -208
- frontend/debugger/dist/assets/index-DlHsYx1V.css +0 -9
- frontend/debugger/dist/index.html +0 -17
- relationalai/clients/__init__.py +0 -18
- relationalai/clients/client.py +0 -946
- relationalai/clients/config.py +0 -673
- relationalai/clients/direct_access_client.py +0 -118
- relationalai/clients/exec_txn_poller.py +0 -153
- relationalai/clients/hash_util.py +0 -31
- relationalai/clients/local.py +0 -594
- relationalai/clients/profile_polling.py +0 -73
- relationalai/clients/resources/__init__.py +0 -8
- relationalai/clients/resources/azure/azure.py +0 -502
- relationalai/clients/resources/snowflake/__init__.py +0 -20
- relationalai/clients/resources/snowflake/cli_resources.py +0 -98
- relationalai/clients/resources/snowflake/direct_access_resources.py +0 -739
- relationalai/clients/resources/snowflake/engine_service.py +0 -381
- relationalai/clients/resources/snowflake/engine_state_handlers.py +0 -315
- relationalai/clients/resources/snowflake/error_handlers.py +0 -240
- relationalai/clients/resources/snowflake/export_procedure.py.jinja +0 -249
- relationalai/clients/resources/snowflake/resources_factory.py +0 -99
- relationalai/clients/resources/snowflake/snowflake.py +0 -3193
- relationalai/clients/resources/snowflake/use_index_poller.py +0 -1019
- relationalai/clients/resources/snowflake/use_index_resources.py +0 -188
- relationalai/clients/resources/snowflake/util.py +0 -387
- relationalai/clients/result_helpers.py +0 -420
- relationalai/clients/types.py +0 -118
- relationalai/clients/util.py +0 -356
- relationalai/debugging.py +0 -389
- relationalai/dsl.py +0 -1749
- relationalai/early_access/builder/__init__.py +0 -30
- relationalai/early_access/builder/builder/__init__.py +0 -35
- relationalai/early_access/builder/snowflake/__init__.py +0 -12
- relationalai/early_access/builder/std/__init__.py +0 -25
- relationalai/early_access/builder/std/decimals/__init__.py +0 -12
- relationalai/early_access/builder/std/integers/__init__.py +0 -12
- relationalai/early_access/builder/std/math/__init__.py +0 -12
- relationalai/early_access/builder/std/strings/__init__.py +0 -14
- relationalai/early_access/devtools/__init__.py +0 -12
- relationalai/early_access/devtools/benchmark_lqp/__init__.py +0 -12
- relationalai/early_access/devtools/extract_lqp/__init__.py +0 -12
- relationalai/early_access/dsl/adapters/orm/adapter_qb.py +0 -427
- relationalai/early_access/dsl/adapters/orm/parser.py +0 -636
- relationalai/early_access/dsl/adapters/owl/adapter.py +0 -176
- relationalai/early_access/dsl/adapters/owl/parser.py +0 -160
- relationalai/early_access/dsl/bindings/common.py +0 -402
- relationalai/early_access/dsl/bindings/csv.py +0 -170
- relationalai/early_access/dsl/bindings/legacy/binding_models.py +0 -143
- relationalai/early_access/dsl/bindings/snowflake.py +0 -64
- relationalai/early_access/dsl/codegen/binder.py +0 -411
- relationalai/early_access/dsl/codegen/common.py +0 -79
- relationalai/early_access/dsl/codegen/helpers.py +0 -23
- relationalai/early_access/dsl/codegen/relations.py +0 -700
- relationalai/early_access/dsl/codegen/weaver.py +0 -417
- relationalai/early_access/dsl/core/builders/__init__.py +0 -47
- relationalai/early_access/dsl/core/builders/logic.py +0 -19
- relationalai/early_access/dsl/core/builders/scalar_constraint.py +0 -11
- relationalai/early_access/dsl/core/constraints/predicate/atomic.py +0 -455
- relationalai/early_access/dsl/core/constraints/predicate/universal.py +0 -73
- relationalai/early_access/dsl/core/constraints/scalar.py +0 -310
- relationalai/early_access/dsl/core/context.py +0 -13
- relationalai/early_access/dsl/core/cset.py +0 -132
- relationalai/early_access/dsl/core/exprs/__init__.py +0 -116
- relationalai/early_access/dsl/core/exprs/relational.py +0 -18
- relationalai/early_access/dsl/core/exprs/scalar.py +0 -412
- relationalai/early_access/dsl/core/instances.py +0 -44
- relationalai/early_access/dsl/core/logic/__init__.py +0 -193
- relationalai/early_access/dsl/core/logic/aggregation.py +0 -98
- relationalai/early_access/dsl/core/logic/exists.py +0 -223
- relationalai/early_access/dsl/core/logic/helper.py +0 -163
- relationalai/early_access/dsl/core/namespaces.py +0 -32
- relationalai/early_access/dsl/core/relations.py +0 -276
- relationalai/early_access/dsl/core/rules.py +0 -112
- relationalai/early_access/dsl/core/std/__init__.py +0 -45
- relationalai/early_access/dsl/core/temporal/recall.py +0 -6
- relationalai/early_access/dsl/core/types/__init__.py +0 -270
- relationalai/early_access/dsl/core/types/concepts.py +0 -128
- relationalai/early_access/dsl/core/types/constrained/__init__.py +0 -267
- relationalai/early_access/dsl/core/types/constrained/nominal.py +0 -143
- relationalai/early_access/dsl/core/types/constrained/subtype.py +0 -124
- relationalai/early_access/dsl/core/types/standard.py +0 -92
- relationalai/early_access/dsl/core/types/unconstrained.py +0 -50
- relationalai/early_access/dsl/core/types/variables.py +0 -203
- relationalai/early_access/dsl/ir/compiler.py +0 -318
- relationalai/early_access/dsl/ir/executor.py +0 -260
- relationalai/early_access/dsl/ontologies/constraints.py +0 -88
- relationalai/early_access/dsl/ontologies/export.py +0 -30
- relationalai/early_access/dsl/ontologies/models.py +0 -453
- relationalai/early_access/dsl/ontologies/python_printer.py +0 -303
- relationalai/early_access/dsl/ontologies/readings.py +0 -60
- relationalai/early_access/dsl/ontologies/relationships.py +0 -322
- relationalai/early_access/dsl/ontologies/roles.py +0 -87
- relationalai/early_access/dsl/ontologies/subtyping.py +0 -55
- relationalai/early_access/dsl/orm/constraints.py +0 -438
- relationalai/early_access/dsl/orm/measures/dimensions.py +0 -200
- relationalai/early_access/dsl/orm/measures/initializer.py +0 -16
- relationalai/early_access/dsl/orm/measures/measure_rules.py +0 -275
- relationalai/early_access/dsl/orm/measures/measures.py +0 -299
- relationalai/early_access/dsl/orm/measures/role_exprs.py +0 -268
- relationalai/early_access/dsl/orm/models.py +0 -256
- relationalai/early_access/dsl/orm/object_oriented_printer.py +0 -344
- relationalai/early_access/dsl/orm/printer.py +0 -469
- relationalai/early_access/dsl/orm/reasoners.py +0 -480
- relationalai/early_access/dsl/orm/relations.py +0 -19
- relationalai/early_access/dsl/orm/relationships.py +0 -251
- relationalai/early_access/dsl/orm/types.py +0 -42
- relationalai/early_access/dsl/orm/utils.py +0 -79
- relationalai/early_access/dsl/orm/verb.py +0 -204
- relationalai/early_access/dsl/physical_metadata/tables.py +0 -133
- relationalai/early_access/dsl/relations.py +0 -170
- relationalai/early_access/dsl/rulesets.py +0 -69
- relationalai/early_access/dsl/schemas/__init__.py +0 -450
- relationalai/early_access/dsl/schemas/builder.py +0 -48
- relationalai/early_access/dsl/schemas/comp_names.py +0 -51
- relationalai/early_access/dsl/schemas/components.py +0 -203
- relationalai/early_access/dsl/schemas/contexts.py +0 -156
- relationalai/early_access/dsl/schemas/exprs.py +0 -89
- relationalai/early_access/dsl/schemas/fragments.py +0 -464
- relationalai/early_access/dsl/serialization.py +0 -79
- relationalai/early_access/dsl/serialize/exporter.py +0 -163
- relationalai/early_access/dsl/snow/api.py +0 -105
- relationalai/early_access/dsl/snow/common.py +0 -76
- relationalai/early_access/dsl/state_mgmt/__init__.py +0 -129
- relationalai/early_access/dsl/state_mgmt/state_charts.py +0 -125
- relationalai/early_access/dsl/state_mgmt/transitions.py +0 -130
- relationalai/early_access/dsl/types/__init__.py +0 -40
- relationalai/early_access/dsl/types/concepts.py +0 -12
- relationalai/early_access/dsl/types/entities.py +0 -135
- relationalai/early_access/dsl/types/values.py +0 -17
- relationalai/early_access/dsl/utils.py +0 -102
- relationalai/early_access/graphs/__init__.py +0 -13
- relationalai/early_access/lqp/__init__.py +0 -12
- relationalai/early_access/lqp/compiler/__init__.py +0 -12
- relationalai/early_access/lqp/constructors/__init__.py +0 -18
- relationalai/early_access/lqp/executor/__init__.py +0 -12
- relationalai/early_access/lqp/ir/__init__.py +0 -12
- relationalai/early_access/lqp/passes/__init__.py +0 -12
- relationalai/early_access/lqp/pragmas/__init__.py +0 -12
- relationalai/early_access/lqp/primitives/__init__.py +0 -12
- relationalai/early_access/lqp/types/__init__.py +0 -12
- relationalai/early_access/lqp/utils/__init__.py +0 -12
- relationalai/early_access/lqp/validators/__init__.py +0 -12
- relationalai/early_access/metamodel/__init__.py +0 -58
- relationalai/early_access/metamodel/builtins/__init__.py +0 -12
- relationalai/early_access/metamodel/compiler/__init__.py +0 -12
- relationalai/early_access/metamodel/dependency/__init__.py +0 -12
- relationalai/early_access/metamodel/factory/__init__.py +0 -17
- relationalai/early_access/metamodel/helpers/__init__.py +0 -12
- relationalai/early_access/metamodel/ir/__init__.py +0 -14
- relationalai/early_access/metamodel/rewrite/__init__.py +0 -7
- relationalai/early_access/metamodel/typer/__init__.py +0 -3
- relationalai/early_access/metamodel/typer/typer/__init__.py +0 -12
- relationalai/early_access/metamodel/types/__init__.py +0 -15
- relationalai/early_access/metamodel/util/__init__.py +0 -15
- relationalai/early_access/metamodel/visitor/__init__.py +0 -12
- relationalai/early_access/rel/__init__.py +0 -12
- relationalai/early_access/rel/executor/__init__.py +0 -12
- relationalai/early_access/rel/rel_utils/__init__.py +0 -12
- relationalai/early_access/rel/rewrite/__init__.py +0 -7
- relationalai/early_access/solvers/__init__.py +0 -19
- relationalai/early_access/sql/__init__.py +0 -11
- relationalai/early_access/sql/executor/__init__.py +0 -3
- relationalai/early_access/sql/rewrite/__init__.py +0 -3
- relationalai/early_access/tests/logging/__init__.py +0 -12
- relationalai/early_access/tests/test_snapshot_base/__init__.py +0 -12
- relationalai/early_access/tests/utils/__init__.py +0 -12
- relationalai/environments/__init__.py +0 -35
- relationalai/environments/base.py +0 -381
- relationalai/environments/colab.py +0 -14
- relationalai/environments/generic.py +0 -71
- relationalai/environments/ipython.py +0 -68
- relationalai/environments/jupyter.py +0 -9
- relationalai/environments/snowbook.py +0 -169
- relationalai/errors.py +0 -2496
- relationalai/experimental/SF.py +0 -38
- relationalai/experimental/inspect.py +0 -47
- relationalai/experimental/pathfinder/__init__.py +0 -158
- relationalai/experimental/pathfinder/api.py +0 -160
- relationalai/experimental/pathfinder/automaton.py +0 -584
- relationalai/experimental/pathfinder/bridge.py +0 -226
- relationalai/experimental/pathfinder/compiler.py +0 -416
- relationalai/experimental/pathfinder/datalog.py +0 -214
- relationalai/experimental/pathfinder/diagnostics.py +0 -56
- relationalai/experimental/pathfinder/filter.py +0 -236
- relationalai/experimental/pathfinder/glushkov.py +0 -439
- relationalai/experimental/pathfinder/options.py +0 -265
- relationalai/experimental/pathfinder/pathfinder-v0.7.0.rel +0 -1951
- relationalai/experimental/pathfinder/rpq.py +0 -344
- relationalai/experimental/pathfinder/transition.py +0 -200
- relationalai/experimental/pathfinder/utils.py +0 -26
- relationalai/experimental/paths/README.md +0 -107
- relationalai/experimental/paths/api.py +0 -143
- relationalai/experimental/paths/benchmarks/grid_graph.py +0 -37
- relationalai/experimental/paths/code_organization.md +0 -2
- relationalai/experimental/paths/examples/Movies.ipynb +0 -16328
- relationalai/experimental/paths/examples/basic_example.py +0 -40
- relationalai/experimental/paths/examples/minimal_engine_warmup.py +0 -3
- relationalai/experimental/paths/examples/movie_example.py +0 -77
- relationalai/experimental/paths/examples/movies_data/actedin.csv +0 -193
- relationalai/experimental/paths/examples/movies_data/directed.csv +0 -45
- relationalai/experimental/paths/examples/movies_data/follows.csv +0 -7
- relationalai/experimental/paths/examples/movies_data/movies.csv +0 -39
- relationalai/experimental/paths/examples/movies_data/person.csv +0 -134
- relationalai/experimental/paths/examples/movies_data/produced.csv +0 -16
- relationalai/experimental/paths/examples/movies_data/ratings.csv +0 -10
- relationalai/experimental/paths/examples/movies_data/wrote.csv +0 -11
- relationalai/experimental/paths/examples/paths_benchmark.py +0 -115
- relationalai/experimental/paths/examples/paths_example.py +0 -116
- relationalai/experimental/paths/examples/pattern_to_automaton.py +0 -28
- relationalai/experimental/paths/find_paths_via_automaton.py +0 -85
- relationalai/experimental/paths/graph.py +0 -185
- relationalai/experimental/paths/path_algorithms/find_paths.py +0 -280
- relationalai/experimental/paths/path_algorithms/one_sided_ball_repetition.py +0 -26
- relationalai/experimental/paths/path_algorithms/one_sided_ball_upto.py +0 -111
- relationalai/experimental/paths/path_algorithms/single.py +0 -59
- relationalai/experimental/paths/path_algorithms/two_sided_balls_repetition.py +0 -39
- relationalai/experimental/paths/path_algorithms/two_sided_balls_upto.py +0 -103
- relationalai/experimental/paths/path_algorithms/usp-old.py +0 -130
- relationalai/experimental/paths/path_algorithms/usp-tuple.py +0 -183
- relationalai/experimental/paths/path_algorithms/usp.py +0 -150
- relationalai/experimental/paths/product_graph.py +0 -93
- relationalai/experimental/paths/rpq/automaton.py +0 -584
- relationalai/experimental/paths/rpq/diagnostics.py +0 -56
- relationalai/experimental/paths/rpq/rpq.py +0 -378
- relationalai/experimental/paths/tests/tests_limit_sp_max_length.py +0 -90
- relationalai/experimental/paths/tests/tests_limit_sp_multiple.py +0 -119
- relationalai/experimental/paths/tests/tests_limit_sp_single.py +0 -104
- relationalai/experimental/paths/tests/tests_limit_walks_multiple.py +0 -113
- relationalai/experimental/paths/tests/tests_limit_walks_single.py +0 -149
- relationalai/experimental/paths/tests/tests_one_sided_ball_repetition_multiple.py +0 -70
- relationalai/experimental/paths/tests/tests_one_sided_ball_repetition_single.py +0 -64
- relationalai/experimental/paths/tests/tests_one_sided_ball_upto_multiple.py +0 -115
- relationalai/experimental/paths/tests/tests_one_sided_ball_upto_single.py +0 -75
- relationalai/experimental/paths/tests/tests_single_paths.py +0 -152
- relationalai/experimental/paths/tests/tests_single_walks.py +0 -208
- relationalai/experimental/paths/tests/tests_single_walks_undirected.py +0 -297
- relationalai/experimental/paths/tests/tests_two_sided_balls_repetition_multiple.py +0 -107
- relationalai/experimental/paths/tests/tests_two_sided_balls_repetition_single.py +0 -76
- relationalai/experimental/paths/tests/tests_two_sided_balls_upto_multiple.py +0 -76
- relationalai/experimental/paths/tests/tests_two_sided_balls_upto_single.py +0 -110
- relationalai/experimental/paths/tests/tests_usp_nsp_multiple.py +0 -229
- relationalai/experimental/paths/tests/tests_usp_nsp_single.py +0 -108
- relationalai/experimental/paths/tree_agg.py +0 -168
- relationalai/experimental/paths/utilities/iterators.py +0 -27
- relationalai/experimental/paths/utilities/prefix_sum.py +0 -91
- relationalai/experimental/solvers.py +0 -1095
- relationalai/loaders/csv.py +0 -195
- relationalai/loaders/loader.py +0 -177
- relationalai/loaders/types.py +0 -23
- relationalai/rel_emitter.py +0 -373
- relationalai/rel_utils.py +0 -185
- relationalai/semantics/designs/query_builder/identify_by.md +0 -106
- relationalai/semantics/devtools/benchmark_lqp.py +0 -535
- relationalai/semantics/devtools/compilation_manager.py +0 -294
- relationalai/semantics/devtools/extract_lqp.py +0 -110
- relationalai/semantics/internal/internal.py +0 -3785
- relationalai/semantics/internal/snowflake.py +0 -329
- relationalai/semantics/lqp/README.md +0 -34
- relationalai/semantics/lqp/algorithms.py +0 -173
- relationalai/semantics/lqp/builtins.py +0 -213
- relationalai/semantics/lqp/compiler.py +0 -22
- relationalai/semantics/lqp/constructors.py +0 -68
- relationalai/semantics/lqp/executor.py +0 -518
- relationalai/semantics/lqp/export_rewriter.py +0 -40
- relationalai/semantics/lqp/intrinsics.py +0 -24
- relationalai/semantics/lqp/ir.py +0 -150
- relationalai/semantics/lqp/model2lqp.py +0 -1056
- relationalai/semantics/lqp/passes.py +0 -38
- relationalai/semantics/lqp/primitives.py +0 -252
- relationalai/semantics/lqp/result_helpers.py +0 -266
- relationalai/semantics/lqp/rewrite/__init__.py +0 -32
- relationalai/semantics/lqp/rewrite/algorithm.py +0 -385
- relationalai/semantics/lqp/rewrite/annotate_constraints.py +0 -69
- relationalai/semantics/lqp/rewrite/cdc.py +0 -216
- relationalai/semantics/lqp/rewrite/constants_to_vars.py +0 -70
- relationalai/semantics/lqp/rewrite/deduplicate_vars.py +0 -104
- relationalai/semantics/lqp/rewrite/eliminate_data.py +0 -108
- relationalai/semantics/lqp/rewrite/extract_common.py +0 -340
- relationalai/semantics/lqp/rewrite/extract_keys.py +0 -577
- relationalai/semantics/lqp/rewrite/flatten_script.py +0 -301
- relationalai/semantics/lqp/rewrite/function_annotations.py +0 -114
- relationalai/semantics/lqp/rewrite/functional_dependencies.py +0 -348
- relationalai/semantics/lqp/rewrite/period_math.py +0 -77
- relationalai/semantics/lqp/rewrite/quantify_vars.py +0 -339
- relationalai/semantics/lqp/rewrite/splinter.py +0 -76
- relationalai/semantics/lqp/rewrite/unify_definitions.py +0 -323
- relationalai/semantics/lqp/types.py +0 -101
- relationalai/semantics/lqp/utils.py +0 -170
- relationalai/semantics/lqp/validators.py +0 -70
- relationalai/semantics/metamodel/compiler.py +0 -134
- relationalai/semantics/metamodel/dependency.py +0 -880
- relationalai/semantics/metamodel/executor.py +0 -78
- relationalai/semantics/metamodel/factory.py +0 -287
- relationalai/semantics/metamodel/helpers.py +0 -368
- relationalai/semantics/metamodel/ir.py +0 -924
- relationalai/semantics/metamodel/rewrite/__init__.py +0 -8
- relationalai/semantics/metamodel/rewrite/discharge_constraints.py +0 -39
- relationalai/semantics/metamodel/rewrite/dnf_union_splitter.py +0 -220
- relationalai/semantics/metamodel/rewrite/extract_nested_logicals.py +0 -78
- relationalai/semantics/metamodel/rewrite/flatten.py +0 -590
- relationalai/semantics/metamodel/rewrite/format_outputs.py +0 -256
- relationalai/semantics/metamodel/rewrite/handle_aggregations_and_ranks.py +0 -237
- relationalai/semantics/metamodel/typer/checker.py +0 -355
- relationalai/semantics/metamodel/typer/typer.py +0 -1396
- relationalai/semantics/metamodel/util.py +0 -506
- relationalai/semantics/metamodel/visitor.py +0 -945
- relationalai/semantics/reasoners/__init__.py +0 -10
- relationalai/semantics/reasoners/graph/README.md +0 -620
- relationalai/semantics/reasoners/graph/__init__.py +0 -37
- relationalai/semantics/reasoners/graph/core.py +0 -9019
- relationalai/semantics/reasoners/graph/design/beyond_demand_transform.md +0 -797
- relationalai/semantics/reasoners/graph/tests/README.md +0 -21
- relationalai/semantics/reasoners/optimization/__init__.py +0 -68
- relationalai/semantics/reasoners/optimization/common.py +0 -88
- relationalai/semantics/reasoners/optimization/solvers_dev.py +0 -568
- relationalai/semantics/reasoners/optimization/solvers_pb.py +0 -1407
- relationalai/semantics/rel/builtins.py +0 -40
- relationalai/semantics/rel/compiler.py +0 -994
- relationalai/semantics/rel/executor.py +0 -363
- relationalai/semantics/rel/rel.py +0 -482
- relationalai/semantics/rel/rel_utils.py +0 -276
- relationalai/semantics/snowflake/__init__.py +0 -3
- relationalai/semantics/sql/compiler.py +0 -2503
- relationalai/semantics/sql/executor/duck_db.py +0 -52
- relationalai/semantics/sql/executor/result_helpers.py +0 -64
- relationalai/semantics/sql/executor/snowflake.py +0 -149
- relationalai/semantics/sql/rewrite/denormalize.py +0 -222
- relationalai/semantics/sql/rewrite/double_negation.py +0 -49
- relationalai/semantics/sql/rewrite/recursive_union.py +0 -127
- relationalai/semantics/sql/rewrite/sort_output_query.py +0 -246
- relationalai/semantics/sql/sql.py +0 -504
- relationalai/semantics/std/pragmas.py +0 -11
- relationalai/semantics/std/std.py +0 -14
- relationalai/semantics/tests/lqp/algorithms.py +0 -345
- relationalai/semantics/tests/test_snapshot_abstract.py +0 -144
- relationalai/semantics/tests/test_snapshot_base.py +0 -9
- relationalai/semantics/tests/utils.py +0 -46
- relationalai/std/__init__.py +0 -70
- relationalai/tools/cli.py +0 -2089
- relationalai/tools/cli_controls.py +0 -1975
- relationalai/tools/cli_helpers.py +0 -802
- relationalai/tools/debugger_client.py +0 -109
- relationalai/tools/debugger_server.py +0 -302
- relationalai/tools/dev.py +0 -685
- relationalai/tools/notes +0 -7
- relationalai/tools/qb_debugger.py +0 -425
- relationalai/tools/txn_progress.py +0 -188
- relationalai/util/clean_up_databases.py +0 -95
- relationalai/util/list_databases.py +0 -9
- relationalai/util/otel_configuration.py +0 -26
- relationalai/util/otel_handler.py +0 -484
- relationalai/util/snowflake_handler.py +0 -88
- relationalai/util/span_format_test.py +0 -43
- relationalai/util/span_tracker.py +0 -207
- relationalai/util/spans_file_handler.py +0 -72
- relationalai/util/tracing_handler.py +0 -34
- relationalai-0.13.5.dist-info/METADATA +0 -74
- relationalai-0.13.5.dist-info/RECORD +0 -473
- relationalai-0.13.5.dist-info/WHEEL +0 -4
- relationalai-0.13.5.dist-info/entry_points.txt +0 -3
- relationalai-0.13.5.dist-info/licenses/LICENSE +0 -202
- relationalai_test_util/__init__.py +0 -4
- relationalai_test_util/fixtures.py +0 -233
- relationalai_test_util/snapshot.py +0 -252
- relationalai_test_util/traceback.py +0 -118
- /relationalai/{analysis → semantics/frontend}/__init__.py +0 -0
- /relationalai/{auth/__init__.py → semantics/metamodel/metamodel_compiler.py} +0 -0
- /relationalai/{early_access → shims}/__init__.py +0 -0
- {relationalai/early_access/dsl/adapters → v0/relationalai/analysis}/__init__.py +0 -0
- {relationalai → v0/relationalai}/analysis/mechanistic.py +0 -0
- {relationalai → v0/relationalai}/analysis/whynot.py +0 -0
- {relationalai/early_access/dsl/adapters/orm → v0/relationalai/auth}/__init__.py +0 -0
- {relationalai → v0/relationalai}/auth/jwt_generator.py +0 -0
- {relationalai → v0/relationalai}/auth/oauth_callback_server.py +0 -0
- {relationalai → v0/relationalai}/auth/token_handler.py +0 -0
- {relationalai → v0/relationalai}/auth/util.py +0 -0
- {relationalai/clients/resources/snowflake → v0/relationalai/clients}/cache_store.py +0 -0
- {relationalai → v0/relationalai}/compiler.py +0 -0
- {relationalai → v0/relationalai}/dependencies.py +0 -0
- {relationalai → v0/relationalai}/docutils.py +0 -0
- {relationalai/early_access/dsl/adapters/owl → v0/relationalai/early_access}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/__init__.py +0 -0
- {relationalai/early_access/dsl/bindings → v0/relationalai/early_access/dsl/adapters}/__init__.py +0 -0
- {relationalai/early_access/dsl/bindings/legacy → v0/relationalai/early_access/dsl/adapters/orm}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/adapters/orm/model.py +0 -0
- {relationalai/early_access/dsl/codegen → v0/relationalai/early_access/dsl/adapters/owl}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/adapters/owl/model.py +0 -0
- {relationalai/early_access/dsl/core/temporal → v0/relationalai/early_access/dsl/bindings}/__init__.py +0 -0
- {relationalai/early_access/dsl/ir → v0/relationalai/early_access/dsl/bindings/legacy}/__init__.py +0 -0
- {relationalai/early_access/dsl/ontologies → v0/relationalai/early_access/dsl/codegen}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/constants.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/core/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/core/constraints/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/core/constraints/predicate/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/core/stack.py +0 -0
- {relationalai/early_access/dsl/orm → v0/relationalai/early_access/dsl/core/temporal}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/core/utils.py +0 -0
- {relationalai/early_access/dsl/orm/measures → v0/relationalai/early_access/dsl/ir}/__init__.py +0 -0
- {relationalai/early_access/dsl/physical_metadata → v0/relationalai/early_access/dsl/ontologies}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/ontologies/raw_source.py +0 -0
- {relationalai/early_access/dsl/serialize → v0/relationalai/early_access/dsl/orm}/__init__.py +0 -0
- {relationalai/early_access/dsl/snow → v0/relationalai/early_access/dsl/orm/measures}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/orm/reasoner_errors.py +0 -0
- {relationalai/loaders → v0/relationalai/early_access/dsl/physical_metadata}/__init__.py +0 -0
- {relationalai/semantics/tests → v0/relationalai/early_access/dsl/serialize}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/serialize/binding_model.py +0 -0
- {relationalai → v0/relationalai}/early_access/dsl/serialize/model.py +0 -0
- {relationalai/semantics/tests/lqp → v0/relationalai/early_access/dsl/snow}/__init__.py +0 -0
- {relationalai → v0/relationalai}/early_access/tests/__init__.py +0 -0
- {relationalai → v0/relationalai}/environments/ci.py +0 -0
- {relationalai → v0/relationalai}/environments/hex.py +0 -0
- {relationalai → v0/relationalai}/environments/terminal.py +0 -0
- {relationalai → v0/relationalai}/experimental/__init__.py +0 -0
- {relationalai → v0/relationalai}/experimental/graphs.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/__init__.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/benchmarks/__init__.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/path_algorithms/__init__.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/rpq/__init__.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/rpq/filter.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/rpq/glushkov.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/rpq/transition.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/utilities/__init__.py +0 -0
- {relationalai → v0/relationalai}/experimental/paths/utilities/utilities.py +0 -0
- {relationalai/tools → v0/relationalai/loaders}/__init__.py +0 -0
- {relationalai → v0/relationalai}/metagen.py +0 -0
- {relationalai → v0/relationalai}/metamodel.py +0 -0
- {relationalai → v0/relationalai}/rel.py +0 -0
- {relationalai → v0/relationalai}/semantics/devtools/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/internal/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/internal/annotations.py +0 -0
- {relationalai → v0/relationalai}/semantics/lqp/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/lqp/pragmas.py +0 -0
- {relationalai → v0/relationalai}/semantics/metamodel/dataflow.py +0 -0
- {relationalai → v0/relationalai}/semantics/metamodel/typer/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/metamodel/types.py +0 -0
- {relationalai → v0/relationalai}/semantics/reasoners/experimental/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/rel/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/sql/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/sql/executor/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/sql/rewrite/__init__.py +0 -0
- {relationalai → v0/relationalai}/semantics/tests/logging.py +0 -0
- {relationalai → v0/relationalai}/std/aggregates.py +0 -0
- {relationalai → v0/relationalai}/std/dates.py +0 -0
- {relationalai → v0/relationalai}/std/graphs.py +0 -0
- {relationalai → v0/relationalai}/std/inspect.py +0 -0
- {relationalai → v0/relationalai}/std/math.py +0 -0
- {relationalai → v0/relationalai}/std/re.py +0 -0
- {relationalai → v0/relationalai}/std/strings.py +0 -0
- {relationalai → v0/relationalai}/tools/cleanup_snapshots.py +0 -0
- {relationalai → v0/relationalai}/tools/constants.py +0 -0
- {relationalai → v0/relationalai}/tools/query_utils.py +0 -0
- {relationalai → v0/relationalai}/tools/snapshot_viewer.py +0 -0
- {relationalai → v0/relationalai}/util/__init__.py +0 -0
- {relationalai → v0/relationalai}/util/constants.py +0 -0
- {relationalai → v0/relationalai}/util/graph.py +0 -0
- {relationalai → v0/relationalai}/util/timeout.py +0 -0
|
@@ -1,802 +0,0 @@
|
|
|
1
|
-
#pyright: reportPrivateImportUsage=false
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
import io
|
|
4
|
-
import json
|
|
5
|
-
import os
|
|
6
|
-
import re
|
|
7
|
-
import sys
|
|
8
|
-
import requests
|
|
9
|
-
import rich
|
|
10
|
-
import click
|
|
11
|
-
import functools
|
|
12
|
-
import pytz
|
|
13
|
-
from typing import NoReturn
|
|
14
|
-
|
|
15
|
-
from relationalai.util.constants import TOP_LEVEL_PROFILE_NAME
|
|
16
|
-
from relationalai.errors import RAIException
|
|
17
|
-
from rich.table import Table
|
|
18
|
-
from typing import Callable, Dict, Any, List, cast
|
|
19
|
-
from ..clients import config
|
|
20
|
-
from click.core import Context
|
|
21
|
-
from rich.console import Console
|
|
22
|
-
from rich import box as rich_box
|
|
23
|
-
from collections import defaultdict
|
|
24
|
-
from packaging.version import Version
|
|
25
|
-
from ..clients.config import ConfigFile
|
|
26
|
-
from datetime import datetime, timedelta
|
|
27
|
-
from click.formatting import HelpFormatter
|
|
28
|
-
from ..clients.client import ResourcesBase
|
|
29
|
-
from relationalai.tools.constants import GlobalProfile, SHOW_FULL_TRACES
|
|
30
|
-
from relationalai.tools.cli_controls import divider
|
|
31
|
-
from relationalai.util.format import humanized_bytes, humanized_duration
|
|
32
|
-
from InquirerPy.base.control import Choice
|
|
33
|
-
|
|
34
|
-
#--------------------------------------------------
|
|
35
|
-
# Helpers
|
|
36
|
-
#--------------------------------------------------
|
|
37
|
-
|
|
38
|
-
@functools.cache
|
|
39
|
-
def get_config(profile:str|Dict[str, Any]|None = None):
|
|
40
|
-
return config.Config(profile or GlobalProfile.get())
|
|
41
|
-
|
|
42
|
-
@functools.cache
|
|
43
|
-
def get_resource_provider(platform:str|None=None, _cfg:config.Config|None = None) -> ResourcesBase:
|
|
44
|
-
cfg = _cfg or get_config()
|
|
45
|
-
platform = platform or cfg.get("platform", "snowflake")
|
|
46
|
-
if platform == "snowflake":
|
|
47
|
-
from relationalai.clients.resources.snowflake.cli_resources import CLIResources
|
|
48
|
-
provider = CLIResources(config=cfg)
|
|
49
|
-
elif platform == "azure":
|
|
50
|
-
from relationalai.clients.resources.azure.azure import Resources
|
|
51
|
-
provider = Resources(config=cfg)
|
|
52
|
-
else:
|
|
53
|
-
from .. import Resources
|
|
54
|
-
provider = Resources(config=cfg)
|
|
55
|
-
return provider
|
|
56
|
-
|
|
57
|
-
def unexpand_user_path(path):
|
|
58
|
-
"""Inverse of os.path.expanduser"""
|
|
59
|
-
home_dir = os.path.expanduser('~')
|
|
60
|
-
if path.startswith(home_dir):
|
|
61
|
-
return '~' + path[len(home_dir):]
|
|
62
|
-
return path
|
|
63
|
-
|
|
64
|
-
def account_from_url(account_or_url:str):
|
|
65
|
-
regex = r"https://app.snowflake.com/([^/]+)/([^/]+)/?.*"
|
|
66
|
-
match = re.match(regex, account_or_url)
|
|
67
|
-
if match:
|
|
68
|
-
org = match.group(1)
|
|
69
|
-
account = match.group(2)
|
|
70
|
-
return f"{org}-{account}"
|
|
71
|
-
elif "app.snowflake.com" in account_or_url or "https://" in account_or_url:
|
|
72
|
-
raise ValueError("URL not of the form https://app.snowflake.com/[org]/[account]")
|
|
73
|
-
else:
|
|
74
|
-
return account_or_url
|
|
75
|
-
|
|
76
|
-
def supports_platform(*platform_names: str):
|
|
77
|
-
def decorator(cmd: click.Command):
|
|
78
|
-
setattr(cmd, "__available_platforms", platform_names)
|
|
79
|
-
cb = cmd.callback
|
|
80
|
-
assert cb
|
|
81
|
-
def checked(*args, **kwargs):
|
|
82
|
-
assert cmd.name
|
|
83
|
-
assert_command_available(cmd.name, command_available(cmd))
|
|
84
|
-
return cb(*args, **kwargs)
|
|
85
|
-
|
|
86
|
-
cmd.callback = checked
|
|
87
|
-
return cmd
|
|
88
|
-
return decorator
|
|
89
|
-
|
|
90
|
-
def command_available(cmd: click.Command) -> bool:
|
|
91
|
-
available_platforms = getattr(cmd, "__available_platforms", ())
|
|
92
|
-
platform = get_config().get("platform", "")
|
|
93
|
-
return not available_platforms or not platform or platform in available_platforms
|
|
94
|
-
|
|
95
|
-
def assert_command_available(name: str, available: bool, plural=False):
|
|
96
|
-
if not available:
|
|
97
|
-
platform = get_config().get("platform", "")
|
|
98
|
-
rich.print(f"[yellow]{name} {'are' if plural else 'is'} not available for {platform}")
|
|
99
|
-
divider()
|
|
100
|
-
sys.exit(1)
|
|
101
|
-
|
|
102
|
-
def coming_soon():
|
|
103
|
-
rich.print("[yellow]This isn't quite ready yet, but it's coming soon!")
|
|
104
|
-
divider()
|
|
105
|
-
sys.exit(1)
|
|
106
|
-
|
|
107
|
-
def issue_top_level_profile_warning():
|
|
108
|
-
rich.print("[yellow]Warning: Using a top-level profile is not recommended")
|
|
109
|
-
rich.print("[yellow]Consider naming the profile by adding \\[profile.<name>] to your raiconfig.toml file\n")
|
|
110
|
-
rich.print("[yellow]Example:")
|
|
111
|
-
rich.print("[yellow]\\[profile.default]")
|
|
112
|
-
rich.print("[yellow]platform = \"snowflake\"")
|
|
113
|
-
rich.print("[yellow]account = ...")
|
|
114
|
-
divider()
|
|
115
|
-
|
|
116
|
-
def ensure_config(profile:str|None=None) -> config.Config:
|
|
117
|
-
cfg = get_config(profile)
|
|
118
|
-
if not cfg.file_path:
|
|
119
|
-
rich.print("[yellow bold]No configuration file found.")
|
|
120
|
-
rich.print("To create one, run: [green bold]rai init[/green bold]")
|
|
121
|
-
divider()
|
|
122
|
-
sys.exit(1)
|
|
123
|
-
return cfg
|
|
124
|
-
|
|
125
|
-
def latest_version(package_name):
|
|
126
|
-
"""Get the current version of a package on PyPI."""
|
|
127
|
-
url = f"https://pypi.org/pypi/{package_name}/json"
|
|
128
|
-
response = requests.get(url)
|
|
129
|
-
if response.status_code == 200:
|
|
130
|
-
data = response.json()
|
|
131
|
-
version = data['info']['version']
|
|
132
|
-
return version
|
|
133
|
-
else:
|
|
134
|
-
return None
|
|
135
|
-
|
|
136
|
-
def is_latest_cli_version():
|
|
137
|
-
from .. import __version__
|
|
138
|
-
latest_ver_str = latest_version("relationalai")
|
|
139
|
-
latest_ver = Version(latest_ver_str) if latest_ver_str else Version("0.0.0")
|
|
140
|
-
version = Version(__version__)
|
|
141
|
-
return version >= latest_ver, version, latest_ver
|
|
142
|
-
|
|
143
|
-
#--------------------------------------------------
|
|
144
|
-
# Validation
|
|
145
|
-
#--------------------------------------------------
|
|
146
|
-
|
|
147
|
-
EMPTY_STRING_REGEX = re.compile(r'^\S+$')
|
|
148
|
-
ENGINE_NAME_REGEX = re.compile(r'^[a-zA-Z]\w{2,}$')
|
|
149
|
-
COMPUTE_POOL_REGEX = re.compile(r'^[a-zA-Z][a-zA-Z0-9_]*$')
|
|
150
|
-
PASSCODE_REGEX = re.compile(r'^(\d{6})?$')
|
|
151
|
-
ENGINE_NAME_ERROR = "Min 3 chars, start with letter, only letters, numbers, underscores allowed."
|
|
152
|
-
UUID = re.compile('[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')
|
|
153
|
-
|
|
154
|
-
def validate_engine_name(name:str) -> tuple[bool, str|None]:
|
|
155
|
-
if not ENGINE_NAME_REGEX.match(name):
|
|
156
|
-
return False, ENGINE_NAME_ERROR
|
|
157
|
-
return True, None
|
|
158
|
-
|
|
159
|
-
#--------------------------------------------------
|
|
160
|
-
# Engine types & selection helpers (Snowflake)
|
|
161
|
-
#--------------------------------------------------
|
|
162
|
-
|
|
163
|
-
def format_state_with_color(state: str) -> str:
|
|
164
|
-
"""Format engine state with colors for display."""
|
|
165
|
-
if not state:
|
|
166
|
-
return ""
|
|
167
|
-
state_upper = state.upper()
|
|
168
|
-
if state_upper == "READY":
|
|
169
|
-
return f"[green]{state_upper}[/green]"
|
|
170
|
-
if state_upper == "SUSPENDED":
|
|
171
|
-
return f"[yellow]{state_upper}[/yellow]"
|
|
172
|
-
if state_upper in ("PENDING", "SYNCING", "PROCESSING"):
|
|
173
|
-
return f"[bold yellow]{state_upper}[/bold yellow]"
|
|
174
|
-
if state_upper in ("ABORTED", "QUARANTINED", "GONE"):
|
|
175
|
-
return f"[red]{state_upper}[/red]"
|
|
176
|
-
return state_upper
|
|
177
|
-
|
|
178
|
-
def _get_engine_type_api():
|
|
179
|
-
# Local import to avoid importing snowflake modules for non-snowflake usage
|
|
180
|
-
from relationalai.clients.resources.snowflake import EngineType
|
|
181
|
-
return EngineType
|
|
182
|
-
|
|
183
|
-
def _get_internal_engine_sizes() -> list[str]:
|
|
184
|
-
# Local import to avoid snowflake imports for non-snowflake usage
|
|
185
|
-
from relationalai.clients.resources.snowflake import INTERNAL_ENGINE_SIZES
|
|
186
|
-
return list(INTERNAL_ENGINE_SIZES)
|
|
187
|
-
|
|
188
|
-
def get_engine_type_choices(cfg: config.Config, exclude_types: List[str] | None = None) -> List[Choice]:
|
|
189
|
-
"""Get sorted list of engine type choices for interactive selection."""
|
|
190
|
-
EngineType = _get_engine_type_api()
|
|
191
|
-
if exclude_types is None:
|
|
192
|
-
exclude_types = []
|
|
193
|
-
exclude_types_upper = [et.upper() for et in exclude_types]
|
|
194
|
-
engine_types_list = [EngineType.LOGIC, EngineType.ML, EngineType.SOLVER]
|
|
195
|
-
engine_types_list = [et for et in engine_types_list if et.upper() not in exclude_types_upper]
|
|
196
|
-
engine_types_list.sort(key=lambda et: EngineType.get_label(et))
|
|
197
|
-
return [
|
|
198
|
-
Choice(value=et, name=f"{EngineType.get_label(et)}: {EngineType.get_description(et)}")
|
|
199
|
-
for et in engine_types_list
|
|
200
|
-
]
|
|
201
|
-
|
|
202
|
-
def select_engine_type_interactive(cfg: config.Config) -> str:
|
|
203
|
-
"""Show interactive engine type selection and return the selected type."""
|
|
204
|
-
from . import cli_controls as controls
|
|
205
|
-
rich.print("")
|
|
206
|
-
engine_type_choices = get_engine_type_choices(cfg)
|
|
207
|
-
return controls.select("Engine type:", cast("list[str | Choice]", engine_type_choices), None, newline=True)
|
|
208
|
-
|
|
209
|
-
def select_engine_interactive(
|
|
210
|
-
provider: ResourcesBase,
|
|
211
|
-
prompt: str = "Select an engine:",
|
|
212
|
-
engine_name: str | None = None,
|
|
213
|
-
engines: List[Dict[str, Any]] | None = None,
|
|
214
|
-
) -> tuple[str, str | None] | None:
|
|
215
|
-
"""Interactive engine picker returning (name, type)."""
|
|
216
|
-
from . import cli_controls as controls
|
|
217
|
-
|
|
218
|
-
engine_map: Dict[str, tuple[str, str | None]] = {}
|
|
219
|
-
|
|
220
|
-
def get_engines():
|
|
221
|
-
engine_list = engines if engines is not None else provider.list_engines()
|
|
222
|
-
engine_map.clear()
|
|
223
|
-
items: List[str] = []
|
|
224
|
-
EngineType = _get_engine_type_api()
|
|
225
|
-
for engine in engine_list:
|
|
226
|
-
eng_name = engine.get("name", "")
|
|
227
|
-
if engine_name and eng_name.upper() != engine_name.upper():
|
|
228
|
-
continue
|
|
229
|
-
eng_type = engine.get("type", "")
|
|
230
|
-
eng_size = engine.get("size", "")
|
|
231
|
-
if eng_type:
|
|
232
|
-
label = f"{EngineType.get_label(eng_type)} ({eng_type})" if EngineType.is_valid(eng_type) else f"{eng_type} ({eng_type})"
|
|
233
|
-
display = f"{eng_name}, {label}, {eng_size}"
|
|
234
|
-
else:
|
|
235
|
-
display = f"{eng_name}, {eng_size}" if eng_size else eng_name
|
|
236
|
-
engine_map[display] = (eng_name, eng_type or None)
|
|
237
|
-
items.append(display)
|
|
238
|
-
return items
|
|
239
|
-
|
|
240
|
-
# Auto-select when engine_name uniquely identifies an engine
|
|
241
|
-
if engine_name:
|
|
242
|
-
engine_list = engines if engines is not None else provider.list_engines()
|
|
243
|
-
matches = [e for e in engine_list if e.get("name", "").upper() == engine_name.upper()]
|
|
244
|
-
if len(matches) == 1:
|
|
245
|
-
e = matches[0]
|
|
246
|
-
return (e.get("name", ""), e.get("type"))
|
|
247
|
-
if len(matches) == 0:
|
|
248
|
-
return None
|
|
249
|
-
|
|
250
|
-
selected = controls.fuzzy_with_refetch(prompt, "engines", get_engines)
|
|
251
|
-
if not selected or isinstance(selected, Exception):
|
|
252
|
-
return None
|
|
253
|
-
return engine_map.get(selected)
|
|
254
|
-
|
|
255
|
-
def select_engine_with_state_filter(
|
|
256
|
-
provider: ResourcesBase,
|
|
257
|
-
engine_name: str | None,
|
|
258
|
-
engine_type: str | None,
|
|
259
|
-
state_filter: str,
|
|
260
|
-
prompt_no_name: str,
|
|
261
|
-
prompt_with_name: str,
|
|
262
|
-
error_no_engines: str,
|
|
263
|
-
error_no_matching: str,
|
|
264
|
-
) -> tuple[str, str | None] | None:
|
|
265
|
-
"""Select an engine with optional state filtering + optional name filtering."""
|
|
266
|
-
EngineType = _get_engine_type_api()
|
|
267
|
-
|
|
268
|
-
if not engine_name:
|
|
269
|
-
filtered = provider.list_engines(state_filter)
|
|
270
|
-
if not filtered:
|
|
271
|
-
exit_with_error(error_no_engines)
|
|
272
|
-
return select_engine_interactive(provider, prompt_no_name, engines=filtered)
|
|
273
|
-
|
|
274
|
-
# If type provided and valid, return directly
|
|
275
|
-
if engine_type and EngineType.is_valid(engine_type):
|
|
276
|
-
return (engine_name, engine_type)
|
|
277
|
-
|
|
278
|
-
# Filter by name + state; selection handles (name,type)
|
|
279
|
-
filtered = provider.list_engines(state_filter, name=engine_name)
|
|
280
|
-
if not filtered:
|
|
281
|
-
exit_with_error(error_no_matching)
|
|
282
|
-
return select_engine_interactive(provider, prompt_with_name, engine_name=engine_name, engines=filtered)
|
|
283
|
-
|
|
284
|
-
def ensure_engine_type_for_snowflake(
|
|
285
|
-
provider: ResourcesBase,
|
|
286
|
-
engine_name: str,
|
|
287
|
-
engine_type: str | None,
|
|
288
|
-
error_message: str,
|
|
289
|
-
) -> str:
|
|
290
|
-
"""Ensure engine_type is provided and valid; default to LOGIC if omitted."""
|
|
291
|
-
EngineType = _get_engine_type_api()
|
|
292
|
-
# If --type was omitted, default to LOGIC for backwards compatibility
|
|
293
|
-
if engine_type is None:
|
|
294
|
-
return EngineType.LOGIC
|
|
295
|
-
assert isinstance(engine_type, str)
|
|
296
|
-
if engine_type == "" or not EngineType.is_valid(engine_type):
|
|
297
|
-
cfg = get_config()
|
|
298
|
-
if engine_type == "":
|
|
299
|
-
rich.print(f"[yellow]Empty engine type provided for engine '{engine_name}'.")
|
|
300
|
-
else:
|
|
301
|
-
rich.print(f"[yellow]Invalid engine type '{engine_type}' for engine '{engine_name}'.")
|
|
302
|
-
return select_engine_type_interactive(cfg)
|
|
303
|
-
return engine_type
|
|
304
|
-
|
|
305
|
-
def build_engine_operation_messages(
|
|
306
|
-
provider: ResourcesBase,
|
|
307
|
-
engine_name: str,
|
|
308
|
-
engine_type: str | None,
|
|
309
|
-
action: str,
|
|
310
|
-
action_past: str,
|
|
311
|
-
) -> tuple[str, str]:
|
|
312
|
-
EngineType = _get_engine_type_api()
|
|
313
|
-
if engine_type:
|
|
314
|
-
label = EngineType.get_label(engine_type) if EngineType.is_valid(engine_type) else engine_type
|
|
315
|
-
return (f"{action} {label} engine '{engine_name}'", f"{label} Engine '{engine_name}' {action_past.lower()}")
|
|
316
|
-
return (f"{action} '{engine_name}' engine", f"Engine '{engine_name}' {action_past.lower()}")
|
|
317
|
-
|
|
318
|
-
def prompt_and_validate_engine_name(name: str | None) -> str:
|
|
319
|
-
"""Prompt for engine name if missing; validate using ENGINE_NAME_REGEX."""
|
|
320
|
-
from . import cli_controls as controls
|
|
321
|
-
if not name:
|
|
322
|
-
name = controls.prompt(
|
|
323
|
-
"Engine name:",
|
|
324
|
-
name,
|
|
325
|
-
validator=ENGINE_NAME_REGEX.match,
|
|
326
|
-
invalid_message=ENGINE_NAME_ERROR,
|
|
327
|
-
newline=True,
|
|
328
|
-
)
|
|
329
|
-
assert isinstance(name, str)
|
|
330
|
-
return name
|
|
331
|
-
|
|
332
|
-
def validate_auto_suspend_mins(auto_suspend_mins: int | str | None) -> int | None:
|
|
333
|
-
if auto_suspend_mins is None:
|
|
334
|
-
return None
|
|
335
|
-
if isinstance(auto_suspend_mins, int):
|
|
336
|
-
return auto_suspend_mins
|
|
337
|
-
error_msg = f"[yellow]Error: auto_suspend_mins must be an integer instead of {type(auto_suspend_mins)}"
|
|
338
|
-
try:
|
|
339
|
-
return int(auto_suspend_mins)
|
|
340
|
-
except ValueError:
|
|
341
|
-
exit_with_error(error_msg)
|
|
342
|
-
return None
|
|
343
|
-
|
|
344
|
-
def get_engine_type_for_creation(provider: ResourcesBase, cfg: config.Config, engine_type: str | None) -> str | None:
|
|
345
|
-
"""Get engine type for engine creation; defaults to LOGIC when omitted."""
|
|
346
|
-
EngineType = _get_engine_type_api()
|
|
347
|
-
if engine_type is None:
|
|
348
|
-
return EngineType.LOGIC
|
|
349
|
-
if engine_type == "" or not EngineType.is_valid(engine_type):
|
|
350
|
-
if engine_type == "":
|
|
351
|
-
rich.print("[yellow]Empty engine type provided.")
|
|
352
|
-
else:
|
|
353
|
-
valid_types_display = ", ".join(EngineType.get_all_types())
|
|
354
|
-
rich.print(f"[yellow]Invalid engine type '{engine_type}'. Valid types: {valid_types_display}")
|
|
355
|
-
return select_engine_type_interactive(cfg)
|
|
356
|
-
return engine_type
|
|
357
|
-
|
|
358
|
-
def get_and_validate_engine_size(
|
|
359
|
-
provider: ResourcesBase,
|
|
360
|
-
cfg: config.Config,
|
|
361
|
-
size: str | None,
|
|
362
|
-
engine_type: str | None = None,
|
|
363
|
-
) -> str:
|
|
364
|
-
from . import cli_controls as controls
|
|
365
|
-
EngineType = _get_engine_type_api()
|
|
366
|
-
internal_sizes = set(_get_internal_engine_sizes())
|
|
367
|
-
|
|
368
|
-
cloud_provider = provider.get_cloud_provider()
|
|
369
|
-
valid_sizes = provider.get_engine_sizes(cloud_provider)
|
|
370
|
-
|
|
371
|
-
# Engine-type-aware filtering:
|
|
372
|
-
# Internal sizes (XS/S/M/L) are only valid for LOGIC engines (and only on some accounts).
|
|
373
|
-
# For ML/SOLVER, hide them to avoid presenting invalid options.
|
|
374
|
-
if engine_type and EngineType.is_valid(engine_type) and engine_type != EngineType.LOGIC:
|
|
375
|
-
valid_sizes = [s for s in valid_sizes if s not in internal_sizes]
|
|
376
|
-
|
|
377
|
-
# Ask if missing and not in config
|
|
378
|
-
if not size and not cfg.get("engine_size", None):
|
|
379
|
-
rich.print("")
|
|
380
|
-
# This refers to the cloud backing your Snowflake account (AWS/Azure), not the engine "platform".
|
|
381
|
-
size = controls.fuzzy(f"Engine size (Snowflake cloud: {cloud_provider.upper()}):", choices=valid_sizes)
|
|
382
|
-
elif size is None and cfg.get("engine_size", None):
|
|
383
|
-
size = cfg.get("engine_size", None)
|
|
384
|
-
if not isinstance(size, str) or size not in valid_sizes:
|
|
385
|
-
exit_with_error(f"\nInvalid engine size [yellow]{size}[/yellow] provided. Please check your config.\n\nValid sizes: [green]{valid_sizes}[/green]")
|
|
386
|
-
return size
|
|
387
|
-
|
|
388
|
-
def create_engine_with_spinner(
|
|
389
|
-
provider: ResourcesBase,
|
|
390
|
-
engine_name: str,
|
|
391
|
-
engine_size: str,
|
|
392
|
-
engine_type: str | None,
|
|
393
|
-
auto_suspend_mins: int | None,
|
|
394
|
-
) -> None:
|
|
395
|
-
"""Create an engine with appropriate spinner messages and error handling."""
|
|
396
|
-
from .cli_controls import Spinner
|
|
397
|
-
|
|
398
|
-
EngineType = _get_engine_type_api()
|
|
399
|
-
# Build creation message with engine type when available
|
|
400
|
-
if engine_type:
|
|
401
|
-
creation_message = (
|
|
402
|
-
f"Creating {EngineType.get_label(engine_type)} engine '{engine_name}' with size {engine_size}... "
|
|
403
|
-
f"(this may take several minutes)"
|
|
404
|
-
)
|
|
405
|
-
else:
|
|
406
|
-
creation_message = (
|
|
407
|
-
f"Creating engine '{engine_name}' with size {engine_size}... "
|
|
408
|
-
f"(this may take several minutes)"
|
|
409
|
-
)
|
|
410
|
-
|
|
411
|
-
with Spinner(
|
|
412
|
-
creation_message,
|
|
413
|
-
f"Engine '{engine_name}' created!",
|
|
414
|
-
failed_message=None, # We handle error display ourselves below
|
|
415
|
-
):
|
|
416
|
-
try:
|
|
417
|
-
provider.create_engine(
|
|
418
|
-
engine_name,
|
|
419
|
-
type=engine_type,
|
|
420
|
-
size=engine_size,
|
|
421
|
-
auto_suspend_mins=auto_suspend_mins,
|
|
422
|
-
)
|
|
423
|
-
except Exception as e:
|
|
424
|
-
# Prefer richer error messages when available
|
|
425
|
-
error_msg = None
|
|
426
|
-
|
|
427
|
-
# EngineProvisioningFailed has a format_message() method that provides better error details
|
|
428
|
-
if hasattr(e, "format_message"):
|
|
429
|
-
try:
|
|
430
|
-
error_msg = getattr(e, "format_message")()
|
|
431
|
-
except Exception:
|
|
432
|
-
pass
|
|
433
|
-
|
|
434
|
-
# Try content/message fallbacks
|
|
435
|
-
if not error_msg and hasattr(e, "content"):
|
|
436
|
-
error_msg = getattr(e, "content", None)
|
|
437
|
-
if not error_msg and hasattr(e, "message"):
|
|
438
|
-
error_msg = str(getattr(e, "message", ""))
|
|
439
|
-
if not error_msg:
|
|
440
|
-
error_msg = str(e)
|
|
441
|
-
|
|
442
|
-
raise Exception(error_msg)
|
|
443
|
-
|
|
444
|
-
#--------------------------------------------------
|
|
445
|
-
# Tables
|
|
446
|
-
#--------------------------------------------------
|
|
447
|
-
|
|
448
|
-
def get_color_by_state(state: str) -> str:
|
|
449
|
-
if state and isinstance(state, str):
|
|
450
|
-
state_lower = state.lower()
|
|
451
|
-
if state_lower in ("aborted", "quarantined"):
|
|
452
|
-
return "red"
|
|
453
|
-
elif state_lower == "completed":
|
|
454
|
-
return "white"
|
|
455
|
-
elif state_lower in ("running", "cancelling", "syncing", "pending", "processing"):
|
|
456
|
-
return "bold yellow"
|
|
457
|
-
elif state_lower == "suspended":
|
|
458
|
-
return "dim"
|
|
459
|
-
else:
|
|
460
|
-
return ""
|
|
461
|
-
return ""
|
|
462
|
-
|
|
463
|
-
def format_value(value) -> str:
|
|
464
|
-
if value is None:
|
|
465
|
-
return "N/A"
|
|
466
|
-
elif isinstance(value, (int, float)):
|
|
467
|
-
return f"{value}"
|
|
468
|
-
elif isinstance(value, list):
|
|
469
|
-
return ", ".join(map(str, value))
|
|
470
|
-
elif isinstance(value, bool):
|
|
471
|
-
return f"{value}"
|
|
472
|
-
elif isinstance(value, datetime):
|
|
473
|
-
return value.strftime("%Y-%m-%d %H:%M:%S")
|
|
474
|
-
elif isinstance(value, timedelta):
|
|
475
|
-
return humanized_duration(int(value.total_seconds() * 1000))
|
|
476
|
-
else:
|
|
477
|
-
return str(value)
|
|
478
|
-
|
|
479
|
-
def format_row(key: str, value) -> dict:
|
|
480
|
-
result = {}
|
|
481
|
-
result[key] = value
|
|
482
|
-
if "status" in key.lower() or "state" in key.lower():
|
|
483
|
-
result["style"] = get_color_by_state(value)
|
|
484
|
-
if key == "query_size" and isinstance(value, int):
|
|
485
|
-
result[key] = humanized_bytes(value)
|
|
486
|
-
else:
|
|
487
|
-
result[key] = format_value(value)
|
|
488
|
-
return result
|
|
489
|
-
|
|
490
|
-
def show_dictionary_table(dict, format_fn:Callable|None=None):
|
|
491
|
-
table = Table(show_header=True, border_style="dim", header_style="bold", box=rich_box.SIMPLE_HEAD)
|
|
492
|
-
table.add_column("Field")
|
|
493
|
-
table.add_column("Value")
|
|
494
|
-
for key, value in dict.items():
|
|
495
|
-
if format_fn:
|
|
496
|
-
row = format_fn(key, value)
|
|
497
|
-
table.add_row(key, row.get(key), style=row.get("style"))
|
|
498
|
-
else:
|
|
499
|
-
table.add_row(key, value)
|
|
500
|
-
rich.print(table)
|
|
501
|
-
|
|
502
|
-
#--------------------------------------------------
|
|
503
|
-
# Custom help printer
|
|
504
|
-
#--------------------------------------------------
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
class RichGroup(click.Group):
|
|
508
|
-
def invoke(self, ctx: Context) -> Any:
|
|
509
|
-
"""Invoke the CLI command, suppressing tracebacks for handled RAIExceptions.
|
|
510
|
-
|
|
511
|
-
Any `RAIException` is expected to already know how to render itself nicely via
|
|
512
|
-
`pprint()`. When such an exception bubbles up to the top-level Click runner,
|
|
513
|
-
Click will otherwise print a full Python traceback, which is noisy for users.
|
|
514
|
-
"""
|
|
515
|
-
try:
|
|
516
|
-
return super().invoke(ctx)
|
|
517
|
-
except RAIException as exc:
|
|
518
|
-
# Respect config-based full-trace setting when available.
|
|
519
|
-
try:
|
|
520
|
-
show_full_traces = get_config().get("show_full_traces", SHOW_FULL_TRACES)
|
|
521
|
-
except Exception:
|
|
522
|
-
show_full_traces = SHOW_FULL_TRACES
|
|
523
|
-
|
|
524
|
-
if show_full_traces:
|
|
525
|
-
raise
|
|
526
|
-
|
|
527
|
-
exc.pprint()
|
|
528
|
-
raise click.exceptions.Exit(1) from None
|
|
529
|
-
|
|
530
|
-
def format_help(self, ctx: Context, formatter: HelpFormatter) -> None:
|
|
531
|
-
is_latest, current_ver, latest_ver = is_latest_cli_version()
|
|
532
|
-
|
|
533
|
-
global PROFILE
|
|
534
|
-
# @NOTE: I couldn't find a sane way to access the --profile option from here, so insane it is.
|
|
535
|
-
if "--profile" in sys.argv:
|
|
536
|
-
ix = sys.argv.index("--profile") + 1
|
|
537
|
-
if ix < len(sys.argv):
|
|
538
|
-
PROFILE = sys.argv[ix]
|
|
539
|
-
|
|
540
|
-
profile = get_config().profile
|
|
541
|
-
if profile == TOP_LEVEL_PROFILE_NAME:
|
|
542
|
-
profile = "[yellow bold]None[/yellow bold]" if not get_config().get("platform", "") else "[ROOT]"
|
|
543
|
-
|
|
544
|
-
sio = io.StringIO()
|
|
545
|
-
console = Console(file=sio, force_terminal=True)
|
|
546
|
-
divider(console)
|
|
547
|
-
console.print(f"[bold]Welcome to [green]RelationalAI[/bold] ({current_ver})!")
|
|
548
|
-
console.print()
|
|
549
|
-
if not is_latest:
|
|
550
|
-
console.print(f"[yellow]A new version of RelationalAI is available: {latest_ver}[/yellow] ")
|
|
551
|
-
console.print()
|
|
552
|
-
console.print("rai [magenta]\\[options][/magenta] [cyan]command[/cyan]")
|
|
553
|
-
|
|
554
|
-
console.print()
|
|
555
|
-
console.print(f"[magenta]--profile[/magenta][dim] - which config profile to use (current: [/dim][cyan]{profile}[/cyan][dim])")
|
|
556
|
-
|
|
557
|
-
unavailable_commands = []
|
|
558
|
-
groups = defaultdict(list)
|
|
559
|
-
for command in self.commands.keys():
|
|
560
|
-
if ":" in command:
|
|
561
|
-
group, _, _ = command.rpartition(":")
|
|
562
|
-
groups[group].append(command)
|
|
563
|
-
else:
|
|
564
|
-
groups[""].append(command)
|
|
565
|
-
|
|
566
|
-
console.print()
|
|
567
|
-
for command in groups[""]:
|
|
568
|
-
console.print(f"[cyan]{command}[/cyan][dim] - {self.commands[command].help}")
|
|
569
|
-
|
|
570
|
-
for group, commands in groups.items():
|
|
571
|
-
if not group:
|
|
572
|
-
continue
|
|
573
|
-
|
|
574
|
-
empty = True
|
|
575
|
-
for command in commands:
|
|
576
|
-
if command_available(self.commands[command]):
|
|
577
|
-
if empty:
|
|
578
|
-
empty = False
|
|
579
|
-
console.print()
|
|
580
|
-
|
|
581
|
-
console.print(f"[cyan]{command}[/cyan][dim] - {self.commands[command].help}")
|
|
582
|
-
else:
|
|
583
|
-
unavailable_commands.append(command)
|
|
584
|
-
|
|
585
|
-
if unavailable_commands:
|
|
586
|
-
platform = get_config().get("platform", "")
|
|
587
|
-
console.print()
|
|
588
|
-
console.print(f"[yellow]Not available on {platform}[/yellow]")
|
|
589
|
-
console.print()
|
|
590
|
-
for command in unavailable_commands:
|
|
591
|
-
console.print(f"[dim yellow]{command} - {self.commands[command].help}")
|
|
592
|
-
|
|
593
|
-
divider(console)
|
|
594
|
-
formatter.write(sio.getvalue())
|
|
595
|
-
sio.close()
|
|
596
|
-
|
|
597
|
-
def filter_profiles_by_platform(config:ConfigFile, platform:str):
|
|
598
|
-
filtered_config = {}
|
|
599
|
-
for profile, props in config.get_combined_profiles().items():
|
|
600
|
-
if profile == TOP_LEVEL_PROFILE_NAME:
|
|
601
|
-
continue
|
|
602
|
-
if props.get("platform") == platform or (
|
|
603
|
-
props.get("platform") is None
|
|
604
|
-
and platform == "azure"
|
|
605
|
-
):
|
|
606
|
-
filtered_config[profile] = props
|
|
607
|
-
return filtered_config
|
|
608
|
-
|
|
609
|
-
#--------------------------------------------------
|
|
610
|
-
# Imports list
|
|
611
|
-
#--------------------------------------------------
|
|
612
|
-
|
|
613
|
-
def show_imports(imports, showId=False):
|
|
614
|
-
ensure_config()
|
|
615
|
-
if len(imports):
|
|
616
|
-
table = Table(show_header=True, border_style="dim", header_style="bold", box=rich_box.SIMPLE_HEAD)
|
|
617
|
-
cols = {"#": "index"}
|
|
618
|
-
if showId and len(imports) and "id" in imports[0]:
|
|
619
|
-
cols["ID"] = "id"
|
|
620
|
-
if len(imports) and "name" in imports[0]:
|
|
621
|
-
cols["Name"] = "name"
|
|
622
|
-
if len(imports) and "model" in imports[0]:
|
|
623
|
-
cols["Model"] = "model"
|
|
624
|
-
if len(imports) and "created" in imports[0]:
|
|
625
|
-
cols["Created"] = "created"
|
|
626
|
-
if len(imports) and "creator" in imports[0]:
|
|
627
|
-
cols["Creator"] = "creator"
|
|
628
|
-
if len(imports) and "batches" in imports[0]:
|
|
629
|
-
cols["Batches"] = "batches"
|
|
630
|
-
if len(imports) and "status" in imports[0]:
|
|
631
|
-
cols["Status"] = "status"
|
|
632
|
-
if len(imports) and "errors" in imports[0]:
|
|
633
|
-
cols["Errors"] = "errors"
|
|
634
|
-
|
|
635
|
-
for label in cols.keys():
|
|
636
|
-
table.add_column(label)
|
|
637
|
-
|
|
638
|
-
for index, imp in enumerate(imports):
|
|
639
|
-
imp["index"] = f"{index+1}"
|
|
640
|
-
style = get_color_by_state(imp["status"])
|
|
641
|
-
if imp["created"]:
|
|
642
|
-
imp["created"] = format_value(imp["created"])
|
|
643
|
-
table.add_row(*[imp.get(attr, None) for attr in cols.values()], style=style)
|
|
644
|
-
rich.print(table)
|
|
645
|
-
else:
|
|
646
|
-
rich.print("[yellow]No imports found")
|
|
647
|
-
|
|
648
|
-
#--------------------------------------------------
|
|
649
|
-
# Transactions
|
|
650
|
-
#--------------------------------------------------
|
|
651
|
-
|
|
652
|
-
def show_transactions(transactions, limit):
|
|
653
|
-
if len(transactions):
|
|
654
|
-
table = Table(show_header=True, border_style="dim", header_style="bold", box=rich_box.SIMPLE_HEAD)
|
|
655
|
-
table.add_column("#")
|
|
656
|
-
table.add_column("ID")
|
|
657
|
-
table.add_column("Schema")
|
|
658
|
-
table.add_column("Engine")
|
|
659
|
-
table.add_column("State")
|
|
660
|
-
table.add_column("Created")
|
|
661
|
-
table.add_column("Duration", justify="right")
|
|
662
|
-
|
|
663
|
-
added = 0
|
|
664
|
-
for i, txn in enumerate(transactions):
|
|
665
|
-
if added >= limit:
|
|
666
|
-
break
|
|
667
|
-
|
|
668
|
-
state = txn.get("state", "")
|
|
669
|
-
duration = txn.get("duration")
|
|
670
|
-
created_on = txn.get("created_on")
|
|
671
|
-
|
|
672
|
-
if isinstance(created_on, int):
|
|
673
|
-
created_on = datetime.fromtimestamp(created_on / 1000, tz=pytz.utc)
|
|
674
|
-
if duration is None:
|
|
675
|
-
duration = (datetime.now(created_on.tzinfo) - created_on).total_seconds() * 1000
|
|
676
|
-
|
|
677
|
-
table.add_row(
|
|
678
|
-
f"{i+1}",
|
|
679
|
-
txn.get("id"),
|
|
680
|
-
txn.get("database", ""),
|
|
681
|
-
txn.get("engine", ""),
|
|
682
|
-
state,
|
|
683
|
-
created_on.strftime("%Y-%m-%d %H:%M:%S"),
|
|
684
|
-
humanized_duration(int(duration)),
|
|
685
|
-
style=get_color_by_state(state)
|
|
686
|
-
)
|
|
687
|
-
added += 1
|
|
688
|
-
rich.print(table)
|
|
689
|
-
else:
|
|
690
|
-
rich.print("[yellow]No transactions found")
|
|
691
|
-
|
|
692
|
-
def show_engines(engines):
|
|
693
|
-
if len(engines):
|
|
694
|
-
table = Table(show_header=True, border_style="dim", header_style="bold", box=rich_box.SIMPLE_HEAD)
|
|
695
|
-
table.add_column("#")
|
|
696
|
-
table.add_column("Name")
|
|
697
|
-
# Show type column if present
|
|
698
|
-
table.add_column("Type")
|
|
699
|
-
table.add_column("Size")
|
|
700
|
-
table.add_column("State")
|
|
701
|
-
table.add_column("Created By")
|
|
702
|
-
table.add_column("Created On")
|
|
703
|
-
EngineType = _get_engine_type_api()
|
|
704
|
-
for index, engine in enumerate(engines):
|
|
705
|
-
engine_type = engine.get("type", "")
|
|
706
|
-
type_display = EngineType.get_label_with_value(engine_type) if engine_type and EngineType.is_valid(engine_type) else (engine_type or "")
|
|
707
|
-
created_on = format_value(engine.get("created_on"))
|
|
708
|
-
state_display = format_state_with_color(engine.get("state", ""))
|
|
709
|
-
table.add_row(
|
|
710
|
-
f"{index+1}",
|
|
711
|
-
engine.get("name"),
|
|
712
|
-
type_display,
|
|
713
|
-
engine.get("size"),
|
|
714
|
-
state_display,
|
|
715
|
-
engine.get("created_by", ""),
|
|
716
|
-
created_on,
|
|
717
|
-
)
|
|
718
|
-
rich.print(table)
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
def show_engine_details(engine: dict[str, Any]) -> None:
|
|
722
|
-
"""Print a vertical table of engine details (one field per row)."""
|
|
723
|
-
from relationalai.clients.resources.snowflake import EngineType as _EngineType
|
|
724
|
-
|
|
725
|
-
table = Table(
|
|
726
|
-
show_header=True,
|
|
727
|
-
border_style="dim",
|
|
728
|
-
header_style="bold",
|
|
729
|
-
box=rich_box.SIMPLE_HEAD,
|
|
730
|
-
)
|
|
731
|
-
table.add_column("Field")
|
|
732
|
-
table.add_column("Value", overflow="fold")
|
|
733
|
-
|
|
734
|
-
engine_type_from_db = engine.get("type", "")
|
|
735
|
-
type_display = (
|
|
736
|
-
_EngineType.get_label_with_value(engine_type_from_db)
|
|
737
|
-
if engine_type_from_db and _EngineType.is_valid(engine_type_from_db)
|
|
738
|
-
else engine_type_from_db
|
|
739
|
-
)
|
|
740
|
-
|
|
741
|
-
rows: list[tuple[str, str]] = [
|
|
742
|
-
("Name", str(engine.get("name", ""))),
|
|
743
|
-
("Type", str(type_display)),
|
|
744
|
-
("Size", str(engine.get("size", ""))),
|
|
745
|
-
("State", str(format_state_with_color(engine.get("state", "")))),
|
|
746
|
-
("Created By", str(engine.get("created_by", ""))),
|
|
747
|
-
("Created On", str(format_value(engine.get("created_on")))),
|
|
748
|
-
]
|
|
749
|
-
|
|
750
|
-
# Optional fields (may not exist on older backends).
|
|
751
|
-
for key, label, formatter in [
|
|
752
|
-
("version", "Version", lambda v: "" if v is None else str(v)),
|
|
753
|
-
("updated_on", "Updated On", format_value),
|
|
754
|
-
("suspends_at", "Suspends At", format_value),
|
|
755
|
-
]:
|
|
756
|
-
if key in engine:
|
|
757
|
-
try:
|
|
758
|
-
val = engine.get(key)
|
|
759
|
-
rows.append((label, str(formatter(val))))
|
|
760
|
-
except Exception:
|
|
761
|
-
rows.append((label, str(engine.get(key))))
|
|
762
|
-
|
|
763
|
-
# Auto-suspend minutes is represented differently across backends:
|
|
764
|
-
# - list_engines tends to return auto_suspend_mins
|
|
765
|
-
# - get_engine (Snowflake EngineServiceSQL) returns auto_suspend
|
|
766
|
-
if "auto_suspend_mins" in engine or "auto_suspend" in engine:
|
|
767
|
-
auto_suspend_val = engine.get("auto_suspend_mins", engine.get("auto_suspend"))
|
|
768
|
-
rows.append(("Auto Suspend (mins)", "" if auto_suspend_val is None else str(auto_suspend_val)))
|
|
769
|
-
|
|
770
|
-
settings = engine.get("settings")
|
|
771
|
-
if settings in (None, {}, ""):
|
|
772
|
-
settings_str = ""
|
|
773
|
-
elif isinstance(settings, dict):
|
|
774
|
-
settings_str = json.dumps(settings, indent=2, sort_keys=True)
|
|
775
|
-
else:
|
|
776
|
-
settings_str = str(settings)
|
|
777
|
-
rows.append(("Settings", settings_str))
|
|
778
|
-
|
|
779
|
-
for field, value in rows:
|
|
780
|
-
table.add_row(field, value)
|
|
781
|
-
|
|
782
|
-
rich.print(table)
|
|
783
|
-
|
|
784
|
-
def exit_with_error(message: str) -> NoReturn:
|
|
785
|
-
rich.print(message, file=sys.stderr)
|
|
786
|
-
exit_with_divider(1)
|
|
787
|
-
|
|
788
|
-
def exit_with_handled_exception(context: str, exc: Exception) -> NoReturn:
|
|
789
|
-
"""Exit with a nicely formatted message for handled RAIExceptions.
|
|
790
|
-
|
|
791
|
-
- If `exc` is a RAIException (i.e. produced by an error handler), print its rich
|
|
792
|
-
formatted content via `exc.pprint()`.
|
|
793
|
-
- Otherwise, print a raw one-line error including the context and exception string.
|
|
794
|
-
"""
|
|
795
|
-
if isinstance(exc, RAIException):
|
|
796
|
-
exc.pprint()
|
|
797
|
-
sys.exit(1)
|
|
798
|
-
exit_with_error(f"\n\n[yellow]{context}: {exc}")
|
|
799
|
-
|
|
800
|
-
def exit_with_divider(exit_code: int = 0) -> NoReturn:
|
|
801
|
-
divider()
|
|
802
|
-
sys.exit(exit_code)
|