Skip to content
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

Merging prerelease into pytests_sam #157

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .github/workflows/mopper-conda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
jobs:
build-linux:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
max-parallel: 5

Expand All @@ -22,27 +23,28 @@ jobs:
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.10
python-version: '3.10'
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda env update --file conda/environment.yml --name base
conda env update --file env.yaml --name base
- name: Lint with flake8
run: |
conda install flake8
conda install flake8 --solver classic
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# - name: Install package
run: |
conda build conda/meta.yaml
- name: install package
run: |
source activate base
pip install ./
- name: Test with pytest
run: |
conda install pytest coverage codecov
conda install pytest coverage codecov --solver classic
conda run python -m pytest
conda run coverage run --source src -m py.test
- name: Upload to codecov
Expand Down
5 changes: 2 additions & 3 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{% set version = "1.0.0" %}
package:
name: mopper
version: {{ version }}
version: 1.0.0

#source:
# path: ./

source:
#url: https://github.com/ACCESS-Hive/ACCESS-MOPPeR/archive/refs/tags/{{version}}.tar.gz
git_url: https://github.com/ACCESS-Hive/ACCESS-MOPPeR.git
git_rev: {{ version }}
git_rev: "{{ version }}"
git_depth: 1 # (Defaults to -1/not shallow)

build:
Expand Down
2 changes: 1 addition & 1 deletion docs/gettingstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Step2: Set up the working environment
*mop -c <conf_exp.yaml> setup*

.. code-block:: console
https://climate-cms.org/posts/2023-05-31-vscode-are.html

$ mop -c exp_conf.yaml setup
Simulation to process: cy286
Setting environment and creating working directory
Expand Down
10 changes: 10 additions & 0 deletions env.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: mopenv
channels:
- conda-forge
dependencies:
- click
- cmor
- xarray
- numpy
- pyyaml
- dask
2 changes: 1 addition & 1 deletion src/mopdb/mopdb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def read_map(fname, alias):
notes = row[16]
else:
notes = row[15]
if alias is '':
if alias == '':
alias = fname.replace(".csv","")
var_list.append(row[:11] + [notes, alias])
return var_list
Expand Down
7 changes: 4 additions & 3 deletions src/mopper/calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import dask
import logging

from importlib_resources import files as import_files
from importlib.resources import files as import_files
from mopper.setup_utils import read_yaml

# Global Variables
Expand Down Expand Up @@ -950,7 +950,7 @@ def tos_3hr(var, landfrac):
vout : Xarray dataset
"""

v = tos_degC(var)
v = K_degC(var)

vout = xr.zeros_like(var)
t = len(var.time)
Expand Down Expand Up @@ -1346,6 +1346,7 @@ def get_basin_mask(ctx, lat, lon):
basin_mask: DataArray
basin_mask(lat,lon)
"""
var_log = logging.getLogger(ctx.obj['var_log'])
coords = ['t', 't']
if 'xu' in lon:
coords[0] = 'u'
Expand Down Expand Up @@ -1443,6 +1444,6 @@ def calc_depositions(ctx, var, weight=None):
varlist.append(v0)
if weight is None:
weight = 0.05844
deps = sum_vars(varlist) * mole_weight
deps = sum_vars(varlist) * weight
return deps

2 changes: 1 addition & 1 deletion src/mopper/mop_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

from mopper.calculations import *
from mopper.setup_utils import read_yaml
from importlib_resources import files as import_files
from importlib.resources import files as import_files


def config_log(debug, path, stream_level=logging.WARNING):
Expand Down
10 changes: 5 additions & 5 deletions src/mopper/setup_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@
from collections import OrderedDict
from datetime import datetime#, timedelta
from dateutil.relativedelta import relativedelta
from importlib_resources import files as import_files
from importlib.resources import files as import_files
from json.decoder import JSONDecodeError

from mopdb.mopdb_utils import query
from mopper.cmip_utils import fix_years


def write_var_map(outpath, table, matches):
Expand Down Expand Up @@ -166,7 +167,7 @@ def find_custom_tables(ctx):
mop_log = logging.getLogger('mop_log')
tables = []
path = ctx.obj['tables_path']
tables = ctx.obj['tables_path'].rglob("*_*.json")
table_files = ctx.obj['tables_path'].rglob("*_*.json")
for f in table_files:
f = str(f).replace(".json", "")
tables.append(f)
Expand Down Expand Up @@ -626,9 +627,8 @@ def define_files(ctx, cursor, opts, mp):
if mp['years'] != 'all' and ctx.obj['dreq_years']:
exp_start, exp_end = fix_years(mp['years'], exp_start[:4], exp_end[:4])
if exp_start is None:
mop_log.info("Years requested for variable are outside specified")
mop_log.info((f"period: {table_id}, {var},",
f"{match['tstart']}, {match['tend']}"))
mop_log.info(f"""Years requested for variable are outside
specified period: {mp['years']}""")
return
tstep_dict = {'10min': ['minutes=10', 'minutes=5'],
'30min': ['minutes=30', 'minutes=15'],
Expand Down
Loading