Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STREAM-383/STREAM-668/deploy-to-hosted-account #54

Merged
merged 11 commits into from
Oct 17, 2023
2 changes: 1 addition & 1 deletion .github/workflows/dbt_docs_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
name: docs_update
runs-on: ubuntu-latest
environment:
name: workflow_prod
name: prod

steps:
- uses: actions/checkout@v3
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/dbt_integration_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: integration test
run-name: ${{ github.event.inputs.branch }}

on:
workflow_dispatch:
inputs:
environment:
type: choice
description: DBT Run Environment
required: true
options:
- dev
- prod
default: dev
warehouse:
type: choice
description: Snowflake warehouse
required: true
options:
- DBT
- DBT_CLOUD
default: DBT
schedule:
# Runs “Daily at midnight GMT” (see https://crontab.guru)
- cron: '0 0 * * *'

concurrency:
group: ${{ github.workflow }}

jobs:
scheduled:
uses: ./.github/workflows/dbt.yml
if: github.event_name == 'schedule' || github.event_name == 'push'
secrets: inherit
with:
warehouse: DBT_CLOUD
environment: prod
command: test -s test___utils_udf_introspect

dispached:
uses: ./.github/workflows/dbt.yml
if: github.event_name == 'workflow_dispatch'
secrets: inherit
with:
warehouse: ${{ inputs.warehouse }}
environment: workflow_${{ inputs.environment }}
command: test -s test___utils_udf_introspect
3 changes: 2 additions & 1 deletion .github/workflows/dbt_run_adhoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
options:
- dev
- prod
- hosted
default: dev
warehouse:
type: choice
Expand All @@ -35,5 +36,5 @@ jobs:
secrets: inherit
with:
warehouse: ${{ inputs.warehouse }}
environment: workflow_${{ inputs.environment }}
environment: ${{ inputs.environment }}
command: ${{ inputs.dbt_command }}
2 changes: 1 addition & 1 deletion .github/workflows/dbt_run_dev_refresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ jobs:
uses: ./.github/workflows/dbt.yml
secrets: inherit
with:
environment: workflow_prod
environment: prod
command: run-operation run_sp_create_prod_clone
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
secrets: inherit
with:
warehouse: DBT_CLOUD
environment: workflow_prod
environment: prod
command: test --selector test_udfs --threads 24

dispached:
Expand Down
6 changes: 6 additions & 0 deletions cspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ version: "0.2"
language: en
words:
- aave
- arbitrum
- AVAX
- bitquery
- blockpour
- CELO
- chainbase
- credmark
- crosschain
- dapplooker
- doseq
- fromyaml
Expand All @@ -15,7 +19,9 @@ words:
- livequery
- quicknode
- reingest
- sepolia
- solana
- strangelove
- subquery
- udfs
- zkevm
29 changes: 24 additions & 5 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ profile: "livequery"
# found in the "models/" directory. You probably won't need to change these!
model-paths: ["models"]
analysis-paths: ["analysis"]
# test-paths: ["tests"]
test-paths: ["tests"]
seed-paths: ["data"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]
Expand Down Expand Up @@ -65,10 +65,29 @@ vars:
UPDATE_SNOWFLAKE_TAGS: true
STREAMLINE_INVOKE_STREAMS: False
STREAMLINE_USE_DEV_FOR_EXTERNAL_TABLES: False
REST_API_PREFIX_PROD: bqco8lkjsb.execute-api.us-east-1.amazonaws.com/prod/
REST_API_PREFIX_DEV: u5z0tu43sc.execute-api.us-east-1.amazonaws.com/stg/
API_INTEGRATION: AWS_LIVE_QUERY{{ "_STG" if target.name != "prod" else "" }}
AWS_REGION: us-east-1
STUDIO_TEST_USER_ID: '{{ env_var("STUDIO_TEST_USER_ID", "98d15c30-9fa5-43cd-9c69-3d4c0bb269f5") }}'

API_INTEGRATION: '{{ var("config")[target.name]["API_INTEGRATION"] }}'
EXTERNAL_FUNCTION_URI: '{{ var("config")[target.name]["EXTERNAL_FUNCTION_URI"] }}'
ENABLE_SNOWFLAKE_SECRETS: '{{ env_var("ENABLE_SNOWFLAKE_SECRETS", "") }}'
ROLES: '{{ var("config")[target.name]["ROLES"] }}'

config:
# The keys correspond to dbt profiles and are case sensitive
dev:
API_INTEGRATION: AWS_LIVE_QUERY_STG
EXTERNAL_FUNCTION_URI: u5z0tu43sc.execute-api.us-east-1.amazonaws.com/stg/
ROLES: []
juls858 marked this conversation as resolved.
Show resolved Hide resolved
prod:
API_INTEGRATION: AWS_LIVE_QUERY
EXTERNAL_FUNCTION_URI: bqco8lkjsb.execute-api.us-east-1.amazonaws.com/prod/
ROLES:
- VELOCITY_INTERNAL
- VELOCITY_ETHEREUM
- INTERNAL_DEV
- BI_ANALYTICS_READER
hosted:
API_INTEGRATION: AWS_LIVEQUERY
EXTERNAL_FUNCTION_URI: dlcb3tpiz8.execute-api.us-east-1.amazonaws.com/hosted/
ROLES:
- DATA_READER
2 changes: 1 addition & 1 deletion macros/core/utils.yaml.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- [request_id, STRING]
- [key, STRING]
func_type: SECURE
return_type: TEXT
return_type: OBJECT
options: |
NOT NULL
RETURNS NULL ON NULL INPUT
Expand Down
4 changes: 2 additions & 2 deletions macros/grants.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
This can be manually run to grant permissions to a new schema:
`dbt run-operation apply_grants_by_schema --args '{"schema": "my_schema"}'`
#}
{% if target.name == "prod" %}
{% if target.name in ("prod", "hosted") %}
{%- set outer = namespace(sql="") -%}
{% for role in ["VELOCITY_INTERNAL", "VELOCITY_ETHEREUM", "INTERNAL_DEV", "BI_ANALYTICS_READER"] %}
{% for role in var("ROLES") %}
{% set sql -%}
{% if schema.startswith("_") %}
REVOKE USAGE ON SCHEMA {{ target.database }}.{{ schema }} FROM {{ role }};
Expand Down
2 changes: 1 addition & 1 deletion macros/livequery/manage_udfs.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% endmacro %}

{%- macro construct_api_route(route) -%}
'https://{{ var("REST_API_PREFIX_PROD") | lower if target.name == "prod" else var("REST_API_PREFIX_DEV") | lower }}{{ route }}'
'https://{{ var("EXTERNAL_FUNCTION_URI") | lower }}{{ route }}'
{%- endmacro -%}

{%- macro compile_signature(
Expand Down
1 change: 1 addition & 0 deletions models/deploy/core/_utils.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ models:
- name: udf_introspect
tests:
- test_udf:
name: test___utils_udf_introspect
args: "'hello'"
assertions:
- result = 'hello'
4 changes: 2 additions & 2 deletions models/mapping_tables/_eth__decoded_logs.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{{ config(
materialized = 'view',
grants = {'+select': ['INTERNAL_DEV']}
grants = {'+select': var('ROLES')}
) }}

SELECT *
FROM
{{ source(
'ethereum_core',
'ez_decoded_event_logs'
) }}
) }}
4 changes: 2 additions & 2 deletions models/mapping_tables/_eth__logs.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{{ config(
materialized = 'view',
grants = {'+select': ['INTERNAL_DEV']}
grants = {'+select': var('ROLES')}
) }}

SELECT *
FROM
{{ source(
'ethereum_core',
'fact_event_logs'
) }}
) }}
2 changes: 1 addition & 1 deletion models/mapping_tables/_evm__abi_map.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ config(
materialized = 'view',
grants = {'+select': ['INTERNAL_DEV']}
grants = {'+select': var('ROLES')}
) }}

SELECT
Expand Down
2 changes: 1 addition & 1 deletion models/mapping_tables/_evm__contracts_map.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ config(
materialized = 'view',
grants = {'+select': ['INTERNAL_DEV']}
grants = {'+select': ['INTERNAL_DEV'] if target.name != "hosted" else ['DATA_READER'] }
) }}

SELECT
Expand Down
2 changes: 1 addition & 1 deletion models/mapping_tables/_evm__native_symbol_map.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ config(
materialized = 'view',
grants = {'+select': ['INTERNAL_DEV']}
grants = {'+select': var('ROLES')}
) }}

WITH blockchain_assets AS (
Expand Down
27 changes: 20 additions & 7 deletions profiles.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
livequery:
target: prod
target: dev
outputs:
dev:
type: snowflake
Expand All @@ -10,10 +10,10 @@ livequery:
region: "{{ env_var('REGION') }}"
database: "{{ env_var('DATABASE') }}"
warehouse: "{{ env_var('WAREHOUSE') }}"
schema: SILVER
threads: 4
schema: LIVE
threads: 24
client_session_keep_alive: False
query_tag: livequery_curator
query_tag: dbt-livequery-dev
prod:
type: snowflake
account: "{{ env_var('ACCOUNT') }}"
Expand All @@ -23,7 +23,20 @@ livequery:
region: "{{ env_var('REGION') }}"
database: "{{ env_var('DATABASE') }}"
warehouse: "{{ env_var('WAREHOUSE') }}"
schema: SILVER
threads: 4
schema: LIVE
threads: 24
client_session_keep_alive: False
query_tag: livequery_curator
query_tag: dbt-livequery-prod
hosted:
type: snowflake
account: "{{ env_var('ACCOUNT') }}"
role: "{{ env_var('ROLE') }}"
user: "{{ env_var('USER') }}"
password: "{{ env_var('PASSWORD') }}"
region: "{{ env_var('REGION') }}"
database: "{{ env_var('DATABASE') }}"
warehouse: "{{ env_var('WAREHOUSE') }}"
schema: LIVE
threads: 24
client_session_keep_alive: False
query_tag: dbt-livequery-hosted-prod