-
Notifications
You must be signed in to change notification settings - Fork 0
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
Codespaces proof-of-concept #208
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a118470
WIP adding devcontainer
ian-r-rose 8c535f0
Try to make poetry environment the default vs code interpreter
ian-r-rose 4e941ef
Use recommended settings schema
ian-r-rose 7b2790f
Try to configure dbt
ian-r-rose 61856bd
Work on adding secrets config
ian-r-rose d2fda9d
Fix warehouse name
ian-r-rose 51a1ef2
Add some useful extensions
ian-r-rose 0aee075
Update devcontainer settings to allow no-verify commits
ian-r-rose 0a751c2
WIP jupyterlab
ian-r-rose f44a806
Install deps
ian-r-rose ad0e328
Install jupyterlab in dockerfile
ian-r-rose 8f17983
Don't include pre-commit feature, try forcing it to poetry env
ian-r-rose ddc3716
Use system language to avoid virtualenv for these hooks
ian-r-rose 8add521
Remove jupyter devcontainer for now
ian-r-rose 91ab479
Add some docs for how t to use codespaces
ian-r-rose b7ee688
Add note to setup doc
ian-r-rose 362456e
fixed typo
britt-allen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "dbt", | ||
"image": "mcr.microsoft.com/devcontainers/python:1-3.10-bookworm", | ||
"features": { | ||
"ghcr.io/devcontainers-contrib/features/poetry:2": {}, | ||
"ghcr.io/devcontainers/features/terraform:1": {} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"settings": { | ||
"dbt.queryLimit": 50, | ||
"git.allowNoVerifyCommit": true, | ||
"python.defaultInterpreterPath": ".venv/bin/python" | ||
}, | ||
"extensions": [ | ||
"innoverio.vscode-dbt-power-user" | ||
] | ||
} | ||
}, | ||
"secrets": { | ||
"SNOWFLAKE_USER": { | ||
"description": "Your Snowflake Username" | ||
}, | ||
"SNOWFLAKE_PASSWORD": { | ||
"description": "Your Snowflake Password" | ||
}, | ||
"DBT_SCHEMA": { | ||
"description": "The dev schema into which to build your dbt models (e.g. DBT_<YOURNAME>)" | ||
} | ||
}, | ||
"postCreateCommand": "poetry config virtualenvs.in-project true && poetry install && poetry run pre-commit install && mkdir -p ~/.dbt && cp .devcontainer/profiles.yml ~/.dbt" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
dse_snowflake: | ||
target: snowflake_dev | ||
outputs: | ||
snowflake_dev: | ||
type: snowflake | ||
account: heb41095 | ||
authenticator: username_password_mfa | ||
user: "{{ env_var('SNOWFLAKE_USER') }}" | ||
password: "{{ env_var('SNOWFLAKE_PASSWORD') }}" | ||
role: TRANSFORMER_DEV | ||
warehouse: TRANSFORMING_XS_DEV | ||
database: TRANSFORM_DEV | ||
schema: "{{ env_var('DBT_SCHEMA') }}" | ||
threads: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,8 +84,8 @@ repos: | |
hooks: | ||
- name: Dbt deps | ||
id: dbt-deps | ||
language: python | ||
entry: dbt deps --project-dir=transform | ||
language: system | ||
entry: poetry run dbt deps --project-dir transform | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Caught some real bugs in the pre-commit set-up when doing this! |
||
always_run: false | ||
pass_filenames: false | ||
types: [sql] | ||
|
@@ -103,7 +103,7 @@ repos: | |
hooks: | ||
- id: sqlfluff | ||
name: sqlfluff | ||
language: python | ||
language: system | ||
description: "Lints sql files with `SQLFluff`" | ||
types: [sql] | ||
require_serial: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Developing using Codespaces | ||
|
||
GitHub Codespaces allow you to spin up an ephemeral development environment in VS Code | ||
which includes a git repository, configurations, and pre-installed libraries. | ||
It provides an easy way for developers to get started working in a repository, | ||
especially if they are uncomfortable | ||
|
||
## Creating a Codespace | ||
|
||
Go to the "Code" dropdown from the main repository page, | ||
select the three dot dropdown, and select "New with options..." | ||
This will allow more configuration than the default codespace. | ||
|
||
![Create a new codespace](images/create-new-codespace.png) | ||
|
||
In the codespace configuration form, you will have an option to add "Recommended Secrets". | ||
This is where you can add your personal Snowflake credentials to your codespace, | ||
allowing for development against our Snowflake warehouse, including using dbt. | ||
You should only add credentials for accounts that are protected by multi-factor authentication (MFA). | ||
|
||
![Add codespace secrets](images/codespace-secrets.png) | ||
|
||
After you have added your secrets, click "Create Codespace". | ||
Building it may take a few minutes, | ||
but then you should be redirected to a VS Code environment in your browser. | ||
|
||
## Launching an existing Codespace | ||
|
||
Once your codespace is created, you should be able to launch it | ||
without re-creating it every time using the "Code" dropdown, | ||
going to "Open in...", and selecting "Open in browser": | ||
|
||
![Launch codespace](images/launch-codespace.png) | ||
|
||
## Using a Codespace | ||
|
||
Once you have created and configured a codespace, | ||
you have access to a relatively full-featured VS Code-based development environment. | ||
This includes: | ||
|
||
* An integrated bash terminal | ||
* dbt profiles configured | ||
* All Python dependencies for the project | ||
* All pre-commit hooks installed | ||
* git configured using your GitHub account | ||
|
||
### Usage notes | ||
|
||
1. When you launch a new codespace, it can take a couple of minutes for all of the extensions to install. In particular, this means that the Python environment may not be fully set-up when you land in VS Code. We recommend closing existing terminal sessions and starting a new one once the extensions have finished installing. | ||
1. The first time you make a commit, the pre-commit hooks will be installed. This may take a few minutes. Subsequent commits will take less time. | ||
1. If the pre-commit hooks fail when making a commit, it will give you the opportunity to open the git logs to view the errors. If you are unable to fix the errors for whatever reason, you can always make a new commit from the command line with `--no-verify`: | ||
```bash | ||
git commit --no-verify -m "Your commit message" | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the secrets that you need to set in order to do dbt-related work in the codespace