diff --git a/.github/workflows/build_workflow.yml b/.github/workflows/build_workflow.yml index c1b508a44..058d4af9c 100644 --- a/.github/workflows/build_workflow.yml +++ b/.github/workflows/build_workflow.yml @@ -1,82 +1,76 @@ name: CI/CD Build Workflow on: - push: - branches: [master] + push: + branches: [master] - pull_request: - branches: [master] + pull_request: + branches: [master] - workflow_dispatch: + workflow_dispatch: jobs: - check-jobs-to-skip: - runs-on: ubuntu-latest - outputs: - should_skip: ${{ steps.skip_check.outputs.should_skip }} - steps: - - id: skip_check - uses: fkirc/skip-duplicate-actions@master - with: - cancel_others: true - paths_ignore: '["**/README.rst", "**/docs/**", "**/ISSUE_TEMPLATE/**", "**/pull_request_template.md", "**/.vscode/**"]' + check-jobs-to-skip: + runs-on: ubuntu-latest + outputs: + should_skip: ${{ steps.skip_check.outputs.should_skip }} + steps: + - id: skip_check + uses: fkirc/skip-duplicate-actions@master + with: + cancel_others: true + paths_ignore: '["**/README.md", "**/docs/**", "**/ISSUE_TEMPLATE/**", "**/pull_request_template.md", "**/.vscode/**"]' - pre-commit-hooks: - needs: check-jobs-to-skip - if: ${{ needs.check-jobs-to-skip.outputs.should_skip != 'true'}} || ${{ github.event_name == 'push' }} - runs-on: ubuntu-latest - timeout-minutes: 2 - steps: - - name: Checkout Code Repository - uses: actions/checkout@v2 + pre-commit-hooks: + needs: check-jobs-to-skip + if: ${{ needs.check-jobs-to-skip.outputs.should_skip != 'true'}} || ${{ github.event_name == 'push' }} + runs-on: ubuntu-latest + timeout-minutes: 2 + steps: + - name: Checkout Code Repository + uses: actions/checkout@v2 - - name: Set up Python 3.9 - uses: actions/setup-python@v2 - with: - python-version: 3.9 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 - # Run all pre-commit hooks on all the files. - # Getting only staged files can be tricky in case a new PR is opened - # since the action is run on a branch in detached head state - - name: Install and Run Pre-commit - uses: pre-commit/action@v2.0.3 + # Run all pre-commit hooks on all the files. + # Getting only staged files can be tricky in case a new PR is opened + # since the action is run on a branch in detached head state + - name: Install and Run Pre-commit + uses: pre-commit/action@v2.0.3 - build: - needs: check-jobs-to-skip - if: ${{ needs.check-jobs-to-skip.outputs.should_skip != 'true'}} || ${{ github.event_name == 'push' }} - runs-on: ubuntu-latest - defaults: - run: - shell: bash -l {0} - timeout-minutes: 5 - steps: - - uses: actions/checkout@v2 + build: + needs: check-jobs-to-skip + if: ${{ needs.check-jobs-to-skip.outputs.should_skip != 'true'}} || ${{ github.event_name == 'push' }} + runs-on: ubuntu-latest + defaults: + run: + shell: bash -l {0} + timeout-minutes: 5 + steps: + - uses: actions/checkout@v2 - - name: Cache Conda - uses: actions/cache@v2 - env: - # Increase this value to reset cache if conda/dev.yml has not changed in the workflow - CACHE_NUMBER: 0 - with: - path: ~/conda_pkgs_dir - key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-publish + - name: Cache Conda + uses: actions/cache@v2 + env: + # Increase this value to reset cache if conda/dev.yml has not changed in the workflow + CACHE_NUMBER: 0 + with: + path: ~/conda_pkgs_dir + key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-publish - - name: Set up Conda Environment - uses: conda-incubator/setup-miniconda@v2 - with: - activate-environment: "xcdat_dev" - environment-file: conda-env/dev.yml - channel-priority: strict - auto-update-conda: true - # IMPORTANT: This needs to be set for caching to work properly! - use-only-tar-bz2: true + - name: Set up Conda Environment + uses: conda-incubator/setup-miniconda@v2 + with: + activate-environment: "pcmdi_metrics_dev" + environment-file: conda-env/dev.yml + channel-priority: strict + auto-update-conda: true + # IMPORTANT: This needs to be set for caching to work properly! + use-only-tar-bz2: true - - name: Run Tests - run: | - pytest - - - name: Upload Coverage Report - uses: codecov/codecov-action@v1 - with: - file: "tests_coverage_reports/coverage.xml" - fail_ci_if_error: true + - name: Run Tests + run: | + pytest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 86ea215bb..bef93d0da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,34 +3,28 @@ default_stages: [commit] fail_fast: true repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml - - repo: https://github.com/psf/black - rev: 21.9b0 - hooks: - - id: black + - repo: https://github.com/psf/black + rev: 21.9b0 + hooks: + - id: black - - repo: https://github.com/timothycrosley/isort - rev: 5.9.3 - hooks: - - id: isort + - repo: https://github.com/timothycrosley/isort + rev: 5.9.3 + hooks: + - id: isort - # Need to use flake8 GitHub mirror due to CentOS git issue with GitLab - # https://github.com/pre-commit/pre-commit/issues/1206 - - repo: https://github.com/pycqa/flake8 - rev: 3.9.2 - hooks: - - id: flake8 - args: ["--config=setup.cfg"] - additional_dependencies: [flake8-isort] - - - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.910 - hooks: - - id: mypy - args: ["--config=setup.cfg"] + # Need to use flake8 GitHub mirror due to CentOS git issue with GitLab + # https://github.com/pre-commit/pre-commit/issues/1206 + - repo: https://github.com/pycqa/flake8 + rev: 3.9.2 + hooks: + - id: flake8 + args: ["--config=setup.cfg"] + additional_dependencies: [flake8-isort] diff --git a/conda-env/dev.yml b/conda-env/dev.yml index 4b980d115..beafad772 100644 --- a/conda-env/dev.yml +++ b/conda-env/dev.yml @@ -19,6 +19,7 @@ dependencies: - eofs=1.4.0 # Testing # ================== + - pre_commit=2.15.0 - pytest=6.2.5 - pytest-cov=3.0.0 # Developer Tools diff --git a/pcmdi_metrics/devel/monsoon_wang/scripts/bar_chart_monsoon_precip_index.py b/pcmdi_metrics/devel/monsoon_wang/scripts/bar_chart_monsoon_precip_index.py index 804b6c705..957be058b 100644 --- a/pcmdi_metrics/devel/monsoon_wang/scripts/bar_chart_monsoon_precip_index.py +++ b/pcmdi_metrics/devel/monsoon_wang/scripts/bar_chart_monsoon_precip_index.py @@ -182,6 +182,12 @@ aux_mods = "" custom_names = {} aux_jsons = [] + + # FIXME: Should these be set? + mod_name = None + numexpts = None + ############################### + if aux_json_path: print("==> Loading auxillary json file : " + aux_json_path) print("...") diff --git a/pcmdi_metrics/pcmdi/scripts/pcmdi_compute_climatologies-CMOR.py b/pcmdi_metrics/pcmdi/scripts/pcmdi_compute_climatologies-CMOR.py index 5d64c6df3..954c6203c 100644 --- a/pcmdi_metrics/pcmdi/scripts/pcmdi_compute_climatologies-CMOR.py +++ b/pcmdi_metrics/pcmdi/scripts/pcmdi_compute_climatologies-CMOR.py @@ -218,6 +218,13 @@ def dump_cmor(A, data, time, bounds, season): inst = checkCMORAttribute("institution") src = checkCMORAttribute("source") exp = checkCMORAttribute("experiment_id") + + # FIXME: Should these be set? + realization_index = None + initialization_index = None + physics_index = None + ############################### + xtra = {} for x in cmor_xtra_args: try: @@ -317,9 +324,16 @@ def dump_cmor(A, data, time, bounds, season): "license": "CMIP6 model data produced by Lawrence Livermore PCMDI is licensed under a Creative Commons Attribution ShareAlike 4.0 International License (https://creativecommons.org/licenses). Consult https://pcmdi.llnl.gov/CMIP6/TermsOfUse for terms of use governing CMIP6 output, including citation requirements and proper acknowledgment. Further information about this data, including some limitations, can be found via the further_info_url (recorded as a global attribute in this file) and at https:///pcmdi.llnl.gov/. The data producers and data providers make no warranty, either express or implied, including, but not limited to, warranties of merchantability and fitness for a particular purpose. All liabilities arising from the supply of the information (including any liability arising in negligence) are excluded to the fullest extent permitted by law." }} """.format( - A.results_dir, exp, cal_name, r, i, p, inst.split()[0], src + A.results_dir, + exp, + cal_name, + realization_index, + initialization_index, + physics_index, + inst.split()[0], + src, ) - ) # noqa + ) tmp.flush() cmor.dataset_json(tmp.name) diff --git a/setup.cfg b/setup.cfg index a65e33c26..683d5b22e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -52,14 +52,6 @@ exclude = *__init__.py venv -[mypy] -python_version = 3.8 -check_untyped_defs = True -ignore_missing_imports = True -warn_unused_ignores = True -warn_redundant_casts = True -warn_unused_configs = True - [aliases] # Define setup.py command aliases here test = pytest diff --git a/tests/test_placeholder.py b/tests/test_placeholder.py new file mode 100644 index 000000000..583ea51ea --- /dev/null +++ b/tests/test_placeholder.py @@ -0,0 +1,8 @@ +""" +Placeholder to to suppress `Error: Process completed with exit code 5`, +which occurs when no tests run. Remove this file when real tests are added. +""" + + +def test_placeholder(): + pass