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

Fixes tests in prematurely merged #21 #24

Merged
merged 3 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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

16 changes: 10 additions & 6 deletions pangeo_forge_esgf/parsing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import requests
from typing import Optional

from .utils import facets_from_iid

Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pangeo_forge_esgf/tests/test_logging.py
Original file line number Diff line number Diff line change
@@ -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")
18 changes: 1 addition & 17 deletions pangeo_forge_esgf/tests/test_recipe_inputs.py
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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