From 335452421ed306646b0ee0054c8054a3d10cc37a Mon Sep 17 00:00:00 2001 From: Jason Freeberg Date: Mon, 10 Apr 2023 16:29:42 -0700 Subject: [PATCH 1/5] Add conda env, instructions Update workflow files as well --- .github/workflows/build-and-deploy.yml | 21 ++++++++++++--------- .github/workflows/pr-checks.yml | 15 ++++++--------- README.md | 11 +++++++---- environment.yml | 13 +++++++++++++ 4 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 environment.yml diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 6af2df3..23c4ef8 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -23,17 +23,20 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v4 + - name: Setup Conda + uses: conda-incubator/setup-miniconda@v3 with: - python-version: '3.8' - cache: 'pip' + activate-environment: conda-default + environment-file: environment.yml - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -r requirements-test.txt + # - name: Install dependencies + # run: | + # python -m pip install --upgrade pip + # pip install -r requirements.txt + # pip install -r requirements-test.txt + + - name: Install test dependencies + run: pup install -r requirements-test.txt - name: Run tests run: python -m pytest diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index cd47c2e..8339830 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -22,17 +22,14 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v4 + - name: Setup Conda + uses: conda-incubator/setup-miniconda@v3 with: - python-version: '3.8' - cache: 'pip' + activate-environment: conda-default + environment-file: environment.yml - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -r requirements-test.txt + - name: Install test dependencies + run: pip install -r requirements-test.txt - name: Run tests run: python -m pytest diff --git a/README.md b/README.md index 06407b9..dabc160 100644 --- a/README.md +++ b/README.md @@ -31,16 +31,19 @@ using the System Properties menu (on Windows). ### Install dependencies -Set up a virtual environment using [Anaconda](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands) or [virtualenv](https://docs.python.org/3/library/venv.html). For example, the following command will create and activate a virtual environment named `venv`: +Set up a virtual environment using [Anaconda](https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands) or [virtualenv](https://docs.python.org/3/library/venv.html). + +#### Anaconda ```bash -python3 -m venv venv -source venv/bin/activate +conda env create -f environment.yml ``` -Next, import the packages in [requirements.txt](requirements.txt): +#### Virtualenv ```bash +python3 -m venv venv +source venv/bin/activate pip install -r requirements.txt ``` diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..0b9c30e --- /dev/null +++ b/environment.yml @@ -0,0 +1,13 @@ +# Snowpark environment file +# https://docs.snowflake.com/en/developer-guide/snowpark/python/setup.html + +name: snowpark_default +channels: + - snowflake +dependencies: + - python=3.8 + - snowflake-snowpark-python + - toml + - tomli + - pip: + - "git+https://github.com/Snowflake-Labs/snowflake-vcrpy.git@v0.1.1" From 8fa69f83d1319691919b40f03ab86657c5220202 Mon Sep 17 00:00:00 2001 From: Jason Freeberg Date: Mon, 10 Apr 2023 17:02:20 -0700 Subject: [PATCH 2/5] Typo fixes --- .github/workflows/build-and-deploy.yml | 4 ++-- .github/workflows/pr-checks.yml | 4 ++-- README.md | 1 + environment.yml | 5 +++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 23c4ef8..fcd4309 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -24,9 +24,9 @@ jobs: - uses: actions/checkout@v3 - name: Setup Conda - uses: conda-incubator/setup-miniconda@v3 + uses: conda-incubator/setup-miniconda@v2.2.0 with: - activate-environment: conda-default + activate-environment: snowpark environment-file: environment.yml # - name: Install dependencies diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 8339830..466bc73 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -23,9 +23,9 @@ jobs: - uses: actions/checkout@v3 - name: Setup Conda - uses: conda-incubator/setup-miniconda@v3 + uses: conda-incubator/setup-miniconda@v2.2.0 with: - activate-environment: conda-default + activate-environment: snowpark environment-file: environment.yml - name: Install test dependencies diff --git a/README.md b/README.md index dabc160..3cd7a3e 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ Set up a virtual environment using [Anaconda](https://conda.io/projects/conda/en ```bash conda env create -f environment.yml +conda activate snowpark ``` #### Virtualenv diff --git a/environment.yml b/environment.yml index 0b9c30e..e376b9d 100644 --- a/environment.yml +++ b/environment.yml @@ -1,13 +1,14 @@ # Snowpark environment file # https://docs.snowflake.com/en/developer-guide/snowpark/python/setup.html -name: snowpark_default +name: snowpark channels: - snowflake dependencies: - python=3.8 + - pip - snowflake-snowpark-python - toml - tomli - pip: - - "git+https://github.com/Snowflake-Labs/snowflake-vcrpy.git@v0.1.1" + - "-r requirements-test.txt" From 69bff08d1cde35d227ecd3cc41b334e7086840aa Mon Sep 17 00:00:00 2001 From: Jason Freeberg Date: Mon, 10 Apr 2023 17:16:55 -0700 Subject: [PATCH 3/5] Update pr-checks.yml --- .github/workflows/pr-checks.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 466bc73..bface00 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -19,6 +19,9 @@ env: jobs: test: runs-on: ubuntu-latest + defaults: + run: + shell: bash -el {0} steps: - uses: actions/checkout@v3 From d13dd822d4921e938daa02bac3f7fe2d56cecf6b Mon Sep 17 00:00:00 2001 From: Jason Freeberg Date: Mon, 10 Apr 2023 17:21:14 -0700 Subject: [PATCH 4/5] Update pr-checks.yml --- .github/workflows/pr-checks.yml | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index bface00..1f1927f 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -16,12 +16,13 @@ env: SNOWSQL_SCHEMA: ${{ secrets.SNOWSQL_SCHEMA }} SNOWSQL_WAREHOUSE: ${{ secrets.SNOWSQL_WAREHOUSE }} +defaults: + run: + shell: bash -el {0} + jobs: test: runs-on: ubuntu-latest - defaults: - run: - shell: bash -el {0} steps: - uses: actions/checkout@v3 @@ -42,18 +43,14 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v4 + - name: Setup Conda + uses: conda-incubator/setup-miniconda@v2.2.0 with: - python-version: '3.8' - cache: 'pip' + activate-environment: snowpark + environment-file: environment.yml - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - pip install pylint + run: pip install pylint - name: Analysing the code with pylint - run: | - pylint $(git ls-files '*.py') + run: pylint $(git ls-files '*.py') From 236f806eaa611f818674a56768e4780ee28ad447 Mon Sep 17 00:00:00 2001 From: Jason Freeberg Date: Mon, 10 Apr 2023 17:25:27 -0700 Subject: [PATCH 5/5] Remove redundant pip install --- .github/workflows/build-and-deploy.yml | 14 ++++---------- .github/workflows/pr-checks.yml | 3 --- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index fcd4309..7dfb5da 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -20,6 +20,9 @@ env: jobs: build: runs-on: ubuntu-latest + defaults: + run: + shell: bash -el {0} steps: - uses: actions/checkout@v3 @@ -29,20 +32,11 @@ jobs: activate-environment: snowpark environment-file: environment.yml - # - name: Install dependencies - # run: | - # python -m pip install --upgrade pip - # pip install -r requirements.txt - # pip install -r requirements-test.txt - - - name: Install test dependencies - run: pup install -r requirements-test.txt - - name: Run tests run: python -m pytest - name: Create deployment artifact - run: zip -r ${{ env.ARTIFACT_NAME }} . -x .git/\* + run: zip -r ${{ env.ARTIFACT_NAME }} . -x .git/\* - name: Upload artifact for deployment job uses: actions/upload-artifact@v2 diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 1f1927f..68f427d 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -32,9 +32,6 @@ jobs: activate-environment: snowpark environment-file: environment.yml - - name: Install test dependencies - run: pip install -r requirements-test.txt - - name: Run tests run: python -m pytest