Skip to content

Commit

Permalink
Merge pull request #87 from pangeo-forge/version-check
Browse files Browse the repository at this point in the history
Cleanup how we pick beam or no-beam versions of recipes to test
  • Loading branch information
yuvipanda authored Aug 19, 2023
2 parents a0fef17 + 1f4af18 commit 78162c6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
15 changes: 0 additions & 15 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,3 @@ def minio(local_ip):
proc.wait()

assert proc.returncode == 0


@pytest.fixture
def recipes_version_ref():
# FIXME: recipes version matrix is currently determined by github workflows matrix
# in the future, it should be set by pangeo-forge-runner venv feature?
pip_list = subprocess.check_output("pip list".split()).decode("utf-8").splitlines()
recipes_version = [
p.split()[-1] for p in pip_list if p.startswith("pangeo-forge-recipes")
][0]
# the recipes_version is a 3-element semantic version of form `0.A.B` where A is either minor
# version `9` or `10`. the test feedstock (pforgetest/gpcp-from-gcs-feedstock) has tags for
# each of these minor versions, of the format `0.A.x`, so we translate the installed version
# of pangeo-forge-recipes to one of the valid tags (either `0.9.x` or `0.10.x`) here.
return f"0.{recipes_version.split('.')[1]}.x"
15 changes: 11 additions & 4 deletions tests/integration/test_dataflow_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
import subprocess
import tempfile
import time
from importlib.metadata import version

import pytest
import xarray as xr
from packaging.version import parse as parse_version


def test_dataflow_integration(recipes_version_ref):
def test_dataflow_integration():
pfr_version = parse_version(version("pangeo-forge-recipes"))
if pfr_version >= parse_version("0.10"):
recipe_version_ref = "0.10.x"
else:
recipe_version_ref = "0.9.x"
bucket = "gs://pangeo-forge-runner-ci-testing"
config = {
"Bake": {
Expand Down Expand Up @@ -40,7 +47,7 @@ def test_dataflow_integration(recipes_version_ref):
"--ref",
# in the test feedstock, tags are named for the recipes version
# which was used to write the recipe module
recipes_version_ref,
recipe_version_ref,
"--json",
"-f",
f.name,
Expand Down Expand Up @@ -93,8 +100,8 @@ def test_dataflow_integration(recipes_version_ref):

# open the generated dataset with xarray!
target_path = config["TargetStorage"]["root_path"].format(job_name=job_name)
if recipes_version_ref == "0.10.x":
# in pangeo-forge-recipes>=0.10.0, an additional `StoreToZarr.store_name` kwarg
if pfr_version >= parse_version("0.10"):
# in pangeo-forge-eecipes>=0.10.0, an additional `StoreToZarr.store_name` kwarg
# is appended to the formatted root path at execution time. for ref `0.10.x`,
# the value of that kwarg is "gpcp", so we append that here.
target_path += "/gpcp"
Expand Down
17 changes: 12 additions & 5 deletions tests/unit/test_bake.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import re
import subprocess
import tempfile
from importlib.metadata import version

import pytest
import xarray as xr
from packaging.version import parse as parse_version

from pangeo_forge_runner.commands.bake import Bake

Expand Down Expand Up @@ -50,9 +52,7 @@ def test_job_name_validation(job_name, raises):
[None, None, "special-name-for-job"],
),
)
def test_gpcp_bake(
minio, recipe_id, expected_error, custom_job_name, recipes_version_ref
):
def test_gpcp_bake(minio, recipe_id, expected_error, custom_job_name):
fsspec_args = {
"key": minio["username"],
"secret": minio["password"],
Expand Down Expand Up @@ -86,6 +86,12 @@ def test_gpcp_bake(
if custom_job_name:
config["Bake"].update({"job_name": custom_job_name})

pfr_version = parse_version(version("pangeo-forge-recipes"))
if pfr_version >= parse_version("0.10"):
recipe_version_ref = "0.10.x"
else:
recipe_version_ref = "0.9.x"

with tempfile.NamedTemporaryFile("w", suffix=".json") as f:
json.dump(config, f)
f.flush()
Expand All @@ -97,7 +103,7 @@ def test_gpcp_bake(
"--ref",
# in the test feedstock, tags are named for the recipes version
# which was used to write the recipe module
recipes_version_ref,
recipe_version_ref,
"--json",
"-f",
f.name,
Expand Down Expand Up @@ -126,7 +132,8 @@ def test_gpcp_bake(
# root path itself. This is a compatibility break vs the previous
# versions of pangeo-forge-recipes. https://github.com/pangeo-forge/pangeo-forge-recipes/pull/495
# has more information
if recipes_version_ref == "0.10.x":

if pfr_version >= parse_version("0.10"):
zarr_store_path = config["TargetStorage"]["root_path"] + "gpcp/"
else:
zarr_store_path = config["TargetStorage"]["root_path"]
Expand Down

0 comments on commit 78162c6

Please sign in to comment.