diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c579f7e..7936fdc 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,7 +22,7 @@ jobs: python-version: ["3.9", "3.10", "3.11"] runs-on: ${{ matrix.os }} steps: - - name: 🥡 Checkout code + - name: 🫙 Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 # checkout tags (which is not done by default) @@ -39,10 +39,8 @@ jobs: shell: bash -l {0} run: | python -m pip install -e ".[test]" - - name: Test with pytest - run: pytest pangeo_forge_esgf/tests - name: 🏄‍♂️ Run Tests shell: bash -l {0} run: | - py.test tests -v + py.test pangeo_forge_esgf/tests -v diff --git a/pangeo_forge_esgf/parsing.py b/pangeo_forge_esgf/parsing.py index 34e9042..af1cb45 100644 --- a/pangeo_forge_esgf/parsing.py +++ b/pangeo_forge_esgf/parsing.py @@ -1,4 +1,5 @@ import requests +from typing import Optional from .utils import facets_from_iid @@ -23,7 +24,10 @@ def instance_ids_from_request(json_dict): return uniqe_iids -def parse_instance_ids(iid: str) -> list[str]: +def parse_instance_ids( + iid: str, + search_node:Optional[str] = None +) -> list[str]: """Parse an instance id with wildcards""" facets = facets_from_iid(iid) # convert string to list if square brackets are found @@ -39,13 +43,13 @@ def parse_instance_ids(iid: str) -> list[str]: facets[k] = v facets_filtered = {k: v for k, v in facets.items() if v != "*"} - # TODO: I should make the node url a keyword argument. - # For now this works well enough - url = "https://esgf-node.llnl.gov/esg-search/search" - # url = "https://esgf-data.dkrz.de/esg-search/search" + if search_node is None: + # search_node = "https://esgf-node.llnl.gov/esg-search/search" + search_node = "https://esgf-data.dkrz.de/esg-search/search" + #FIXME: I got some really weird flakyness with the LLNL node. This is a dumb way to test this... # TODO: how do I iterate over this more efficiently? # Maybe we do not want to allow more than x files parsed? - resp = request_from_facets(url, **facets_filtered) + resp = request_from_facets(search_node, **facets_filtered) if resp.status_code != 200: print(f"Request [{resp.url}] failed with {resp.status_code}") return resp diff --git a/pangeo_forge_esgf/tests/test_logging.py b/pangeo_forge_esgf/tests/test_logging.py new file mode 100644 index 0000000..d4f0a1c --- /dev/null +++ b/pangeo_forge_esgf/tests/test_logging.py @@ -0,0 +1,5 @@ +"""Not sure if this is working but I want to somehow test that logging is active and working as expected.""" +from pangeo_forge_esgf import setup_logging + +def test_setup_logging_smoketest(): + setup_logging(level="DEBUG") \ No newline at end of file diff --git a/pangeo_forge_esgf/tests/test_recipe_inputs.py b/pangeo_forge_esgf/tests/test_recipe_inputs.py index bd8ce4a..90e70b7 100644 --- a/pangeo_forge_esgf/tests/test_recipe_inputs.py +++ b/pangeo_forge_esgf/tests/test_recipe_inputs.py @@ -1,5 +1,5 @@ import pytest -from pangeo_forge_esgf.recipe_inputs import sort_urls_by_time, get_unique_filenames, filter_urls_first, filter_urls_preferred_node +from pangeo_forge_esgf.recipe_inputs import sort_urls_by_time, get_unique_filenames, filter_urls_first @pytest.mark.parametrize( @@ -74,19 +74,3 @@ def test_filter_first_file_urls(): for ii in range(2): assert filtered[i][ii] == expected[i][ii] -# def test_filter_urls_preferred_node(): -# unfiltered = [ -# ('some.iid.you.like|some.filename.pattern', ['urlb', 'url2']), -# ('some.iid.you.like|some.other_filename.pattern', ['url2', 'urla', 'urlb']), -# ('some.other_iid.you.like|some.filename.pattern', ['urlc']), -# ('some.other_iid.you.like|some.other_filename.pattern', ['urlb', 'urla']), -# ] -# expected = [ -# ('some.iid.you.like|some.filename.pattern', 'url2'), -# ('some.iid.you.like|some.other_filename.pattern', 'urla'), -# ('some.other_iid.you.like|some.filename.pattern', 'urlc'), -# ('some.other_iid.you.like|some.other_filename.pattern', 'urla'), -# ] -# filtered = filter_urls_preferred_node(unfiltered, preferred_file=['urla', 'url2']) -# pass -