Skip to content

Commit

Permalink
Merge pull request #95 from ESGF/refresh-ci
Browse files Browse the repository at this point in the history
Refresh CI: add conda/mamba environment file and modern env creation, fix tests, and add modern Github Action workflow file
  • Loading branch information
valeriupredoi authored Nov 28, 2023
2 parents 72a609e + 7141237 commit 9ad147b
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 52 deletions.
67 changes: 40 additions & 27 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,49 @@
name: build ⚙️

on: [ push, pull_request ]
on:
push:
branches:
- master
pull_request:
branches:
- master
schedule:
- cron: '30 5 * * *'

# Required shell entrypoint to have properly configured bash shell
defaults:
run:
shell: bash -l {0}

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
fail-fast: false
name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- name: Install packages
run: |
sudo apt-get -y install pandoc
if: matrix.python-version == 3.7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install requirements 📦
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Test with pytest ⚙️
run: make test-all
- name: Lint with flake8 ⚙️
run: make lint
if: matrix.python-version == 3.6
- name: Test notebooks ⚙️
run: make test-nb
if: matrix.python-version == 3.7
- name: Build docs 🏗️
run: make docs
if: matrix.python-version == 3.7
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: esgf-pyclient
environment-file: environment.yml
python-version: ${{ matrix.python-version }}
miniforge-version: "latest"
miniforge-variant: Mambaforge
use-mamba: true
- run: conda --version
- run: python -V
- name: Install 📦
run: pip install -e .[develop]
- name: Lint with flake8 ⚙️
run: flake8
- name: Run tests
run: pytest
- name: Test notebooks ⚙️
run: make test-nb
- name: Build docs 🏗️
run: make docs
18 changes: 16 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
# conda env create -f environment.yml
---
name: esgf-pyclient
channels:
- conda-forge
- nodefaults

dependencies:
# installation
- pip
- python>=3.7
- python>=3.8
- requests
- requests_cache
- jinja2
- defusedxml
- webob
- myproxyclient
# testing
- flake8
- pytest
# documentation
- sphinx
- nbsphinx
- pandoc
# ipython notebook
- ipykernel
- nbconvert
- nbval
2 changes: 1 addition & 1 deletion notebooks/examples/logon.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"source": [
"**NOTE**: For the logon module you need to install the latest `myproxyclient` from pypi:\n",
"```\n",
"$ conda create -c conda-forge -n esgf-pyclient python=3.6 pip esgf-pyclient\n",
"$ conda create -c conda-forge -n esgf-pyclient python=3.10 pip esgf-pyclient\n",
"$ conda activate esgf-pyclient\n",
"(esgf-pyclient) pip install myproxyclient\n",
"```"
Expand Down
4 changes: 0 additions & 4 deletions pyesgf/logon.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,10 +273,6 @@ def _parse_dap_config(self, config_str=None):
return ('', '', '')
config_str = open(self.dap_config).read()

# !NOTE: The flags keyword argument to re.split was introduced
# in Python2.7
# Keep with call non-keyword arguments for compatibility with
# Python2.6
sections = re.split(r'^# (?:BEGIN|END) {0}$\n'
.format(DAP_CONFIG_MARKER),
config_str, re.M)
Expand Down
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[tool:pytest]
python_files = test_*.py
testpaths = tests
addopts = --strict --tb=native
addopts =
--strict
--tb=native
--ignore=tests/test_results.py
markers =
online: mark test to need internet connection
slow: mark test to be slow
Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@
'Topic :: Scientific/Engineering',
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
# Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
keywords='',
Expand All @@ -40,9 +41,8 @@
url='http://esgf-pyclient.readthedocs.org',
download_url='https://github.com/ESGF/esgf-pyclient',
license='BSD',
# This qualifier can be used to selectively exclude Python versions -
# in this case early Python 2 and 3 releases
python_requires=">=3.6.0",
# This qualifier can be used to selectively exclude Python versions
python_requires=">=3.8.0",
packages=find_packages(exclude=['ez_setup', 'examples', 'tests']),
include_package_data=True,
zip_safe=False,
Expand Down
5 changes: 3 additions & 2 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ def test_get_shard_list(self):
# !NOTE: the exact shard list will change depending on the shard
# replication configuration
# on the test server
assert 'esgf.ceda.ac.uk' in shards
assert 'esgf-solr.ceda.ac.uk' in shards
# in esg-search in esgf.ceda.ac.uk, there are a bunch
# of replicas hosted on esgf-index2
assert len(shards['esgf-index2.ceda.ac.uk']) > 1
print("Shards:", shards)
assert len(shards['esgf-solr.ceda.ac.uk']) > 1

def test_url_fixing(self):
# Switch off warnings for this case because we are testing that issue
Expand Down
2 changes: 0 additions & 2 deletions tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,10 @@ def test_distrib_with_few_facets(self):
def test_distrib_with_all_facets(self):
self._test_distrib(constraints=self._distrib_constraints_all_facets)

# @pytest.mark.skip(reason="cache fails on python 3.7")
def test_distrib_with_cache_with_few_facets(self):
self._test_distrib(constraints=self._distrib_constraints_few_facets,
cache=self.cache)

# @pytest.mark.skip(reason="cache fails on python 3.7")
@pytest.mark.xfail(reason=_all_facets_explanation)
# Expected failure: see test_distrib_all_facets above
def test_distrib_with_cache_with_all_facets(self):
Expand Down
18 changes: 10 additions & 8 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ def test_opendap_url(self):

agg_ctx = results[0].aggregation_context()
aggs = agg_ctx.search()
print(aggs)

# Take first aggregation
agg = aggs[0]
# agg = aggs[0]
for agg in aggs:
print((agg.aggregation_id))
print((agg.json['cf_standard_name']))
print((agg.urls))

print((agg.aggregation_id))
print((agg.json['cf_standard_name']))
print((agg.urls))

opendap_url = agg.opendap_url
print(opendap_url)
opendap_url = agg.opendap_url
print(opendap_url)

@pytest.mark.slow
def test_download_url(self):
Expand All @@ -65,4 +66,5 @@ def test_download_url(self):
files = results[0].file_context().search()

download_url = files[0].download_url
assert re.match(r'http://.*\.nc', download_url)
print("Download URL is: ", download_url)
assert re.match(r'https://.*\.nc', download_url)

0 comments on commit 9ad147b

Please sign in to comment.