diff --git a/.github/workflows/mopper-conda.yaml b/.github/workflows/mopper-conda.yaml index c232518..d08666f 100644 --- a/.github/workflows/mopper-conda.yaml +++ b/.github/workflows/mopper-conda.yaml @@ -14,6 +14,7 @@ on: jobs: build-linux: runs-on: ubuntu-latest + timeout-minutes: 60 strategy: max-parallel: 5 @@ -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 diff --git a/conda/meta.yaml b/conda/meta.yaml index f20a79a..05d58fc 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,7 +1,6 @@ -{% set version = "1.0.0" %} package: name: mopper - version: {{ version }} + version: 1.0.0 #source: # path: ./ @@ -9,7 +8,7 @@ package: 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: diff --git a/docs/gettingstarted.rst b/docs/gettingstarted.rst index 666e89a..2e7181e 100644 --- a/docs/gettingstarted.rst +++ b/docs/gettingstarted.rst @@ -56,7 +56,7 @@ Step2: Set up the working environment *mop -c 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 diff --git a/env.yaml b/env.yaml new file mode 100644 index 0000000..6e46467 --- /dev/null +++ b/env.yaml @@ -0,0 +1,10 @@ +name: mopenv +channels: + - conda-forge +dependencies: + - click + - cmor + - xarray + - numpy + - pyyaml + - dask diff --git a/src/mopdb/mopdb_utils.py b/src/mopdb/mopdb_utils.py index b9875c7..32ceb81 100644 --- a/src/mopdb/mopdb_utils.py +++ b/src/mopdb/mopdb_utils.py @@ -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 diff --git a/src/mopper/calculations.py b/src/mopper/calculations.py index 1adf216..d217aef 100644 --- a/src/mopper/calculations.py +++ b/src/mopper/calculations.py @@ -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 @@ -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) @@ -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' @@ -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 diff --git a/src/mopper/mop_utils.py b/src/mopper/mop_utils.py index cdb78db..6017b68 100755 --- a/src/mopper/mop_utils.py +++ b/src/mopper/mop_utils.py @@ -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): diff --git a/src/mopper/setup_utils.py b/src/mopper/setup_utils.py index e0341fa..ef2c1ec 100755 --- a/src/mopper/setup_utils.py +++ b/src/mopper/setup_utils.py @@ -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): @@ -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) @@ -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'],