Skip to content

Commit

Permalink
Add some very basic CI capabilities
Browse files Browse the repository at this point in the history
Add some very basic CI capabilities
  • Loading branch information
CoryMartin-NOAA authored Nov 6, 2023
2 parents f9c0fed + fe1b6b6 commit f2bab60
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 17 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/norms.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Coding Norms
on: [push]

jobs:
check_pynorms:
runs-on: ubuntu-latest
name: Check python coding norms with pycodestyle

steps:

- name: Install dependencies
run: |
pip install --upgrade pip
pip install pycodestyle
- name: Checkout
uses: actions/checkout@v2
with:
path: obs-monitor

- name: Run pycodestyle
run: |
cd $GITHUB_WORKSPACE/obs-monitor
pycodestyle -v --config ./.pycodestyle ./ush ./ush/plotObsMon
70 changes: 70 additions & 0 deletions .github/workflows/unittests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Unit Tests
on: [push, pull_request]

jobs:
ctests:
runs-on: ubuntu-latest
name: Run Unit Tests with ctest

steps:

# Setup Python
#- name: Set up Python 3.10
# uses: actions/setup-python@v2
# with:
# python-version: 3.10.10

# Update conda
- name: Update conda
run: conda update -n base -c defaults conda

# Install pip
- name: Install pip
run: conda install pip

- name: Checkout wxflow
uses: actions/checkout@v3
with:
repository: NOAA-EMC/wxflow
ref: develop
path: wxflow

- name: Install wxflow
run: |
cd wxflow
$CONDA/bin/pip3 install .
# Install cartopy
- name: Install cartopy
run: conda install -c conda-forge cartopy

# Clone the eva code
- name: Clone eva repo
uses: actions/checkout@v2
with:
repository: JCSDA-internal/eva
ref: develop
path: eva
lfs: true

# Install eva
#- name: Upgrade pip
# run: $CONDA/bin/pip3 install --upgrade pip
- name: Install eva and dependencies
run: $CONDA/bin/pip3 install --use-deprecated=legacy-resolver -r $GITHUB_WORKSPACE/eva/requirements-github.txt --user $GITHUB_WORKSPACE/eva
- name: Put eva in the path
run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Checkout
uses: actions/checkout@v2
with:
path: obs-monitor

# - name: Test running plotObsMon
# run: |
# cd $GITHUB_WORKSPACE/obs-monitor/ush
# $CONDA/bin/python3 plotObsMon -i $GITHUB_WORKSPACE/obs-monitor/parm/gfs/gfs_plots.yaml -p 2023110300

# - name: Display YAML files
# run: |
# ls $GITHUB_WORKSPACE/obs-monitor/ush
6 changes: 6 additions & 0 deletions .pycodestyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[pycodestyle]
count = False
ignore = E226,E401,E402,W504
max-line-length = 160
statistics = True
exclude = Experimental
37 changes: 20 additions & 17 deletions ush/plotObsMon
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ from eva.utilities.logger import Logger
def genYaml(input_yaml, output_yaml, config):
"""
Read in input yaml file and modify with contents of config.
Parameters:
input_yaml (yaml file): path to input yaml file
output_yaml (yaml file): path to output yaml file
Expand All @@ -29,7 +29,8 @@ def genYaml(input_yaml, output_yaml, config):
final_config = parse_j2yaml(input_yaml, config)
save_as_yaml(final_config, output_yaml)

#--------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------


def camelCase(s):
"""
Expand All @@ -44,7 +45,8 @@ def camelCase(s):
s = sub(r"(_|-)+", " ", s).title().replace(" ", "")
return ''.join([s[0].lower(), s[1:]])

#--------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------


def loadConfig(satname, instrument, plot, cycle_tm, cycle_interval, data_location):
"""
Expand All @@ -56,24 +58,24 @@ def loadConfig(satname, instrument, plot, cycle_tm, cycle_interval, data_locatio
plot (str): plot template
cycle_tm (datetime): Cycle time of plot
cycle_interval (int): number of hours between cycles
data_location (str): path to directory containing data files
data_location (str): path to directory containing data files
Return:
config(dict): Dictionary containing configuration information
"""
config = {
'SAT': satname,
'SENSOR': instrument,
'LEVELS': plot.get('levels'),
'CHANNELS': plot.get('channels'),
'RUN': plot.get('run'),
'PDATE': cycle_tm,
'PLOT_TEMPLATE': camelCase(plot.get('plot')),
'DATA': data_location
'SAT': satname,
'SENSOR': instrument,
'LEVELS': plot.get('levels'),
'CHANNELS': plot.get('channels'),
'RUN': plot.get('run'),
'PDATE': cycle_tm,
'PLOT_TEMPLATE': camelCase(plot.get('plot')),
'DATA': data_location
}

times = int(plot.get('times'))
for x in range(1,times+1):
for x in range(1, times+1):
date_str = f"PDATEm{x*6}"
config[date_str] = add_to_datetime(cycle_tm, to_timedelta(f"-{cycle_interval*x}H"))

Expand All @@ -91,17 +93,18 @@ def loadConfig(satname, instrument, plot, cycle_tm, cycle_interval, data_locatio
ctr = interval
xticks = ""
while ctr < int(last_chan):
xticks = xticks + str(ctr) + ','
xticks = xticks + str(ctr) + ','
ctr += interval
config['XTICKS'] = xticks[:-1]

return config
return config

# --------------------------------------------------------------------------------------------

#--------------------------------------------------------------------------------------------

if __name__ == "__main__":
"""
plotObsMon
plotObsMon
Read and parse input yaml file, load configuration and apply to requested yaml template(s),
and plot results.
Expand Down

0 comments on commit f2bab60

Please sign in to comment.