shaped 2.0.2__py3-none-any.whl → 2.0.4__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.
- shaped/__init__.py +47 -42
- shaped/autogen/__init__.py +37 -51
- shaped/autogen/api/engine_api.py +1 -1
- shaped/autogen/api/query_api.py +8 -68
- shaped/autogen/api/table_api.py +1 -1
- shaped/autogen/api/view_api.py +1 -1
- shaped/autogen/api_client.py +4 -4
- shaped/autogen/configuration.py +5 -3
- shaped/autogen/exceptions.py +7 -4
- shaped/autogen/models/__init__.py +19 -26
- shaped/autogen/models/ai_enrichment_view_config.py +1 -1
- shaped/autogen/models/algorithm.py +1 -1
- shaped/autogen/models/amplitude_table_config.py +1 -1
- shaped/autogen/models/ascending.py +29 -17
- shaped/autogen/models/attn_dropout_prob.py +1 -1
- shaped/autogen/models/attribute_journey.py +1 -1
- shaped/autogen/models/attribute_value.py +1 -1
- shaped/autogen/models/autoscaling_config.py +1 -1
- shaped/autogen/models/aws_pinpoint_table_config.py +1 -1
- shaped/autogen/models/batch_size.py +1 -1
- shaped/autogen/models/batch_size1.py +1 -1
- shaped/autogen/models/batch_size2.py +1 -1
- shaped/autogen/models/big_query_table_config.py +1 -1
- shaped/autogen/models/bm25.py +1 -1
- shaped/autogen/models/boosted_reorder_step.py +1 -1
- shaped/autogen/models/canary_rollout.py +1 -1
- shaped/autogen/models/candidate_attributes_retrieve_step.py +1 -14
- shaped/autogen/models/candidate_ids_retrieve_step.py +1 -1
- shaped/autogen/models/candidate_retrieval_strategy.py +1 -1
- shaped/autogen/models/clickhouse_table_config.py +1 -1
- shaped/autogen/models/column_order_retrieve_step.py +1 -1
- shaped/autogen/models/column_ordering.py +1 -1
- shaped/autogen/models/create_table_response.py +1 -1
- shaped/autogen/models/create_view_response.py +1 -1
- shaped/autogen/models/custom_table_config.py +1 -1
- shaped/autogen/models/data_compute_config.py +1 -1
- shaped/autogen/models/data_config.py +1 -1
- shaped/autogen/models/data_config_interaction_table.py +1 -1
- shaped/autogen/models/data_split_config.py +1 -1
- shaped/autogen/models/data_split_strategy.py +1 -1
- shaped/autogen/models/data_tier.py +1 -1
- shaped/autogen/models/default.py +1 -1
- shaped/autogen/models/delete_engine_response.py +1 -1
- shaped/autogen/models/delete_table_response.py +1 -1
- shaped/autogen/models/delete_view_response.py +1 -1
- shaped/autogen/models/deployment_config.py +2 -8
- shaped/autogen/models/distance_function.py +5 -5
- shaped/autogen/models/diversity_reorder_step.py +1 -1
- shaped/autogen/models/dropout_rate.py +1 -1
- shaped/autogen/models/dynamo_db_table_config.py +1 -1
- shaped/autogen/models/dynamo_db_table_config_scan_kwargs_value.py +1 -1
- shaped/autogen/models/embedder_batch_size.py +1 -1
- shaped/autogen/models/embedding_config.py +1 -1
- shaped/autogen/models/embedding_dim.py +1 -1
- shaped/autogen/models/embedding_dims.py +1 -1
- shaped/autogen/models/embedding_size.py +1 -1
- shaped/autogen/models/encoder.py +1 -1
- shaped/autogen/models/encoding_pooling_strategy.py +5 -5
- shaped/autogen/models/engine.py +1 -1
- shaped/autogen/models/engine_config_v2.py +1 -1
- shaped/autogen/models/engine_details_response.py +1 -1
- shaped/autogen/models/engine_schema.py +8 -8
- shaped/autogen/models/engine_schema_user_inner.py +30 -18
- shaped/autogen/models/entity_config.py +1 -1
- shaped/autogen/models/entity_journey.py +28 -19
- shaped/autogen/models/entity_type.py +1 -1
- shaped/autogen/models/evaluation_config.py +1 -1
- shaped/autogen/models/exploration_reorder_step.py +1 -1
- shaped/autogen/models/expression_filter_step.py +1 -1
- shaped/autogen/models/factors.py +1 -1
- shaped/autogen/models/factors1.py +1 -1
- shaped/autogen/models/feature.py +1 -1
- shaped/autogen/models/feature_type.py +1 -1
- shaped/autogen/models/file_table_config.py +1 -1
- shaped/autogen/models/filter_config.py +14 -14
- shaped/autogen/models/filter_dataset.py +47 -23
- shaped/autogen/models/filter_index_type.py +1 -1
- shaped/autogen/models/filter_retrieve_step.py +1 -1
- shaped/autogen/models/filter_step_explanation.py +165 -0
- shaped/autogen/models/filter_table.py +140 -0
- shaped/autogen/models/filter_type.py +134 -0
- shaped/autogen/models/global_filter.py +1 -1
- shaped/autogen/models/hidden_dropout_prob.py +1 -1
- shaped/autogen/models/hidden_size.py +1 -1
- shaped/autogen/models/hidden_size1.py +1 -1
- shaped/autogen/models/http_problem_response.py +1 -1
- shaped/autogen/models/http_validation_error.py +1 -1
- shaped/autogen/models/hugging_face_encoder.py +6 -4
- shaped/autogen/models/iceberg_table_config.py +1 -1
- shaped/autogen/models/index_config.py +1 -1
- shaped/autogen/models/inner_entity_id.py +144 -0
- shaped/autogen/models/inner_size.py +1 -1
- shaped/autogen/models/inner_size1.py +1 -1
- shaped/autogen/models/inner_uid.py +144 -0
- shaped/autogen/models/interaction_config.py +1 -1
- shaped/autogen/models/interaction_pooling_encoder.py +1 -1
- shaped/autogen/models/interaction_round_robin_encoder.py +1 -1
- shaped/autogen/models/item_attribute_pooling_encoder.py +1 -14
- shaped/autogen/models/journey.py +1 -1
- shaped/autogen/models/kafka_table_config.py +1 -1
- shaped/autogen/models/kinesis_table_config.py +1 -1
- shaped/autogen/models/kinesis_table_config_column_schema_value.py +1 -1
- shaped/autogen/models/label.py +1 -1
- shaped/autogen/models/label_type.py +1 -2
- shaped/autogen/models/laplace_smoothing.py +1 -1
- shaped/autogen/models/latency_scaling_policy.py +1 -1
- shaped/autogen/models/learning_rate.py +1 -1
- shaped/autogen/models/learning_rate1.py +1 -1
- shaped/autogen/models/learning_rate2.py +1 -1
- shaped/autogen/models/learning_rate3.py +1 -1
- shaped/autogen/models/lexical_search_mode.py +3 -3
- shaped/autogen/models/list_engines_response.py +1 -1
- shaped/autogen/models/list_tables_response.py +1 -1
- shaped/autogen/models/list_views_response.py +1 -1
- shaped/autogen/models/location_inner.py +138 -0
- shaped/autogen/models/loss_types.py +1 -1
- shaped/autogen/models/lr.py +1 -1
- shaped/autogen/models/lr1.py +1 -1
- shaped/autogen/models/lr2.py +1 -1
- shaped/autogen/models/max_depth.py +1 -1
- shaped/autogen/models/max_leaves.py +1 -1
- shaped/autogen/models/max_seq_length.py +1 -1
- shaped/autogen/models/max_seq_length1.py +1 -1
- shaped/autogen/models/max_seq_length2.py +1 -1
- shaped/autogen/models/mode.py +1 -1
- shaped/autogen/models/mode1.py +20 -18
- shaped/autogen/models/mode2.py +32 -18
- shaped/autogen/models/models_inner.py +308 -0
- shaped/autogen/models/mongo_db_table_config.py +1 -1
- shaped/autogen/models/mssql_table_config.py +1 -1
- shaped/autogen/models/my_sql_table_config.py +1 -1
- shaped/autogen/models/n_epochs.py +1 -1
- shaped/autogen/models/n_epochs1.py +1 -1
- shaped/autogen/models/n_epochs2.py +1 -1
- shaped/autogen/models/n_estimators.py +1 -1
- shaped/autogen/models/n_heads.py +1 -1
- shaped/autogen/models/n_layers.py +1 -1
- shaped/autogen/models/neg_per_positive.py +1 -1
- shaped/autogen/models/negative_samples_count.py +1 -1
- shaped/autogen/models/ngram_tokenizer.py +1 -1
- shaped/autogen/models/no_op_config.py +1 -1
- shaped/autogen/models/num_blocks.py +1 -1
- shaped/autogen/models/num_heads.py +1 -1
- shaped/autogen/models/num_leaves.py +1 -1
- shaped/autogen/models/objective.py +1 -1
- shaped/autogen/models/objective1.py +1 -1
- shaped/autogen/models/online_store_config.py +1 -1
- shaped/autogen/models/pagination_config.py +1 -1
- shaped/autogen/models/parameter_definition.py +1 -1
- shaped/autogen/models/parameters_value.py +1 -1
- shaped/autogen/models/passthrough_score.py +1 -1
- shaped/autogen/models/personal_filter.py +1 -1
- shaped/autogen/models/pipeline_stage_explanation.py +4 -4
- shaped/autogen/models/policy.py +1 -1
- shaped/autogen/models/pool_fn.py +39 -21
- shaped/autogen/models/pooling_function.py +1 -1
- shaped/autogen/models/postgres_table_config.py +1 -1
- shaped/autogen/models/posthog_table_config.py +1 -1
- shaped/autogen/models/prebuilt_filter_step.py +1 -1
- shaped/autogen/models/precomputed_item_embedding.py +1 -1
- shaped/autogen/models/precomputed_user_embedding.py +1 -1
- shaped/autogen/models/query.py +15 -15
- shaped/autogen/models/query1.py +15 -15
- shaped/autogen/models/query_any_of.py +58 -26
- shaped/autogen/models/query_config.py +140 -0
- shaped/autogen/models/query_definition.py +1 -1
- shaped/autogen/models/query_encoder.py +1 -1
- shaped/autogen/models/query_explanation.py +7 -3
- shaped/autogen/models/query_request.py +1 -1
- shaped/autogen/models/query_result.py +1 -1
- shaped/autogen/models/query_table_config.py +1 -1
- shaped/autogen/models/rank_item_attribute_values_query_config.py +1 -1
- shaped/autogen/models/rank_query_config.py +7 -7
- shaped/autogen/models/rank_query_config_filter_inner.py +1 -1
- shaped/autogen/models/rank_query_config_reorder_inner.py +62 -25
- shaped/autogen/models/rank_query_config_retrieve_inner.py +100 -31
- shaped/autogen/models/recreate_rollout.py +1 -1
- shaped/autogen/models/redshift_table_config.py +1 -1
- shaped/autogen/models/reference_table_config.py +1 -1
- shaped/autogen/models/regularization.py +1 -1
- shaped/autogen/models/reorder_inner.py +149 -0
- shaped/autogen/models/reorder_step_explanation.py +207 -0
- shaped/autogen/models/request.py +1 -1
- shaped/autogen/models/request1.py +1 -1
- shaped/autogen/models/requests_per_second_scaling_policy.py +1 -1
- shaped/autogen/models/resource_config.py +100 -0
- shaped/autogen/models/response_get_view_details_views_view_name_get.py +1 -1
- shaped/autogen/models/result.py +1 -14
- shaped/autogen/models/result_embeddings_value.py +1 -1
- shaped/autogen/models/retrieval_scores_value.py +127 -0
- shaped/autogen/models/retrieve_inner.py +196 -0
- shaped/autogen/models/retrieve_step_explanation.py +172 -0
- shaped/autogen/models/retriever.py +1 -1
- shaped/autogen/models/retriever1.py +1 -1
- shaped/autogen/models/rollout_config.py +1 -1
- shaped/autogen/models/rudderstack_table_config.py +1 -1
- shaped/autogen/models/sampling_strategy.py +1 -1
- shaped/autogen/models/saved_query_info_response.py +18 -4
- shaped/autogen/models/saved_query_list_response.py +1 -1
- shaped/autogen/models/saved_query_request.py +1 -1
- shaped/autogen/models/schema_config.py +1 -1
- shaped/autogen/models/score.py +1 -1
- shaped/autogen/models/score_ensemble.py +1 -14
- shaped/autogen/models/score_ensemble_policy_config.py +49 -25
- shaped/autogen/models/score_ensemble_policy_config_policies_inner.py +456 -123
- shaped/autogen/models/score_step_explanation.py +224 -0
- shaped/autogen/models/search_config.py +1 -1
- shaped/autogen/models/segment_table_config.py +1 -1
- shaped/autogen/models/sequence_length.py +1 -1
- shaped/autogen/models/server_config.py +14 -1
- shaped/autogen/models/setup_engine_response.py +1 -1
- shaped/autogen/models/shaped_internal_recsys_policies_als_model_policy_als_model_policy_config.py +9 -3
- shaped/autogen/models/shaped_internal_recsys_policies_beeformer_model_policy_beeformer_model_policy_beeformer_model_policy_config.py +9 -3
- shaped/autogen/models/shaped_internal_recsys_policies_bert_model_policy_bert_model_policy_bert_model_policy_config.py +10 -4
- shaped/autogen/models/shaped_internal_recsys_policies_chronological_model_policy_chronological_model_policy_config.py +46 -27
- shaped/autogen/models/shaped_internal_recsys_policies_elsa_model_policy_elsa_model_policy_elsa_model_policy_config.py +6 -4
- shaped/autogen/models/shaped_internal_recsys_policies_gsasrec_model_policy_gsasrec_model_policy_gsas_rec_model_policy_config.py +9 -3
- shaped/autogen/models/shaped_internal_recsys_policies_item2vec_model_policy_item2_vec_model_policy_config.py +1 -1
- shaped/autogen/models/shaped_internal_recsys_policies_item_content_similarity_model_policy_item_content_similarity_model_policy_config.py +77 -34
- shaped/autogen/models/shaped_internal_recsys_policies_lightgbm_model_policy_lightgbm_model_policy_light_gbm_model_policy_config.py +9 -3
- shaped/autogen/models/shaped_internal_recsys_policies_ngram_model_policy_ngram_model_policy_config.py +1 -1
- shaped/autogen/models/shaped_internal_recsys_policies_popular_model_policy_popular_model_policy_config.py +52 -28
- shaped/autogen/models/shaped_internal_recsys_policies_random_model_policy_random_model_policy_config.py +21 -17
- shaped/autogen/models/shaped_internal_recsys_policies_recently_popular_policy_recently_popular_policy_config.py +36 -23
- shaped/autogen/models/shaped_internal_recsys_policies_rising_popular_policy_rising_popular_policy_config.py +1 -1
- shaped/autogen/models/shaped_internal_recsys_policies_sasrec_model_policy_sasrec_model_policy_sas_rec_model_policy_config.py +9 -3
- shaped/autogen/models/shaped_internal_recsys_policies_svd_model_policy_svd_model_policy_config.py +1 -1
- shaped/autogen/models/shaped_internal_recsys_policies_two_tower_model_policy_two_tower_model_policy_two_tower_model_policy_config.py +9 -3
- shaped/autogen/models/shaped_internal_recsys_policies_user_item_content_similarity_model_policy_user_item_content_similarity_model_policy_config.py +53 -31
- shaped/autogen/models/shaped_internal_recsys_policies_widedeep_model_policy_wide_deep_model_policy_config.py +10 -4
- shaped/autogen/models/shaped_internal_recsys_policies_xgboost_model_policy_xg_boost_model_policy_config.py +12 -6
- shaped/autogen/models/shopify_table_config.py +1 -1
- shaped/autogen/models/similarity_retrieve_step.py +6 -4
- shaped/autogen/models/snowflake_table_config.py +1 -1
- shaped/autogen/models/sql_transform_type.py +1 -1
- shaped/autogen/models/sql_view_config.py +1 -1
- shaped/autogen/models/stemmer_tokenizer.py +1 -1
- shaped/autogen/models/step_explanation.py +1 -1
- shaped/autogen/models/steps_inner.py +179 -0
- shaped/autogen/models/strategy.py +1 -1
- shaped/autogen/models/table.py +1 -1
- shaped/autogen/models/table_deployment_type.py +1 -1
- shaped/autogen/models/table_insert_arguments.py +3 -3
- shaped/autogen/models/table_insert_response.py +1 -1
- shaped/autogen/models/text_encoding.py +29 -17
- shaped/autogen/models/text_search_retrieve_step.py +1 -1
- shaped/autogen/models/time_frequency.py +1 -1
- shaped/autogen/models/time_window.py +1 -1
- shaped/autogen/models/time_window_in_days.py +29 -17
- shaped/autogen/models/tokenizer.py +1 -1
- shaped/autogen/models/trained_model_encoder.py +1 -1
- shaped/autogen/models/training_compute_config.py +4 -4
- shaped/autogen/models/training_config.py +4 -4
- shaped/autogen/models/training_config_models_inner.py +325 -93
- shaped/autogen/models/training_strategy.py +1 -1
- shaped/autogen/models/transform_status.py +41 -0
- shaped/autogen/models/trending_mode.py +4 -4
- shaped/autogen/models/truncate_filter_step.py +1 -1
- shaped/autogen/models/tunable_bool.py +1 -1
- shaped/autogen/models/tunable_float.py +1 -1
- shaped/autogen/models/tunable_int.py +1 -1
- shaped/autogen/models/tunable_int_categorical.py +1 -1
- shaped/autogen/models/tunable_string.py +1 -1
- shaped/autogen/models/tuning_config.py +1 -1
- shaped/autogen/models/type.py +36 -20
- shaped/autogen/models/update_table_response.py +1 -1
- shaped/autogen/models/update_view_response.py +1 -1
- shaped/autogen/models/user_attribute_pooling_encoder.py +1 -1
- shaped/autogen/models/user_inner.py +134 -0
- shaped/autogen/models/val_split.py +1 -1
- shaped/autogen/models/validation_error.py +4 -4
- shaped/autogen/models/validation_error_loc_inner.py +28 -16
- shaped/autogen/models/value_type.py +1 -1
- shaped/autogen/models/vector_search_mode.py +6 -4
- shaped/autogen/models/view.py +4 -4
- shaped/autogen/models/view_details_ai.py +6 -6
- shaped/autogen/models/view_details_ai_schema_value.py +1 -1
- shaped/autogen/models/view_details_sql.py +6 -6
- shaped/autogen/models/view_status.py +8 -8
- shaped/autogen/models/weight_decay.py +1 -1
- shaped/autogen/models/whitespace_tokenizer.py +1 -1
- shaped/autogen/models/window_size.py +1 -1
- shaped/autogen/rest.py +9 -9
- shaped/cli/shaped_cli.py +152 -29
- shaped/client.py +50 -43
- shaped/config_builders.py +110 -100
- shaped/query_builder.py +56 -49
- {shaped-2.0.2.dist-info → shaped-2.0.4.dist-info}/METADATA +2 -2
- shaped-2.0.4.dist-info/RECORD +296 -0
- {shaped-2.0.2.dist-info → shaped-2.0.4.dist-info}/WHEEL +1 -1
- shaped-2.0.2.dist-info/RECORD +0 -278
- {shaped-2.0.2.dist-info → shaped-2.0.4.dist-info}/entry_points.txt +0 -0
- {shaped-2.0.2.dist-info → shaped-2.0.4.dist-info}/top_level.txt +0 -0
- {shaped-2.0.2.dist-info → shaped-2.0.4.dist-info}/zip-safe +0 -0
shaped/config_builders.py
CHANGED
|
@@ -4,47 +4,50 @@ Fluent builders for constructing Shaped V2 configurations.
|
|
|
4
4
|
This module provides a fluent API for building Engine, Table, and View configurations
|
|
5
5
|
using Python objects instead of raw dictionaries or complex model instantiation.
|
|
6
6
|
"""
|
|
7
|
-
from typing import Any, Dict, List, Optional, Union
|
|
8
7
|
|
|
9
|
-
from
|
|
10
|
-
from shaped.autogen.models.data_config import DataConfig
|
|
11
|
-
from shaped.autogen.models.data_config_interaction_table import DataConfigInteractionTable
|
|
12
|
-
from shaped.autogen.models.reference_table_config import ReferenceTableConfig
|
|
13
|
-
from shaped.autogen.models.query_table_config import QueryTableConfig
|
|
8
|
+
from typing import Any, Dict, List, Optional, Union
|
|
14
9
|
|
|
15
|
-
|
|
16
|
-
from shaped.autogen.models.postgres_table_config import PostgresTableConfig
|
|
17
|
-
from shaped.autogen.models.big_query_table_config import BigQueryTableConfig
|
|
18
|
-
from shaped.autogen.models.snowflake_table_config import SnowflakeTableConfig
|
|
19
|
-
from shaped.autogen.models.file_table_config import FileTableConfig
|
|
10
|
+
from shaped.autogen.models.ai_enrichment_view_config import AIEnrichmentViewConfig
|
|
20
11
|
from shaped.autogen.models.amplitude_table_config import AmplitudeTableConfig
|
|
21
12
|
from shaped.autogen.models.aws_pinpoint_table_config import AWSPinpointTableConfig
|
|
13
|
+
from shaped.autogen.models.big_query_table_config import BigQueryTableConfig
|
|
22
14
|
from shaped.autogen.models.clickhouse_table_config import ClickhouseTableConfig
|
|
23
15
|
from shaped.autogen.models.custom_table_config import CustomTableConfig
|
|
16
|
+
from shaped.autogen.models.data_config import DataConfig
|
|
17
|
+
from shaped.autogen.models.data_config_interaction_table import (
|
|
18
|
+
DataConfigInteractionTable,
|
|
19
|
+
)
|
|
20
|
+
from shaped.autogen.models.deployment_config import DeploymentConfig
|
|
24
21
|
from shaped.autogen.models.dynamo_db_table_config import DynamoDBTableConfig
|
|
22
|
+
from shaped.autogen.models.engine_config_v2 import EngineConfigV2
|
|
23
|
+
from shaped.autogen.models.file_table_config import FileTableConfig
|
|
25
24
|
from shaped.autogen.models.iceberg_table_config import IcebergTableConfig
|
|
25
|
+
|
|
26
|
+
# Other Imports
|
|
27
|
+
from shaped.autogen.models.index_config import IndexConfig
|
|
26
28
|
from shaped.autogen.models.kafka_table_config import KafkaTableConfig
|
|
27
29
|
from shaped.autogen.models.kinesis_table_config import KinesisTableConfig
|
|
28
30
|
from shaped.autogen.models.mongo_db_table_config import MongoDBTableConfig
|
|
29
31
|
from shaped.autogen.models.mssql_table_config import MSSQLTableConfig
|
|
30
32
|
from shaped.autogen.models.my_sql_table_config import MySQLTableConfig
|
|
33
|
+
|
|
34
|
+
# Table Config Imports
|
|
35
|
+
from shaped.autogen.models.postgres_table_config import PostgresTableConfig
|
|
31
36
|
from shaped.autogen.models.posthog_table_config import PosthogTableConfig
|
|
37
|
+
from shaped.autogen.models.query_definition import QueryDefinition
|
|
38
|
+
from shaped.autogen.models.query_table_config import QueryTableConfig
|
|
39
|
+
from shaped.autogen.models.rank_query_config import RankQueryConfig
|
|
32
40
|
from shaped.autogen.models.redshift_table_config import RedshiftTableConfig
|
|
41
|
+
from shaped.autogen.models.reference_table_config import ReferenceTableConfig
|
|
33
42
|
from shaped.autogen.models.rudderstack_table_config import RudderstackTableConfig
|
|
34
43
|
from shaped.autogen.models.segment_table_config import SegmentTableConfig
|
|
35
44
|
from shaped.autogen.models.shopify_table_config import ShopifyTableConfig
|
|
45
|
+
from shaped.autogen.models.snowflake_table_config import SnowflakeTableConfig
|
|
46
|
+
from shaped.autogen.models.sql_transform_type import SQLTransformType
|
|
36
47
|
|
|
37
48
|
# View Config Imports
|
|
38
49
|
from shaped.autogen.models.sql_view_config import SQLViewConfig
|
|
39
|
-
from shaped.autogen.models.ai_enrichment_view_config import AIEnrichmentViewConfig
|
|
40
|
-
from shaped.autogen.models.sql_transform_type import SQLTransformType
|
|
41
|
-
|
|
42
|
-
# Other Imports
|
|
43
|
-
from shaped.autogen.models.index_config import IndexConfig
|
|
44
50
|
from shaped.autogen.models.training_config import TrainingConfig
|
|
45
|
-
from shaped.autogen.models.deployment_config import DeploymentConfig
|
|
46
|
-
from shaped.autogen.models.query_definition import QueryDefinition
|
|
47
|
-
from shaped.autogen.models.rank_query_config import RankQueryConfig
|
|
48
51
|
|
|
49
52
|
# Type aliases for better type hints
|
|
50
53
|
TableConfig = Union[
|
|
@@ -67,7 +70,7 @@ TableConfig = Union[
|
|
|
67
70
|
RedshiftTableConfig,
|
|
68
71
|
RudderstackTableConfig,
|
|
69
72
|
SegmentTableConfig,
|
|
70
|
-
ShopifyTableConfig
|
|
73
|
+
ShopifyTableConfig,
|
|
71
74
|
]
|
|
72
75
|
ViewConfig = Union[SQLViewConfig, AIEnrichmentViewConfig]
|
|
73
76
|
|
|
@@ -75,7 +78,7 @@ ViewConfig = Union[SQLViewConfig, AIEnrichmentViewConfig]
|
|
|
75
78
|
class Engine:
|
|
76
79
|
"""
|
|
77
80
|
Builder for Engine configurations with support for all V2 features.
|
|
78
|
-
|
|
81
|
+
|
|
79
82
|
Example:
|
|
80
83
|
engine = (Engine("my-engine")
|
|
81
84
|
.interactions("events")
|
|
@@ -86,11 +89,11 @@ class Engine:
|
|
|
86
89
|
.with_deployment_config(...)
|
|
87
90
|
.with_query("recommendations", "SELECT * FROM items ORDER BY score DESC"))
|
|
88
91
|
"""
|
|
89
|
-
|
|
92
|
+
|
|
90
93
|
def __init__(self, name: str):
|
|
91
94
|
if not name:
|
|
92
95
|
raise ValueError("Engine name is required")
|
|
93
|
-
|
|
96
|
+
|
|
94
97
|
self._name = name
|
|
95
98
|
self._description: Optional[str] = None
|
|
96
99
|
self._interactions: Optional[Union[str, Dict[str, Any]]] = None
|
|
@@ -106,187 +109,185 @@ class Engine:
|
|
|
106
109
|
self._training_config: Dict[str, Any] = {}
|
|
107
110
|
self._deployment_config: Dict[str, Any] = {}
|
|
108
111
|
self._queries: Dict[str, QueryDefinition] = {}
|
|
109
|
-
|
|
112
|
+
|
|
110
113
|
def description(self, description: str) -> "Engine":
|
|
111
114
|
"""Set the engine description."""
|
|
112
115
|
self._description = description
|
|
113
116
|
return self
|
|
114
|
-
|
|
117
|
+
|
|
115
118
|
def interactions(self, table: Union[str, Dict[str, Any]]) -> "Engine":
|
|
116
119
|
"""Set the interactions table configuration."""
|
|
117
120
|
self._interactions = table
|
|
118
121
|
return self
|
|
119
|
-
|
|
122
|
+
|
|
120
123
|
def users(self, table: Union[str, Dict[str, Any]]) -> "Engine":
|
|
121
124
|
"""Set the users table configuration."""
|
|
122
125
|
self._users = table
|
|
123
126
|
return self
|
|
124
|
-
|
|
127
|
+
|
|
125
128
|
def items(self, table: Union[str, Dict[str, Any]]) -> "Engine":
|
|
126
129
|
"""Set the items table configuration."""
|
|
127
130
|
self._items = table
|
|
128
131
|
return self
|
|
129
|
-
|
|
132
|
+
|
|
130
133
|
def schedule(self, schedule: str) -> "Engine":
|
|
131
134
|
"""Set the data refresh schedule."""
|
|
132
135
|
self._schedule = schedule
|
|
133
136
|
return self
|
|
134
|
-
|
|
137
|
+
|
|
135
138
|
def with_schema_override(self, schema: Dict[str, Any]) -> "Engine":
|
|
136
139
|
"""Override the default schema detection with custom schema."""
|
|
137
140
|
self._schema_override = schema
|
|
138
141
|
return self
|
|
139
|
-
|
|
142
|
+
|
|
140
143
|
def with_compute(self, compute: Dict[str, Any]) -> "Engine":
|
|
141
144
|
"""Configure compute resources for data processing."""
|
|
142
145
|
self._compute = compute
|
|
143
146
|
return self
|
|
144
|
-
|
|
147
|
+
|
|
145
148
|
def add_filter(self, filter_config: Dict[str, Any]) -> "Engine":
|
|
146
149
|
"""
|
|
147
150
|
Add a filter configuration.
|
|
148
|
-
|
|
151
|
+
|
|
149
152
|
Args:
|
|
150
153
|
filter_config: Dictionary containing filter configuration
|
|
151
|
-
|
|
154
|
+
|
|
152
155
|
Returns:
|
|
153
156
|
The Engine instance for method chaining
|
|
154
157
|
"""
|
|
155
158
|
self._filters.append(filter_config)
|
|
156
159
|
return self
|
|
157
|
-
|
|
160
|
+
|
|
158
161
|
def add_filters(self, *filter_configs: Dict[str, Any]) -> "Engine":
|
|
159
162
|
"""
|
|
160
163
|
Add multiple filter configurations at once.
|
|
161
|
-
|
|
164
|
+
|
|
162
165
|
Args:
|
|
163
166
|
*filter_configs: One or more filter configurations to add
|
|
164
|
-
|
|
167
|
+
|
|
165
168
|
Returns:
|
|
166
169
|
The Engine instance for method chaining
|
|
167
170
|
"""
|
|
168
171
|
self._filters.extend(filter_configs)
|
|
169
172
|
return self
|
|
170
|
-
|
|
173
|
+
|
|
171
174
|
def add_reference_table(self, name: str, config: Dict[str, Any]) -> "Engine":
|
|
172
175
|
"""
|
|
173
176
|
Add a reference table configuration.
|
|
174
|
-
|
|
177
|
+
|
|
175
178
|
Args:
|
|
176
179
|
name: Name of the reference table
|
|
177
180
|
config: Configuration dictionary for the reference table
|
|
178
|
-
|
|
181
|
+
|
|
179
182
|
Returns:
|
|
180
183
|
The Engine instance for method chaining
|
|
181
184
|
"""
|
|
182
185
|
self._reference_tables[name] = config
|
|
183
186
|
return self
|
|
184
|
-
|
|
187
|
+
|
|
185
188
|
def add_reference_tables(self, **tables: Dict[str, Any]) -> "Engine":
|
|
186
189
|
"""
|
|
187
190
|
Add multiple reference tables at once using keyword arguments.
|
|
188
|
-
|
|
191
|
+
|
|
189
192
|
Args:
|
|
190
193
|
**tables: Keyword arguments where keys are table names and values are configs
|
|
191
|
-
|
|
194
|
+
|
|
192
195
|
Returns:
|
|
193
196
|
The Engine instance for method chaining
|
|
194
197
|
"""
|
|
195
198
|
self._reference_tables.update(tables)
|
|
196
199
|
return self
|
|
197
|
-
|
|
200
|
+
|
|
198
201
|
def with_tags(self, **tags: str) -> "Engine":
|
|
199
202
|
"""Add tags to the engine configuration."""
|
|
200
203
|
if self._tags is None:
|
|
201
204
|
self._tags = {}
|
|
202
205
|
self._tags.update(tags)
|
|
203
206
|
return self
|
|
204
|
-
|
|
207
|
+
|
|
205
208
|
def with_index_config(self, config: IndexConfig) -> "Engine":
|
|
206
209
|
"""Configure index settings."""
|
|
207
210
|
self._index_config = config
|
|
208
211
|
return self
|
|
209
|
-
|
|
212
|
+
|
|
210
213
|
def with_training_config(
|
|
211
214
|
self,
|
|
212
215
|
data_split_strategy: Optional[str] = None,
|
|
213
216
|
data_split_params: Optional[Dict[str, Any]] = None,
|
|
214
|
-
**kwargs
|
|
217
|
+
**kwargs,
|
|
215
218
|
) -> "Engine":
|
|
216
219
|
"""Configure model training settings."""
|
|
217
220
|
if data_split_strategy:
|
|
218
221
|
self._training_config["data_split"] = {
|
|
219
222
|
"strategy": data_split_strategy,
|
|
220
|
-
**(data_split_params or {})
|
|
223
|
+
**(data_split_params or {}),
|
|
221
224
|
}
|
|
222
225
|
self._training_config.update(kwargs)
|
|
223
226
|
return self
|
|
224
|
-
|
|
227
|
+
|
|
225
228
|
def with_deployment_config(self, **kwargs) -> "Engine":
|
|
226
229
|
"""Configure deployment settings."""
|
|
227
230
|
self._deployment_config.update(kwargs)
|
|
228
231
|
return self
|
|
229
|
-
|
|
232
|
+
|
|
230
233
|
def with_query(self, name: str, query: Union[str, Dict[str, Any]]) -> "Engine":
|
|
231
234
|
"""Add a named query definition."""
|
|
232
235
|
if isinstance(query, str):
|
|
233
236
|
# Convert SQL string to a RankQueryConfig
|
|
234
|
-
query_def = QueryDefinition(
|
|
235
|
-
query=RankQueryConfig(type="rank", sql=query)
|
|
236
|
-
)
|
|
237
|
+
query_def = QueryDefinition(query=RankQueryConfig(type="rank", sql=query))
|
|
237
238
|
else:
|
|
238
239
|
query_def = QueryDefinition(**query)
|
|
239
|
-
|
|
240
|
+
|
|
240
241
|
self._queries[name] = query_def
|
|
241
242
|
return self
|
|
242
|
-
|
|
243
|
+
|
|
243
244
|
def validate(self) -> List[str]:
|
|
244
245
|
"""
|
|
245
246
|
Validate the current configuration.
|
|
246
|
-
|
|
247
|
+
|
|
247
248
|
Returns:
|
|
248
249
|
List of error messages, empty if configuration is valid
|
|
249
250
|
"""
|
|
250
251
|
errors = []
|
|
251
|
-
|
|
252
|
+
|
|
252
253
|
if not self._interactions:
|
|
253
254
|
errors.append("Interactions table is required")
|
|
254
|
-
|
|
255
|
+
|
|
255
256
|
# Validate reference tables
|
|
256
257
|
for name, config in self._reference_tables.items():
|
|
257
258
|
if not isinstance(config, dict) or not config:
|
|
258
259
|
errors.append(f"Invalid configuration for reference table '{name}'")
|
|
259
|
-
|
|
260
|
+
|
|
260
261
|
# Validate queries
|
|
261
262
|
for name, query in self._queries.items():
|
|
262
|
-
if not query or not getattr(query,
|
|
263
|
+
if not query or not getattr(query, "query", None):
|
|
263
264
|
errors.append(f"Invalid query definition for query '{name}'")
|
|
264
|
-
|
|
265
|
+
|
|
265
266
|
return errors
|
|
266
|
-
|
|
267
|
+
|
|
267
268
|
def is_valid(self) -> bool:
|
|
268
269
|
"""
|
|
269
270
|
Check if the current configuration is valid.
|
|
270
|
-
|
|
271
|
+
|
|
271
272
|
Returns:
|
|
272
273
|
True if configuration is valid, False otherwise
|
|
273
274
|
"""
|
|
274
275
|
return not bool(self.validate())
|
|
275
|
-
|
|
276
|
+
|
|
276
277
|
def build(self) -> EngineConfigV2:
|
|
277
278
|
"""
|
|
278
279
|
Build the EngineConfigV2 object with all configured settings.
|
|
279
|
-
|
|
280
|
+
|
|
280
281
|
Returns:
|
|
281
282
|
EngineConfigV2: The built engine configuration
|
|
282
|
-
|
|
283
|
+
|
|
283
284
|
Raises:
|
|
284
285
|
ValueError: If the configuration is invalid
|
|
285
286
|
"""
|
|
286
287
|
# Validate before building
|
|
287
288
|
if errors := self.validate():
|
|
288
289
|
raise ValueError(f"Invalid configuration: {', '.join(errors)}")
|
|
289
|
-
|
|
290
|
+
|
|
290
291
|
# Build data configuration
|
|
291
292
|
data_config = DataConfig(
|
|
292
293
|
interaction_table=self._create_data_table(self._interactions),
|
|
@@ -296,49 +297,51 @@ class Engine:
|
|
|
296
297
|
schema=self._schema_override,
|
|
297
298
|
compute=self._compute,
|
|
298
299
|
filters=self._filters if self._filters else None,
|
|
299
|
-
reference_tables=self._reference_tables if self._reference_tables else None
|
|
300
|
+
reference_tables=self._reference_tables if self._reference_tables else None,
|
|
300
301
|
)
|
|
301
|
-
|
|
302
|
+
|
|
302
303
|
# Build engine config
|
|
303
304
|
config = EngineConfigV2(
|
|
304
305
|
name=self._name,
|
|
305
306
|
description=self._description,
|
|
306
307
|
data=data_config,
|
|
307
308
|
version="v2",
|
|
308
|
-
tags=self._tags
|
|
309
|
+
tags=self._tags,
|
|
309
310
|
)
|
|
310
|
-
|
|
311
|
+
|
|
311
312
|
# Add optional configurations
|
|
312
313
|
if self._index_config:
|
|
313
314
|
config.index = self._index_config
|
|
314
|
-
|
|
315
|
+
|
|
315
316
|
if self._training_config:
|
|
316
317
|
config.training = TrainingConfig(**self._training_config)
|
|
317
|
-
|
|
318
|
+
|
|
318
319
|
if self._deployment_config:
|
|
319
320
|
config.deployment = DeploymentConfig(**self._deployment_config)
|
|
320
|
-
|
|
321
|
+
|
|
321
322
|
if self._queries:
|
|
322
323
|
config.queries = self._queries
|
|
323
|
-
|
|
324
|
+
|
|
324
325
|
return config
|
|
325
326
|
|
|
326
|
-
def _create_data_table(
|
|
327
|
+
def _create_data_table(
|
|
328
|
+
self, table: Union[str, Dict[str, Any], Any]
|
|
329
|
+
) -> Optional[DataConfigInteractionTable]:
|
|
327
330
|
"""
|
|
328
331
|
Create a DataConfigInteractionTable from input.
|
|
329
|
-
|
|
332
|
+
|
|
330
333
|
Args:
|
|
331
334
|
table: Can be a table name (str), a table config dict, or an existing config object.
|
|
332
|
-
|
|
335
|
+
|
|
333
336
|
Returns:
|
|
334
337
|
A properly configured DataConfigInteractionTable instance, or None if input is None.
|
|
335
|
-
|
|
338
|
+
|
|
336
339
|
Raises:
|
|
337
340
|
ValueError: If the input cannot be converted to a valid table configuration.
|
|
338
341
|
"""
|
|
339
342
|
if table is None:
|
|
340
343
|
return None
|
|
341
|
-
|
|
344
|
+
|
|
342
345
|
try:
|
|
343
346
|
if isinstance(table, str):
|
|
344
347
|
# It's a reference to a table by name
|
|
@@ -346,7 +349,7 @@ class Engine:
|
|
|
346
349
|
# Create the DataConfigInteractionTable with the config
|
|
347
350
|
result = DataConfigInteractionTable(actual_instance=config)
|
|
348
351
|
return result
|
|
349
|
-
|
|
352
|
+
|
|
350
353
|
if isinstance(table, dict):
|
|
351
354
|
# It's a config dictionary
|
|
352
355
|
if table.get("type") == "query":
|
|
@@ -357,13 +360,15 @@ class Engine:
|
|
|
357
360
|
config = ReferenceTableConfig(**table)
|
|
358
361
|
result = DataConfigInteractionTable(actual_instance=config)
|
|
359
362
|
return result
|
|
360
|
-
|
|
363
|
+
|
|
361
364
|
# Check if it's already a DataConfigInteractionTable
|
|
362
|
-
if hasattr(table,
|
|
365
|
+
if hasattr(table, "actual_instance") and hasattr(table, "to_dict"):
|
|
363
366
|
return table
|
|
364
|
-
|
|
365
|
-
raise ValueError(
|
|
366
|
-
|
|
367
|
+
|
|
368
|
+
raise ValueError(
|
|
369
|
+
f"Unsupported table configuration type: {type(table).__name__}"
|
|
370
|
+
)
|
|
371
|
+
|
|
367
372
|
except Exception as e:
|
|
368
373
|
raise ValueError(f"Failed to create data table: {str(e)}")
|
|
369
374
|
|
|
@@ -372,7 +377,7 @@ class Table:
|
|
|
372
377
|
"""
|
|
373
378
|
Factory methods for Table configurations.
|
|
374
379
|
"""
|
|
375
|
-
|
|
380
|
+
|
|
376
381
|
@staticmethod
|
|
377
382
|
def Postgres(
|
|
378
383
|
name: str,
|
|
@@ -384,7 +389,7 @@ class Table:
|
|
|
384
389
|
table: str,
|
|
385
390
|
replication_key: str,
|
|
386
391
|
description: Optional[str] = None,
|
|
387
|
-
schema: Optional[str] = None,
|
|
392
|
+
schema: Optional[str] = None, # database_schema
|
|
388
393
|
ssl_args: Optional[Dict[str, Any]] = None,
|
|
389
394
|
) -> PostgresTableConfig:
|
|
390
395
|
"""Create a Postgres table configuration."""
|
|
@@ -453,7 +458,7 @@ class Table:
|
|
|
453
458
|
replication_key=replication_key,
|
|
454
459
|
description=description,
|
|
455
460
|
)
|
|
456
|
-
|
|
461
|
+
|
|
457
462
|
@staticmethod
|
|
458
463
|
def File(
|
|
459
464
|
name: str,
|
|
@@ -484,7 +489,7 @@ class Table:
|
|
|
484
489
|
) -> MySQLTableConfig:
|
|
485
490
|
"""
|
|
486
491
|
Create a MySQL table configuration.
|
|
487
|
-
|
|
492
|
+
|
|
488
493
|
Args:
|
|
489
494
|
name: Name of the table configuration
|
|
490
495
|
host: MySQL server hostname or IP
|
|
@@ -496,7 +501,7 @@ class Table:
|
|
|
496
501
|
replication_key: Column name to use for change data capture
|
|
497
502
|
description: Optional description of the table
|
|
498
503
|
ssl_args: Optional SSL configuration parameters
|
|
499
|
-
|
|
504
|
+
|
|
500
505
|
Returns:
|
|
501
506
|
MySQLTableConfig: Configured MySQL table configuration
|
|
502
507
|
"""
|
|
@@ -531,7 +536,7 @@ class Table:
|
|
|
531
536
|
) -> MSSQLTableConfig:
|
|
532
537
|
"""
|
|
533
538
|
Create a Microsoft SQL Server table configuration.
|
|
534
|
-
|
|
539
|
+
|
|
535
540
|
Args:
|
|
536
541
|
name: Name of the table configuration
|
|
537
542
|
host: SQL Server hostname or IP
|
|
@@ -544,7 +549,7 @@ class Table:
|
|
|
544
549
|
replication_key: Column name to use for change data capture
|
|
545
550
|
description: Optional description of the table
|
|
546
551
|
ssl_args: Optional SSL configuration parameters
|
|
547
|
-
|
|
552
|
+
|
|
548
553
|
Returns:
|
|
549
554
|
MSSQLTableConfig: Configured SQL Server table configuration
|
|
550
555
|
"""
|
|
@@ -576,7 +581,7 @@ class Table:
|
|
|
576
581
|
) -> MongoDBTableConfig:
|
|
577
582
|
"""
|
|
578
583
|
Create a MongoDB table configuration.
|
|
579
|
-
|
|
584
|
+
|
|
580
585
|
Args:
|
|
581
586
|
name: Name of the table configuration
|
|
582
587
|
connection_uri: MongoDB connection URI
|
|
@@ -585,7 +590,7 @@ class Table:
|
|
|
585
590
|
replication_key: Field name to use for change data capture
|
|
586
591
|
description: Optional description of the table
|
|
587
592
|
**kwargs: Additional MongoDB connection parameters
|
|
588
|
-
|
|
593
|
+
|
|
589
594
|
Returns:
|
|
590
595
|
MongoDBTableConfig: Configured MongoDB table configuration
|
|
591
596
|
"""
|
|
@@ -596,7 +601,7 @@ class Table:
|
|
|
596
601
|
collection=collection,
|
|
597
602
|
replication_key=replication_key,
|
|
598
603
|
description=description,
|
|
599
|
-
**kwargs
|
|
604
|
+
**kwargs,
|
|
600
605
|
)
|
|
601
606
|
|
|
602
607
|
@staticmethod
|
|
@@ -615,7 +620,7 @@ class Table:
|
|
|
615
620
|
) -> RedshiftTableConfig:
|
|
616
621
|
"""
|
|
617
622
|
Create an Amazon Redshift table configuration.
|
|
618
|
-
|
|
623
|
+
|
|
619
624
|
Args:
|
|
620
625
|
name: Name of the table configuration
|
|
621
626
|
host: Redshift cluster endpoint
|
|
@@ -628,7 +633,7 @@ class Table:
|
|
|
628
633
|
replication_key: Column name to use for change data capture
|
|
629
634
|
description: Optional description of the table
|
|
630
635
|
ssl_args: Optional SSL configuration parameters
|
|
631
|
-
|
|
636
|
+
|
|
632
637
|
Returns:
|
|
633
638
|
RedshiftTableConfig: Configured Redshift table configuration
|
|
634
639
|
"""
|
|
@@ -648,11 +653,12 @@ class Table:
|
|
|
648
653
|
kwargs.update(ssl_args)
|
|
649
654
|
return RedshiftTableConfig(**kwargs)
|
|
650
655
|
|
|
656
|
+
|
|
651
657
|
class View:
|
|
652
658
|
"""
|
|
653
659
|
Factory methods for View configurations.
|
|
654
660
|
"""
|
|
655
|
-
|
|
661
|
+
|
|
656
662
|
@staticmethod
|
|
657
663
|
def SQL(
|
|
658
664
|
name: str,
|
|
@@ -664,11 +670,15 @@ class View:
|
|
|
664
670
|
Create a SQL view configuration.
|
|
665
671
|
"""
|
|
666
672
|
transform_type = "MATERIALIZED_VIEW" if materialized else "VIEW"
|
|
667
|
-
|
|
673
|
+
|
|
668
674
|
return SQLViewConfig(
|
|
669
675
|
name=name,
|
|
670
676
|
sql_query=query,
|
|
671
|
-
sql_transform_type=
|
|
677
|
+
sql_transform_type=(
|
|
678
|
+
SQLTransformType(transform_type)
|
|
679
|
+
if isinstance(transform_type, str)
|
|
680
|
+
else transform_type
|
|
681
|
+
),
|
|
672
682
|
description=description,
|
|
673
683
|
)
|
|
674
684
|
|