Skip to content

Commit 0aa4f86

Browse files
committed
change default test envs
only real change: always get tensorflow from main channel because e.g. tf 2.5 is not available on conda-forge
1 parent 942656d commit 0aa4f86

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

scripts/static_validation.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
def get_base_env() -> Dict[str, Union[str, List[Union[str, Dict[str, List[str]]]]]]:
22-
return {"channels": ["conda-forge", "defaults"], "dependencies": ["bioimageio.core"]}
22+
return {"channels": ["defaults"], "dependencies": ["conda-forge::bioimageio.core"]}
2323

2424

2525
def get_env_from_deps(deps: Dependencies):
@@ -45,8 +45,10 @@ def get_env_from_deps(deps: Dependencies):
4545
conda_env["dependencies"] = deps + ["conda-forge::bioimageio.core"]
4646
elif deps.manager == "pip":
4747
pip_req = [d for d in dep_file_content.split("\n") if not d.strip().startswith("#")]
48-
conda_env["dependencies"].append("pip")
49-
conda_env["dependencies"].append({"pip": pip_req})
48+
if "bioimageio.core" not in pip_req:
49+
pip_req.append("bioimageio.core")
50+
51+
conda_env = dict(channels=["defaults"], dependencies=["python=3.9", "pip", {"pip": pip_req}])
5052
else:
5153
raise NotImplementedError(deps.manager)
5254

@@ -57,7 +59,7 @@ def get_env_from_deps(deps: Dependencies):
5759

5860

5961
def get_version_range(v: Version) -> str:
60-
return f">={v.major}.{v.minor},<{v.major}.{v.minor + 1}"
62+
return f"={v.major}.{v.minor}.*"
6163

6264

6365
def get_default_env(
@@ -68,22 +70,21 @@ def get_default_env(
6870
):
6971
conda_env = get_base_env()
7072
if opset_version is not None:
71-
conda_env["dependencies"].append("onnxruntime")
73+
conda_env["dependencies"].append("conda-forge::onnxruntime")
7274
# note: we should not need to worry about the opset version,
7375
# see https://github.com/microsoft/onnxruntime/blob/master/docs/Versioning.md
7476

7577
if pytorch_version is not None:
7678
conda_env["channels"].insert(0, "pytorch")
77-
conda_env["dependencies"].append(f"pytorch {get_version_range(pytorch_version)}")
78-
conda_env["dependencies"].append("cpuonly")
79+
conda_env["dependencies"].extend([f"pytorch {get_version_range(pytorch_version)}", "cpuonly"])
7980

8081
if tensorflow_version is not None:
8182
# tensorflow 1 is not available on conda, so we need to inject this as a pip dependency
8283
if tensorflow_version.major == 1:
8384
tensorflow_version = max(tensorflow_version, Version("1.13")) # tf <1.13 not available anymore
8485
assert opset_version is None
8586
assert pytorch_version is None
86-
conda_env["dependencies"] = ["pip", "python >=3.7,<3.8"] # tf 1.15 not available for py>=3.8
87+
conda_env["dependencies"] = ["pip", "python=3.7.*"] # tf 1.15 not available for py>=3.8
8788
# get bioimageio.core (and its dependencies) via pip as well to avoid conda/pip mix
8889
# protobuf pin: tf 1 does not pin an upper limit for protobuf,
8990
# but fails to load models saved with protobuf 3 when installing protobuf 4.

0 commit comments

Comments
 (0)