Skip to content

Commit

Permalink
Merge pull request #237 from doizuc/dev
Browse files Browse the repository at this point in the history
Add Application Testing Workflow

Great. Thanks, Nils.
  • Loading branch information
oceancolorcoder authored Sep 16, 2024
2 parents 8c70cc0 + 255ec0c commit 1269972
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 46 deletions.
38 changes: 38 additions & 0 deletions .github/actions/SetupEnvironment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: SetupEnvironment
description: 'Setup python environment with conda'

runs:
using: "composite"

steps:
- name: 🐍 Setup Mambaforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
# miniforge-variant: Mambaforge
# use-mamba: true # mambaforge is now deprecated in favor of miniforge
activate-environment: hypercp

- name: 🔂 Cache Environment
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('environment.yml') }}-${{ env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
id: cache

- name: 🔄 Update Environment
if: steps.cache.outputs.cache-hit != 'true'
shell: bash -el {0}
run: |
mamba env update -n hypercp -f environment.yml
mamba install --channel=conda-forge pyinstaller==6.6
- name: 📸 Capture Environment
shell: bash -el {0}
run: |
mamba info
mamba list
40 changes: 40 additions & 0 deletions .github/workflows/ApplicationTesting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: ApplicationTesting

on:
push:
branches:
- master
- dev
workflow_dispatch:

jobs:

ApplicationTesting:
name: Application Tests

runs-on: ${{ matrix.os }}
defaults: # Required for conda environment activation
run:
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]

steps:
- name: ⏬ Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}

- name: 🔧 Setup Environment
uses: ./.github/actions/SetupEnvironment

- name: 📑 Capture Environment
run: |
mamba info
mamba list
- name: 🧪 Run Tests
run: |
python run_Sample_Data.py
45 changes: 7 additions & 38 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,59 +24,28 @@ jobs:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']

steps:
- name: Get Branch Name
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Checkout Repository
- name: ⏬ Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ steps.extract_branch.outputs.branch }}

- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: hypercp
use-mamba: true

- name: Cache Environment
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs
key:
conda-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('environment.yml') }}-${{ env.CACHE_NUMBER }}
env:
# Increase this value to reset cache if environment.yml has not changed
CACHE_NUMBER: 0
id: cache

- name: Update Environment
if: steps.cache.outputs.cache-hit != 'true'
run: |
mamba env update -n hypercp -f environment.yml
mamba install --channel=conda-forge pyinstaller==6.6
ref: ${{ github.event.inputs.branch }}

- name: Capture Environment
run: |
mamba info
mamba list
- name: 🔧 Setup Environment
uses: ./.github/actions/SetupEnvironment

- name: Make Bundle
- name: 📑 Make Bundle
run: |
python make.py
echo "BUNDLE_NAME=$(ls Bundled/dist | head -1 | xargs)" >> $GITHUB_ENV
- name: Zip Bundle
- name: 📥 Zip Bundle
uses: thedoctor0/[email protected]
with:
type: 'zip'
directory: 'Bundled/dist/'
path: '${{ env.BUNDLE_NAME }}'
filename: '${{ env.BUNDLE_NAME }}.zip'

- name: Upload Bundle
- name: ⏫️ Upload Bundle
uses: actions/upload-artifact@v4
with:
name: ${{ env.BUNDLE_NAME }}
Expand Down
2 changes: 1 addition & 1 deletion Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def __init__(
# Confirm that core data files are in place. Download if necessary.
fpfZhang = os.path.join(CODE_HOME, "Data", "Zhang_rho_db.mat")
if not os.path.exists(fpfZhang):
Utilities.downloadZhangDB(fpfZhang)
Utilities.downloadZhangDB(fpfZhang, force=True)

# Create a default main config to be filled with cmd argument
# to avoid reading the one generated with the GUI
Expand Down
10 changes: 7 additions & 3 deletions Source/Utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ class Utilities:
"""A catchall class for HyperCP utilities"""

@staticmethod
def downloadZhangDB(fpfZhang):
def downloadZhangDB(fpfZhang, force=False):
infoText = " NEW INSTALLATION\nGlint database required.\nClick OK to download.\n\nWARNING: THIS IS A 2.5 GB DOWNLOAD.\n\n\
If canceled, Zhang et al. (2017) glint correction will fail. If download fails, a link and instructions will be provided in the terminal."
YNReply = Utilities.YNWindow("Database Download", infoText)
if YNReply == QMessageBox.Ok:
YNReply = True if force else Utilities.YNWindow("Database Download", infoText) == QMessageBox.Ok
if YNReply:

url = "https://oceancolor.gsfc.nasa.gov/fileshare/dirk_aurin/Zhang_rho_db.mat"
download_session = requests.Session()
Expand Down Expand Up @@ -283,6 +283,10 @@ def YNWindow(winText,infoText):

@staticmethod
def writeLogFile(logText, mode='a'):
if not os.path.exists('Logs'):
import logging
logging.getLogger().warning('Made directory: Logs/')
os.mkdir('Logs')
with open('Logs/' + os.environ["LOGFILE"], mode, encoding="utf-8") as logFile:
logFile.write(logText + "\n")

Expand Down
7 changes: 3 additions & 4 deletions run_Sample_Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

################################################### CUSTOM SET UP ###################################################
# Batch options
MULTI_TASK = True # Multiple threads for HyperSAS (any level) or TriOS (only L1A and up)
MULTI_LEVEL = False # Process raw (L0) to Level-2 (L2)
MULTI_TASK = False # Multiple threads for HyperSAS (any level) or TriOS (only L1A and up)
MULTI_LEVEL = True # Process raw (L0) to Level-2 (L2)
CLOBBER = True # True overwrites existing files
PROC_LEVEL = "L2" # Process to this level: L1A, L1AQC, L1B, LBQC, L2 (ignored for MULTI_LEVEL)

Expand All @@ -51,8 +51,7 @@

#################################
## PATH options
PATH_OS = os.path.expanduser("~")
PATH_HCP = os.path.join(PATH_OS,'GitRepos','HyperCP') # Local path to HyperCP repository.
PATH_HCP = os.path.dirname(os.path.abspath(__file__)) # Path to HyperCP repository on host
# PATH_DATA = f"{PATH_OS}/Projects/HyperPACE/field_data/HyperSAS/{CRUISE}" # Top level data directory containing RAW/ and ancillary file.
PATH_DATA = os.path.join(PATH_HCP,'Data','Sample_Data',PLATFORM)
##################################
Expand Down

0 comments on commit 1269972

Please sign in to comment.