From bc7e9c34379b88eb5ee586360637dbaaf9114ce5 Mon Sep 17 00:00:00 2001 From: Jeremiah Hansen Date: Tue, 5 Sep 2023 12:02:44 -0600 Subject: [PATCH 1/4] first devcontainer changes --- .devcontainer/Dockerfile | 18 ++++++++++++++++++ .devcontainer/config | 9 +++++++++ .devcontainer/devcontainer.json | 31 +++++++++++++++++++++++++++++++ conda_env.yml => environment.yml | 4 ++-- 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/config create mode 100644 .devcontainer/devcontainer.json rename conda_env.yml => environment.yml (82%) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..9ba5bd9 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,18 @@ +FROM mcr.microsoft.com/devcontainers/miniconda:0-3 + +USER vscode +WORKDIR /home/vscode + +# Configure SnowSQL +RUN mkdir .snowsql +COPY .devcontainer/config .snowsql + +# Install SnowSQL +RUN curl -O https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.2/linux_x86_64/snowsql-1.2.28-linux_x86_64.bash \ + && SNOWSQL_DEST=~/bin SNOWSQL_LOGIN_SHELL=~/.profile bash snowsql-1.2.28-linux_x86_64.bash + +# Create the conda environment +COPY environment.yml . +RUN conda env create \ + && conda init \ + && rm environment.yml \ No newline at end of file diff --git a/.devcontainer/config b/.devcontainer/config new file mode 100644 index 0000000..0248c69 --- /dev/null +++ b/.devcontainer/config @@ -0,0 +1,9 @@ +# SnowSQL config + +[connections.dev] +accountname = myaccount +username = myusername +password = mypassword +rolename = HOL_ROLE +warehousename = HOL_WH +dbname = HOL_DB \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..0b65f30 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,31 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/miniconda +{ + "name": "Snowflake Demo Codespace", + "build": { + "context": "..", + "dockerfile": "Dockerfile" + }, + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [] + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "conda init", + + // Configure tool-specific properties. + "customizations": { + "vscode": { + "settings": { + "python.defaultInterpreterPath": "/opt/conda/envs/snowflake-demo", + "python.terminal.activateEnvInCurrentTerminal": true + }, + "extensions": [ + "snowflake.snowflake-vsc" + ] + } + } + } \ No newline at end of file diff --git a/conda_env.yml b/environment.yml similarity index 82% rename from conda_env.yml rename to environment.yml index 70be27d..62f40db 100644 --- a/conda_env.yml +++ b/environment.yml @@ -1,9 +1,9 @@ -name: pysnowpark +name: snowflake-demo channels: - https://repo.anaconda.com/pkgs/snowflake - nodefaults dependencies: - - python=3.8 + - python=3.10 - snowflake-snowpark-python - pip - pip: From c0944ae5e3ffb233e1aacd0a79e2817280319d6e Mon Sep 17 00:00:00 2001 From: Jeremiah Hansen <53843050+sfc-gh-jhansen@users.noreply.github.com> Date: Fri, 8 Sep 2023 02:56:01 +0000 Subject: [PATCH 2/4] first commit from codespaces --- steps/05_fahrenheit_to_celsius_udf/app.py | 3 ++- steps/05_fahrenheit_to_celsius_udf/requirements.txt | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/steps/05_fahrenheit_to_celsius_udf/app.py b/steps/05_fahrenheit_to_celsius_udf/app.py index e52520c..a42cf9a 100644 --- a/steps/05_fahrenheit_to_celsius_udf/app.py +++ b/steps/05_fahrenheit_to_celsius_udf/app.py @@ -10,9 +10,10 @@ # SNOWFLAKE ADVANTAGE: SnowCLI (PuPr) import sys +from scipy.constants import convert_temperature def main(temp_f: float) -> float: - return (float(temp_f) - 32) * (5/9) + return convert_temperature(float(temp_f), 'F', 'C') # For local debugging diff --git a/steps/05_fahrenheit_to_celsius_udf/requirements.txt b/steps/05_fahrenheit_to_celsius_udf/requirements.txt index e69de29..9a635b9 100644 --- a/steps/05_fahrenheit_to_celsius_udf/requirements.txt +++ b/steps/05_fahrenheit_to_celsius_udf/requirements.txt @@ -0,0 +1 @@ +scipy From 44496556dad2c6fdc4b3eddf880fee1b48caa2d0 Mon Sep 17 00:00:00 2001 From: Jeremiah Hansen Date: Thu, 7 Sep 2023 21:01:10 -0600 Subject: [PATCH 3/4] Update to Dockerfile and Action pipeline --- .devcontainer/Dockerfile | 3 ++- .github/workflows/build_and_deploy.yaml | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9ba5bd9..f5daa2c 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -9,7 +9,8 @@ COPY .devcontainer/config .snowsql # Install SnowSQL RUN curl -O https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/1.2/linux_x86_64/snowsql-1.2.28-linux_x86_64.bash \ - && SNOWSQL_DEST=~/bin SNOWSQL_LOGIN_SHELL=~/.profile bash snowsql-1.2.28-linux_x86_64.bash + && SNOWSQL_DEST=~/bin SNOWSQL_LOGIN_SHELL=~/.profile bash snowsql-1.2.28-linux_x86_64.bash \ + && rm snowsql-1.2.28-linux_x86_64.bash # Create the conda environment COPY environment.yml . diff --git a/.github/workflows/build_and_deploy.yaml b/.github/workflows/build_and_deploy.yaml index d8bdfde..f4d5478 100644 --- a/.github/workflows/build_and_deploy.yaml +++ b/.github/workflows/build_and_deploy.yaml @@ -18,10 +18,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Setup Python 3.8 + - name: Setup Python 3.10 uses: actions/setup-python@v4 with: - python-version: '3.8' + python-version: '3.10' - name: Install Python packages run: pip install -r requirements.txt From 0aee8dede1df0524580f77684fbc686b2f59a607 Mon Sep 17 00:00:00 2001 From: Jeremiah Hansen Date: Thu, 7 Sep 2023 21:22:00 -0600 Subject: [PATCH 4/4] Reset step 5 --- steps/05_fahrenheit_to_celsius_udf/app.py | 3 +-- steps/05_fahrenheit_to_celsius_udf/requirements.txt | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/steps/05_fahrenheit_to_celsius_udf/app.py b/steps/05_fahrenheit_to_celsius_udf/app.py index a42cf9a..e52520c 100644 --- a/steps/05_fahrenheit_to_celsius_udf/app.py +++ b/steps/05_fahrenheit_to_celsius_udf/app.py @@ -10,10 +10,9 @@ # SNOWFLAKE ADVANTAGE: SnowCLI (PuPr) import sys -from scipy.constants import convert_temperature def main(temp_f: float) -> float: - return convert_temperature(float(temp_f), 'F', 'C') + return (float(temp_f) - 32) * (5/9) # For local debugging diff --git a/steps/05_fahrenheit_to_celsius_udf/requirements.txt b/steps/05_fahrenheit_to_celsius_udf/requirements.txt index 9a635b9..e69de29 100644 --- a/steps/05_fahrenheit_to_celsius_udf/requirements.txt +++ b/steps/05_fahrenheit_to_celsius_udf/requirements.txt @@ -1 +0,0 @@ -scipy