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

Add conda dev env and pytest settings in setup.cfg #784

Merged
merged 5 commits into from
Nov 2, 2021

Conversation

tomvothecoder
Copy link
Collaborator

@tomvothecoder tomvothecoder commented Nov 2, 2021

Related to #774 and #776 (task 4 Add local conda development environment and task 5 Add unit testing infrastructure).

  1. Adds the conda development env for use in local development and in the GH Actions CI/CD workflow(s).

  2. Adds pytest and pytest-cov (code coverage report tool).

    • Usage command: pytest
    • Afterwards, pytest-cov coverage reports are outputted to the console. The reports can also be found under tests_coverage_reports/htmlcov/index.html or tests_coverage_reports/coverage.xml (this one is used for uploading to the Codecov service if desired).
    • Settings are configured in setup.cfg.
    • Example output:
      (pcmdi_metrics_test) vo13@ml-9704174 pcmdi_metrics % pytest
      ==================================================== test session starts =====================================================
      platform darwin -- Python 3.9.7, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
      rootdir: /Users/vo13/Documents/Repositories/tomvothecoder/pcmdi_metrics, configfile: setup.cfg
      plugins: anyio-3.3.4, cov-3.0.0
      collected 0 items                                                                                                            
      /opt/miniconda3/envs/pcmdi_metrics_test/lib/python3.9/site-packages/coverage/control.py:761: CoverageWarning: No data was collected. (no-data-collected)
        self._warn("No data was collected.", slug="no-data-collected")
      
      
      ---------- coverage: platform darwin, python 3.9.7-final-0 -----------
      Name                                                                              Stmts   Miss  Cover
      -----------------------------------------------------------------------------------------------------
      pcmdi_metrics/__init__.py                                                            12     12     0%
      pcmdi_metrics/diurnal/__init__.py                                                     2      2     0%
      pcmdi_metrics/diurnal/common.py                                                      32     32     0%
      pcmdi_metrics/diurnal/fourierFFT.py                                                  39     39     0%
      pcmdi_metrics/diurnal/scripts/__init__.py                                             0      0   100%
      pcmdi_metrics/diurnal/scripts/compositeDiurnalStatistics.py                         132    132     0%
      pcmdi_metrics/diurnal/scripts/computeStdOfDailyMeans.py                              87     87     0%
      pcmdi_metrics/diurnal/scripts/fourierDiurnalAllGrid.py                               81     81     0%
      pcmdi_metrics/diurnal/scripts/fourierDiurnalGridpoints.py                           111    111     0%
      pcmdi_metrics/diurnal/scripts/savg_fourier.py                                       166    166     0%
      pcmdi_metrics/diurnal/scripts/std_of_dailymeans.py                                  111    111     0%
      pcmdi_metrics/diurnal/scripts/std_of_hourlyvalues.py                                117    117     0%
      pcmdi_metrics/diurnal/scripts/std_of_meandiurnalcycle.py                            120    120     0%
      pcmdi_metrics/driver/__init__.py                                                      0      0   100%
      pcmdi_metrics/driver/dataset.py                                                     105    105     0%
      pcmdi_metrics/driver/model.py                                                        76     76     0%
      pcmdi_metrics/driver/observation.py                                                 102    102     0%
      pcmdi_metrics/driver/outputmetrics.py                                               191    191     0%
      pcmdi_metrics/driver/pmp_parameter.py                                               160    160     0%
      pcmdi_metrics/driver/pmp_parser.py                                                   22     22     0%
      pcmdi_metrics/enso/__init__.py                                                        0      0   100%
      pcmdi_metrics/enso/enso_driver.py                                                   271    271     0%
      pcmdi_metrics/enso/lib/__init__.py                                                    1      1     0%
      pcmdi_metrics/enso/lib/enso_lib.py                                                  109    109     0%
      pcmdi_metrics/graphics/__init__.py                                                    6      6     0%
      pcmdi_metrics/graphics/bar_chart/__init__.py                                          1      1     0%
      pcmdi_metrics/graphics/bar_chart/bar_chart.py                                        69     69     0%
      pcmdi_metrics/graphics/bar_chart/lib/__init__.py                                      1      1     0%
      pcmdi_metrics/graphics/bar_chart/lib/barChart.py                                     33     33     0%
      pcmdi_metrics/graphics/parallel_coordinate_plot/__init__.py                           0      0   100%
      pcmdi_metrics/graphics/parallel_coordinate_plot/parallel_coordinate_plot_lib.py      84     84     0%
      pcmdi_metrics/graphics/portrait_plot/__init__.py                                      0      0   100%
      pcmdi_metrics/graphics/portrait_plot/portrait_plot_lib.py                           223    223     0%
      pcmdi_metrics/graphics/portraits.py                                                 963    963     0%
      pcmdi_metrics/graphics/share/__init__.py                                              0      0   100%
      pcmdi_metrics/graphics/share/add_logo.py                                             15     15     0%
      pcmdi_metrics/graphics/share/read_json_mean_clim.py                                  96     96     0%
      pcmdi_metrics/io/__init__.py                                                          2      2     0%
      pcmdi_metrics/io/base.py                                                            592    592     0%
      pcmdi_metrics/misc/__init__.py                                                        0      0   100%
      pcmdi_metrics/misc/scripts/__init__.py                                                1      1     0%
      pcmdi_metrics/misc/scripts/get_pmp_data.py                                           35     35     0%
      pcmdi_metrics/misc/scripts/parallel_submitter.py                                     46     46     0%
      pcmdi_metrics/misc/scripts/parallelize_driver.py                                     80     80     0%
      pcmdi_metrics/mjo/__init__.py                                                         0      0   100%
      pcmdi_metrics/mjo/lib/__init__.py                                                     6      6     0%
      pcmdi_metrics/mjo/lib/argparse_functions.py                                          40     40     0%
      pcmdi_metrics/mjo/lib/debug_chk_plot.py                                              23     23     0%
      pcmdi_metrics/mjo/lib/dict_merge.py                                                   8      8     0%
      pcmdi_metrics/mjo/lib/lib_mjo.py                                                    134    134     0%
      pcmdi_metrics/mjo/lib/mjo_metric_calc.py                                             95     95     0%
      pcmdi_metrics/mjo/lib/plot_wavenumber_frequency_power.py                             52     52     0%
      pcmdi_metrics/mjo/lib/post_process_plot.py                                           41     41     0%
      pcmdi_metrics/mjo/lib/post_process_plot_ensemble_mean.py                             46     46     0%
      pcmdi_metrics/monsoon_sperber/__init__.py                                             0      0   100%
      pcmdi_metrics/monsoon_sperber/lib/__init__.py                                         4      4     0%
      pcmdi_metrics/monsoon_sperber/lib/argparse_functions.py                              32     32     0%
      pcmdi_metrics/monsoon_sperber/lib/calc_metrics.py                                    12     12     0%
      pcmdi_metrics/monsoon_sperber/lib/divide_chunks.py                                   57     57     0%
      pcmdi_metrics/monsoon_sperber/lib/model_land_only.py                                 45     45     0%
      pcmdi_metrics/monsoon_wang/__init__.py                                                2      2     0%
      pcmdi_metrics/monsoon_wang/monsoon_precip_index_fncs.py                              50     50     0%
      pcmdi_metrics/monsoon_wang/monsoon_wang_driver.py                                   137    137     0%
      pcmdi_metrics/pcmdi/__init__.py                                                      18     18     0%
      pcmdi_metrics/pcmdi/annual_mean.py                                                    7      7     0%
      pcmdi_metrics/pcmdi/bias_xy.py                                                        7      7     0%
      pcmdi_metrics/pcmdi/bias_xyt.py                                                       7      7     0%
      pcmdi_metrics/pcmdi/cor_xy.py                                                         5      5     0%
      pcmdi_metrics/pcmdi/cor_xyt.py                                                        5      5     0%
      pcmdi_metrics/pcmdi/io.py                                                            67     67     0%
      pcmdi_metrics/pcmdi/mean_climate_metrics_calculations.py                            131    131     0%
      pcmdi_metrics/pcmdi/mean_climate_metrics_driver.py                                  178    178     0%
      pcmdi_metrics/pcmdi/mean_xy.py                                                        6      6     0%
      pcmdi_metrics/pcmdi/meanabs_xy.py                                                     8      8     0%
      pcmdi_metrics/pcmdi/meanabs_xyt.py                                                    8      8     0%
      pcmdi_metrics/pcmdi/pmp_parser.py                                                     6      6     0%
      pcmdi_metrics/pcmdi/rms_0.py                                                          8      8     0%
      pcmdi_metrics/pcmdi/rms_xy.py                                                         5      5     0%
      pcmdi_metrics/pcmdi/rms_xyt.py                                                        5      5     0%
      pcmdi_metrics/pcmdi/rmsc_xy.py                                                        5      5     0%
      pcmdi_metrics/pcmdi/seasonal_mean.py                                                 15     15     0%
      pcmdi_metrics/pcmdi/std_xy.py                                                         5      5     0%
      pcmdi_metrics/pcmdi/std_xyt.py                                                        5      5     0%
      pcmdi_metrics/pcmdi/zonal_mean.py                                                     5      5     0%
      pcmdi_metrics/variability_mode/__init__.py                                            0      0   100%
      pcmdi_metrics/variability_mode/lib/__init__.py                                        7      7     0%
      pcmdi_metrics/variability_mode/lib/argparse_functions.py                             52     52     0%
      pcmdi_metrics/variability_mode/lib/calc_stat.py                                      80     80     0%
      pcmdi_metrics/variability_mode/lib/dict_merge.py                                      6      6     0%
      pcmdi_metrics/variability_mode/lib/eof_analysis.py                                  160    160     0%
      pcmdi_metrics/variability_mode/lib/landmask.py                                       42     42     0%
      pcmdi_metrics/variability_mode/lib/lib_variability_mode.py                           93     93     0%
      pcmdi_metrics/variability_mode/lib/plot_map.py                                       48     48     0%
      pcmdi_metrics/variability_mode/lib/version.py                                         3      3     0%
      pcmdi_metrics/variability_mode/variability_modes_driver.py                          302    302     0%
      pcmdi_metrics/version.py                                                              3      3     0%
      -----------------------------------------------------------------------------------------------------
      TOTAL                                                                              6380   6380     0%
      Coverage HTML written to dir tests_coverage_reports/htmlcov
      Coverage XML written to file tests_coverage_reports/coverage.xml
      
      =================================================== no tests ran in 2.25s ====================================================
  3. Move existing tests to tests/deprecated and ignore with pytest.

    • These tests are kept around as reference, but can removed if desired.

conda-env/dev.yml Outdated Show resolved Hide resolved
- These tests are written using Python Unittest, not pytest.
conda-env/dev.yml Outdated Show resolved Hide resolved
@tomvothecoder tomvothecoder marked this pull request as ready for review November 2, 2021 16:22
@tomvothecoder
Copy link
Collaborator Author

Hey @lee1043 @acordonez, this PR is ready for review. You can follow the usage commands to test the changes.

conda-env/dev.yml Outdated Show resolved Hide resolved
setup.cfg Show resolved Hide resolved
Copy link
Collaborator

@acordonez acordonez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tomvothecoder. Success with both usage commands. My pytest results look just like yours.

Copy link
Contributor

@lee1043 lee1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder cdat_info and MV should be included in the dev.yml, or they are implicitly installed through cdms2.

@acordonez
Copy link
Collaborator

@lee1043 which metrics use MV2? Since I've got the environment set up I can try running them and see if they work.

@tomvothecoder
Copy link
Collaborator Author

tomvothecoder commented Nov 2, 2021

I wonder cdat_info and MV should be included in the dev.yml, or they are implicitly installed through cdms2.

Both packages are installed through cdms2.

An easy way to test:

conda activate pcmdi_metrics_dev
python
>>> import MV2
>>> import cdat_info

Since pcmdi_metrics uses those packages directly, it is best to add them to the meta.yaml and conda-env/dev.yml. I will make these changes.

@tomvothecoder
Copy link
Collaborator Author

Actually MV2 is apart of cdms2, not a standalone package. I won't need to add that to the dependencies list.
https://cdms.readthedocs.io/en/latest/cdms2.html#module-cdms2.MV2

@lee1043
Copy link
Contributor

lee1043 commented Nov 2, 2021

@lee1043 which metrics use MV2? Since I've got the environment set up I can try running them and see if they work.

I think most of metrics use MV2: mean climate, modes of variability, mjo, monsoon_sperber and monsoon_wang.

But good to learn that installing cdms2 implicitly installs MV2 as well.

@lee1043
Copy link
Contributor

lee1043 commented Nov 2, 2021

@tomvothecoder can this eof package added to the dependency list? it's been used as a part of the modes of variability metric.

It looks like the eofs is on conda-forge: https://anaconda.org/conda-forge/eofs

@tomvothecoder
Copy link
Collaborator Author

@lee1043 and @acordonez Thanks for the review, I will go ahead and merge this PR.

@tomvothecoder
Copy link
Collaborator Author

Nevermind, I can't merge since the CircleCI checks are required (and I'm not sure if I have admin privilege to merge). Those two checks will need to be disabled in the repo settings.

@lee1043
Copy link
Contributor

lee1043 commented Nov 2, 2021

@tomvothecoder thanks for this PR. I will disable circle ci requirement and merge the PR.

@lee1043 lee1043 merged commit 4aed053 into PCMDI:master Nov 2, 2021
@tomvothecoder tomvothecoder deleted the devops/776-conda-dev-env branch November 2, 2021 20:36
@lee1043 lee1043 mentioned this pull request Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants