Skip to content

Commit 5fd0572

Browse files
committed
prefer conda-forge channel for dynamic validation
get tf < 2.11 still from defaults
1 parent 1a95c28 commit 5fd0572

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

scripts/static_validation.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import warnings
33
from functools import partialmethod
44
from pathlib import Path
5-
from typing import Dict, List, Optional, Union
5+
from typing import Dict, List, Literal, Optional, Union
66

77
import requests
88
import typer
@@ -23,7 +23,7 @@
2323

2424

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

2828

2929
def get_env_from_deps(deps: Dependencies):
@@ -49,10 +49,10 @@ def get_env_from_deps(deps: Dependencies):
4949
conda_env["dependencies"] = deps + ["conda-forge::bioimageio.core"]
5050
elif deps.manager == "pip":
5151
pip_req = [d for d in dep_file_content.split("\n") if not d.strip().startswith("#")]
52-
if "bioimageio.core" not in pip_req:
52+
if not any(r.startswith("bioimageio.core") for r in pip_req):
5353
pip_req.append("bioimageio.core")
5454

55-
conda_env = dict(channels=["defaults"], dependencies=["python=3.9", "pip", {"pip": pip_req}])
55+
conda_env = dict(channels=["conda-forge"], dependencies=["python=3.9", "pip", {"pip": pip_req}])
5656
else:
5757
raise NotImplementedError(deps.manager)
5858

@@ -74,7 +74,7 @@ def get_default_env(
7474
):
7575
conda_env = get_base_env()
7676
if opset_version is not None:
77-
conda_env["dependencies"].append("conda-forge::onnxruntime")
77+
conda_env["dependencies"].append("onnxruntime")
7878
# note: we should not need to worry about the opset version,
7979
# see https://github.com/microsoft/onnxruntime/blob/master/docs/Versioning.md
8080

@@ -93,9 +93,15 @@ def get_default_env(
9393
# protobuf pin: tf 1 does not pin an upper limit for protobuf,
9494
# but fails to load models saved with protobuf 3 when installing protobuf 4.
9595
conda_env["dependencies"].append(
96-
{"pip": [f"bioimageio.core", f"tensorflow {get_version_range(tensorflow_version)}", "protobuf <4.0"]}
96+
{"pip": ["bioimageio.core", f"tensorflow {get_version_range(tensorflow_version)}", "protobuf <4.0"]}
9797
)
98-
else: # use conda otherwise
98+
elif tensorflow_version.major == 2 and tensorflow_version.minor < 11:
99+
# get older tf versions from defaults channel
100+
conda_env = {
101+
"channels": ["defaults"],
102+
"dependencies": ["conda-forge::bioimageio.core", f"tensorflow {get_version_range(tensorflow_version)}"],
103+
}
104+
else: # use conda-forge otherwise
99105
conda_env["dependencies"].append(f"tensorflow {get_version_range(tensorflow_version)}")
100106

101107
return conda_env

0 commit comments

Comments
 (0)