Merge pull request #2 from FlipsideCrypto/STREAM-1111/fsc_utils_components_abstraction

Stream 1111/fsc utils components abstraction
This commit is contained in:
Shah Newaz Khan 2024-12-09 18:58:10 -08:00 committed by GitHub
commit 006980d40f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 113 deletions

View File

@ -1,45 +0,0 @@
{% set schema = "strangelove" %}
{% set config = fromyaml(config_strangelove_udfs(schema_name = schema, utils_schema_name = "quicknode_utils")) %}
{% set raw_test_queries %}
strangelove.get:
- |
'https://api.strange.love/cosmoshub/mainnet/rpc/block_by_hash'
- |
{
'blockHash': '0xD70952032620CC4E2737EB8AC379806359D8E0B17B0488F627997A0B043ABDED'
}
strangelove.post:
- |
'https://endpoint'
- |
{
'foo': 'bar'
}
{% endset %}
{% set test_queries = fromyaml(raw_test_queries) %}
{{ test_queries }}
{{ schema }}
_____
columns:
{%- for item in config %}
- name: {{ item["name"] | replace(schema~".", "") }}
tests:
- test_marketplace_udf:
name: test_{{ item["name"].replace(".", "__") ~ "_status_200" }}
args: >
{{ test_queries[item["name"]] | join(", ") | indent(16) }}
validations:
- result:status_code = 200
{%- endfor %}
=====================
{{ config | pprint}}
{# {% for item in config %}
{% if item["return_type"][0] != "VARIANT"%}
{{ item["return_type"][0] }}
{% endif %}
{% endfor %} #}

View File

@ -1,3 +0,0 @@
{{crud_udfs_by_chain(config_evm_high_level_abstractions, 'ethereum', 'mainnet', false)}}
{{- crud_udfs_by_chain(config_evm_rpc_primitives, "ethereum", None, False) -}}
{{- crud_udfs_by_chain(config_evm_rpc_primitives, "ethereum", None, true) -}}

View File

@ -25,7 +25,7 @@ clean-targets: # directories to be removed by `dbt clean`
- "dbt_packages"
models:
livequery_models:
livequery_base:
deploy:
+materialized: ephemeral
core:
@ -34,20 +34,13 @@ models:
+enabled: '{{ true if env_var("ENABLE_SNOWFLAKE_SECRETS", "") else false }}'
evm:
+tags: evm
marketplace:
+tags: marketplace
tests:
+store_failures: true # all tests
livequery_models:
deploy:
marketplace:
blockpour:
# TODO: enable tests for blockpour once we get an API key
+enabled: false
seeds:
+enabled: "{{ target.name not in ['livequery', 'livequery_dev'] }}"
+enabled: "{{ target.database not in ['livequery', 'livequery_dev'] }}"
on-run-start:
- "{{ create_sps() }}"
@ -67,8 +60,8 @@ vars:
UPDATE_UDFS_AND_SPS: false
DROP_UDFS_AND_SPS: false
UPDATE_SNOWFLAKE_TAGS: true
STREAMLINE_INVOKE_STREAMS: False
STREAMLINE_USE_DEV_FOR_EXTERNAL_TABLES: False
STREAMLINE_INVOKE_STREAMS: false
STREAMLINE_USE_DEV_FOR_EXTERNAL_TABLES: false
STUDIO_TEST_USER_ID: '{{ env_var("STUDIO_TEST_USER_ID", "98d15c30-9fa5-43cd-9c69-3d4c0bb269f5") }}'
API_INTEGRATION: '{{ var("config")[target.name]["API_INTEGRATION"] }}'

View File

@ -117,36 +117,6 @@
{%- endfor -%}
{%- endmacro -%}
{% macro crud_udfs_by_marketplace(config_func, schema, utility_schema, drop_) %}
{#
Generate create or drop statements for a list of udf configs for a given blockchain and network
config_func: function that returns a list of udf configs
schema: schema name
utility_schema: utility schema name
#}
CREATE SCHEMA IF NOT EXISTS {{ schema }};
{%- set configs = fromyaml(config_func(schema, utility_schema)) if utility_schema else fromyaml(config_func(schema, schema)) -%}
{%- for udf in configs -%}
{{- create_or_drop_function_from_config(udf, drop_=drop_) -}}
{%- endfor -%}
{%- endmacro -%}
{% macro crud_marketplace_udfs(config_func, schemaName, base_api_schema_name, drop_) %}
{#
Generate create or drop statements for a list of udf configs for a given schema and api
config_func: function that returns a list of udf configs
schemaName: the target schema to build the udfs
base_api_schema_name: the schema that contains base api functions
drop_: whether to drop or create the udfs
#}
{%- set udfs = fromyaml(config_func(schemaName, base_api_schema_name)) -%}
{%- for udf in udfs -%}
{{- create_or_drop_function_from_config(udf, drop_=drop_) -}}
{%- endfor -%}
{%- endmacro -%}
{% macro ephemeral_deploy_core(config) %}
{#
This macro is used to deploy functions using ephemeral models.
@ -190,26 +160,4 @@
SELECT '{{ model.schema }}' as schema_
{%- endmacro -%}
{% macro ephemeral_deploy_marketplace(configs) %}
{#
This macro is used to deploy functions using ephemeral models.
It should only be used within an ephemeral model.
#}
{%- set schema = this.schema -%}
{%- set utility_schema = this.identifier -%}
{% if execute and (var("UPDATE_UDFS_AND_SPS") or var("DROP_UDFS_AND_SPS")) and model.unique_id in selected_resources %}
{% set sql %}
{% for config in configs %}
{{- crud_udfs_by_marketplace(config, schema, utility_schema, var("DROP_UDFS_AND_SPS")) -}}
{%- endfor -%}
{%- endset -%}
{%- if var("DROP_UDFS_AND_SPS") -%}
{%- do log("Drop marketplace udfs: " ~ this.database ~ "." ~ schema, true) -%}
{%- else -%}
{%- do log("Deploy marketplace udfs: " ~ this.database ~ "." ~ schema, true) -%}
{%- endif -%}
{%- do run_query(sql ~ apply_grants_by_schema(schema)) -%}
{%- endif -%}
SELECT '{{ model.schema }}' as schema_
{%- endmacro -%}