diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5fe539f..9d40cf8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/environment.yml b/environment.yml index 33b9cab..f2dc09b 100644 --- a/environment.yml +++ b/environment.yml @@ -1,4 +1,3 @@ -# conda env create -f environment.yml --- name: esgf-pyclient channels: @@ -6,11 +5,23 @@ channels: - nodefaults dependencies: + # installation - pip - - python>=3.7 + - python>=3.8 - requests - requests_cache - jinja2 - defusedxml - webob - myproxyclient >=2.1.1 + # testing + - flake8 + - pytest + # documentation + - sphinx + - nbsphinx + - pandoc + # ipython notebook + - ipykernel + - nbconvert + - nbval diff --git a/notebooks/examples/logon.ipynb b/notebooks/examples/logon.ipynb index 9cb543c..872936f 100644 --- a/notebooks/examples/logon.ipynb +++ b/notebooks/examples/logon.ipynb @@ -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", "```" diff --git a/pyesgf/logon.py b/pyesgf/logon.py index d75e68f..654ef72 100644 --- a/pyesgf/logon.py +++ b/pyesgf/logon.py @@ -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) diff --git a/setup.cfg b/setup.cfg index 052e5b7..086eb7e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 diff --git a/setup.py b/setup.py index 02bc55a..f44c3d5 100644 --- a/setup.py +++ b/setup.py @@ -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='', @@ -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, diff --git a/tests/test_connection.py b/tests/test_connection.py index dce40e8..aba5c4f 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -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 diff --git a/tests/test_context.py b/tests/test_context.py index d5027a8..36adcab 100644 --- a/tests/test_context.py +++ b/tests/test_context.py @@ -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): diff --git a/tests/test_util.py b/tests/test_util.py index 79a13a1..d6dfeda 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -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): @@ -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)