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

AN-3383/init setup #1

Merged
merged 3 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 3 additions & 45 deletions .github/workflows/dbt_docs_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,6 @@ concurrency:
group: ${{ github.workflow }}

jobs:
scheduled_run:
name: docs_update
runs-on: ubuntu-latest
environment:
name: workflow_prod

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v1
with:
python-version: "3.7.x"

- name: install dependencies
run: |
pip install dbt-snowflake==${{ vars.DBT_VERSION }}
dbt deps
- name: checkout docs branch
run: |
git checkout -b docs origin/main

- name: generate dbt docs
run: dbt docs generate -t prod

- name: move files to docs directory
run: |
mkdir -p ./docs
cp target/{catalog.json,manifest.json,index.html} docs/
- name: clean up target directory
run: dbt clean

- name: check for changes
run: git status

- name: stage changed files
run: git add .

- name: commit changed files
run: |
git config user.email "abc@xyz"
git config user.name "github-actions"
git commit -am "Auto-update docs"
- name: push changes to docs
run: |
git push -f --set-upstream origin docs
called_workflow_template:
uses: FlipsideCrypto/analytics-workflow-templates/.github/workflows/dbt_docs_updates.yml@main
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/dbt_run_adhoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ jobs:
dbt deps
- name: Run DBT Jobs
run: |
${{ inputs.dbt_command }}
${{ inputs.dbt_command }}
5 changes: 3 additions & 2 deletions .github/workflows/dbt_run_dev_refresh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ run-name: dbt_run_dev_refresh
on:
workflow_dispatch:
# schedule:
# # Runs "at 9:00 UTC" (see https://crontab.guru)
# - cron: '0 9 * * *'
# TODO enable schedule when ready
# Runs "at 9:00 UTC" (see https://crontab.guru)
# - cron: '0 9 * * *'

env:
USE_VARS: "${{ vars.USE_VARS }}"
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/dbt_run_scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: dbt_run_scheduled
run-name: dbt_run_scheduled

on:
workflow_dispatch:
# schedule:
# TODO - enable once pipeline created
# Runs "every hour" (see https://crontab.guru)
# - cron: '0 */1 * * *'

env:
USE_VARS: "${{ vars.USE_VARS }}"
DBT_PROFILES_DIR: "${{ vars.DBT_PROFILES_DIR }}"
DBT_VERSION: "${{ vars.DBT_VERSION }}"
ACCOUNT: "${{ vars.ACCOUNT }}"
ROLE: "${{ vars.ROLE }}"
USER: "${{ vars.USER }}"
PASSWORD: "${{ secrets.PASSWORD }}"
REGION: "${{ vars.REGION }}"
DATABASE: "${{ vars.DATABASE }}"
WAREHOUSE: "${{ vars.WAREHOUSE }}"
SCHEMA: "${{ vars.SCHEMA }}"

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

jobs:
called_workflow_template:
uses: FlipsideCrypto/analytics-workflow-templates/.github/workflows/dbt_run_template.yml@main
with:
dbt_command: >
dbt run
environment: workflow_prod
warehouse: ${{ vars.WAREHOUSE }}
secrets: inherit
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ logs/
.vscode/
.env
.DS_Store
.user.yml
.user.yml

local/
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

# Please find and replace all instances of `xyz` with your project name.
# Aurora Models

## Profile Set Up

#### Use the following within profiles.yml
----

```yml
xyz:
aurora:
target: dev
outputs:
dev:
Expand All @@ -17,7 +16,7 @@ xyz:
user: <USERNAME>
password: <PASSWORD>
region: <REGION>
database: xyz_DEV
database: AURORA_DEV
warehouse: <WAREHOUSE>
schema: silver
threads: 4
Expand Down Expand Up @@ -73,5 +72,5 @@ dbt run --var '{"UPDATE_SNOWFLAKE_TAGS":True}' -s models/core/core__fact_swaps.s

```
select *
from table(xyz.information_schema.tag_references('xyz.core.fact_blocks', 'table'));
from table(auruora.information_schema.tag_references('aurora.core.fact_blocks', 'table'));
```
7 changes: 4 additions & 3 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Name your project! Project names should contain only lowercase characters
# and underscores. A good package name should reflect your organization's
# name or the intended use of these models
name: "xyz_models"
name: "aurora_models"
version: "1.0.0"
config-version: 2

require-dbt-version: ">=1.4.0"

# This setting configures which "profile" dbt uses for this project.
profile: "xyz"
profile: "aurora"

# These configurations specify where dbt should look for different types of files.
# The `model-paths` config, for example, states that models in this project can be
Expand Down Expand Up @@ -42,6 +42,7 @@ models:
vars:
"dbt_date:time_zone": GMT
"UPDATE_SNOWFLAKE_TAGS": TRUE
"UPDATE_UDFS_AND_SPS": FALSE

tests:
+store_failures: true # all tests
Expand All @@ -51,4 +52,4 @@ on-run-start:
- '{{create_udfs()}}'

on-run-end:
- '{{ apply_meta_as_tags(results) }}'
- '{{ apply_meta_as_tags(results) }}'
4 changes: 2 additions & 2 deletions macros/create_sps.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% macro create_sps() %}
{% if target.database == 'xyz' %}
{% if target.database == 'AURORA' %}
CREATE SCHEMA IF NOT EXISTS _internal;
{{ sp_create_prod_clone('_internal') }};
{% endif %}
{% endmacro %}
{% endmacro %}
4 changes: 4 additions & 0 deletions macros/create_udfs.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
{% macro create_udfs() %}
{% if var("UPDATE_UDFS_AND_SPS") %}
{{- fsc_utils.create_udfs() -}}
{% endif %}
{% endif %}
{% endmacro %}
2 changes: 1 addition & 1 deletion macros/run_sp_create_prod_clone.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% macro run_sp_create_prod_clone() %}
{% set clone_query %}
call xyz._internal.create_prod_clone('xyz', 'xyz_dev', 'internal_dev');
call aurora._internal.create_prod_clone('aurora', 'aurora_dev', 'internal_dev');
{% endset %}

{% do run_query(clone_query) %}
Expand Down
4 changes: 2 additions & 2 deletions macros/tags/add_database_or_schema_tags.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{% macro add_database_or_schema_tags() %}
{{ set_database_tag_value(
'BLOCKCHAIN_NAME',
'xyz'
'AURORA'
) }}
{{ set_database_tag_value(
'BLOCKCHAIN_TYPE',
'IBC'
'EVM'
) }}
{% endmacro %}
13 changes: 6 additions & 7 deletions models/descriptions/__overview__.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{% docs __overview__ %}

# Welcome to the Flipside Crypto xyz Models Documentation
# Welcome to the Flipside Crypto Aurora Models Documentation

## **What does this documentation cover?**
The documentation included here details the design of the xyz
tables and views available via [Flipside Crypto.](https://flipsidecrypto.xyz/) For more information on how these models are built, please see [the github repository.](https://github.com/flipsideCrypto/xyz-models/)
The documentation included here details the design of the Aurora
tables and views available via [Flipside Crypto.](https://flipsidecrypto.xyz/) For more information on how these models are built, please see [the github repository.](https://github.com/flipsideCrypto/aurora-models/)

## **How do I use these docs?**
The easiest way to navigate this documentation is to use the Quick Links below. These links will take you to the documentation for each table, which contains a description, a list of the columns, and other helpful information.
Expand All @@ -17,7 +17,7 @@ There is more information on how to use dbt docs in the last section of this doc

**Click on the links below to jump to the documentation for each schema.**

### Core Tables (`xyz`.`CORE`.`<table_name>`)
### Core Tables (`AURORA`.`CORE`.`<table_name>`)

**Dimension Tables:**

Expand All @@ -33,8 +33,7 @@ There is more information on how to use dbt docs in the last section of this doc

## **Data Model Overview**

The xyz
models are built a few different ways, but the core fact tables are built using three layers of sql models: **bronze, silver, and gold (or core).**
The Aurora models are built a few different ways, but the core fact tables are built using three layers of sql models: **bronze, silver, and gold (or core).**

- Bronze: Data is loaded in from the source as a view
- Silver: All necessary parsing, filtering, de-duping, and other transformations are done here
Expand Down Expand Up @@ -68,7 +67,7 @@ Note that you can also right-click on models to interactively filter and explore
- [Flipside](https://flipsidecrypto.xyz/)
- [Velocity](https://app.flipsidecrypto.com/velocity?nav=Discover)
- [Tutorials](https://docs.flipsidecrypto.com/our-data/tutorials)
- [Github](https://github.com/FlipsideCrypto/xyz-models)
- [Github](https://github.com/FlipsideCrypto/aurora-models)
- [What is dbt?](https://docs.getdbt.com/docs/introduction)

{% enddocs %}
2 changes: 1 addition & 1 deletion models/sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2

sources:
- name: crosschain
database: "{{ 'crosschain' if target.database == 'xyz' else 'crosschain_dev' }}"
database: "{{ 'crosschain' if target.database == 'AURORA' else 'crosschain_dev' }}"
schema: core
tables:
- name: dim_date_hours
Expand Down
2 changes: 1 addition & 1 deletion packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ packages:
- package: calogica/dbt_expectations
version: [">=0.4.0", "<0.9.0"]
- git: https://github.com/FlipsideCrypto/fsc-utils.git
revision: v1.3.0
revision: v1.3.0
8 changes: 4 additions & 4 deletions profiles.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
xyz:
aurora:
target: dev
outputs:
dev:
type: snowflake
account: "{{ env_var('ACCOUNT') }}"
user: "{{ env_var('USER') }}"
password: "{{ env_var('PASSWORD') }}"
authenticator: externalbrowser
role: "{{ env_var('ROLE') }}"
schema: "{{ env_var('SCHEMA') }}"
region: "{{ env_var('REGION') }}"
Expand All @@ -17,7 +17,7 @@ xyz:
type: snowflake
account: "{{ env_var('ACCOUNT') }}"
user: "{{ env_var('USER') }}"
password: "{{ env_var('PASSWORD') }}"
authenticator: externalbrowser
role: "{{ env_var('ROLE') }}"
schema: "{{ env_var('SCHEMA') }}"
region: "{{ env_var('REGION') }}"
Expand All @@ -26,4 +26,4 @@ xyz:
threads: 8
client_session_keep_alive: False
config:
send_anonymous_usage_stats: False
send_anonymous_usage_stats: False