diff --git a/.github/workflows/quicktest.yaml b/.github/workflows/quicktest.yaml index 03c4a31f..eaa53437 100644 --- a/.github/workflows/quicktest.yaml +++ b/.github/workflows/quicktest.yaml @@ -24,7 +24,7 @@ concurrency: on: pull_request: - types: [labeled, unlabeled] + types: [labeled] workflow_dispatch: inputs: docker-image: diff --git a/FastSurferCNN/run_prediction.py b/FastSurferCNN/run_prediction.py index b5a6b30f..cd79317c 100644 --- a/FastSurferCNN/run_prediction.py +++ b/FastSurferCNN/run_prediction.py @@ -249,8 +249,8 @@ def __init__( raise ValueError( f"Could not find the ColorLUT in {lut}, please make sure the --lut argument is valid." ) from err - self.labels = self.lut["ID"].values - self.torch_labels = torch.from_numpy(np.asarray(self.lut["ID"].values)) + self.labels = np.asarray(self.lut["ID"].values).copy() + self.torch_labels = torch.from_numpy(self.labels) self.names = ["SubjectName", "Average", "Subcortical", "Cortical"] self.cfg_fin, cfg_cor, cfg_sag, cfg_ax = args2cfg(cfg_ax, cfg_cor, cfg_sag, batch_size=batch_size) # the order in this dictionary dictates the order in the view aggregation diff --git a/tools/Docker/Dockerfile b/tools/Docker/Dockerfile index 06e1db13..b0295c90 100644 --- a/tools/Docker/Dockerfile +++ b/tools/Docker/Dockerfile @@ -62,6 +62,16 @@ # - AUTHOR: # The author string to include in image labels. # - default: "David Kügler " +# - DEVICE: +# The device type to build the python environment for, this affects the installed torch packages. +# Supported values are what is supported by uv, e.g.: cu128, xpu, rocm6.2.4, etc. +# - default: cu128 +# - DEBUG: +# If set to "true", retains build debug output during build. +# - default: false +# - INSECURE_FLAG: +# If set to "--insecure", will download freesurfer without verifying the ssl certificate. +# - default: "" # DOCUMENTATION FOR TARGETS (use '--target '): # To select which imaged will be tagged with '-t' @@ -91,6 +101,7 @@ ARG AUTHOR="David Kügler " ARG BUILDKIT_SBOM_SCAN_CONTEXT="true" ARG DEVICE="cu128" ARG DEBUG="false" +ARG INSECURE_FLAG="" FROM ghcr.io/astral-sh/uv:$UV_VERSION AS selected_uv_install_image @@ -200,7 +211,13 @@ RUN --mount=type=bind,source=tools/build/install_fs_pruned.sh,target=/install/in --mount=type=bind,source=tools/build/link_fs.sh,target=/install/link_fs.sh \ --mount=type=cache,target=/install/download \ --mount=type=bind,source=pyproject.toml,target=/install/pyproject.toml < argparse.ArgumentParser: help=f"explicitly specifies the base image to build the build images from " f"(default: {DEFAULTS.BUILD_BASE_IMAGE}).", ) + expert.add_argument( + "--insecure", + action="store_true", + help="disables certificate check for downloads, e.g. freesurfer.", + ) expert.add_argument( "--debug", action="store_true", @@ -628,6 +634,7 @@ def main( dry_run: bool = False, tag_dev: bool = True, fastsurfer_home: Path | None = None, + insecure: bool = False, **keywords, ) -> int | str: from FastSurferCNN.version import has_git, parse_build_file @@ -644,7 +651,9 @@ def main( fastsurfer_home = Path(fastsurfer_home) if fastsurfer_home else default_home() # read the freesurfer download url from pyproject.toml with open(fastsurfer_home / "pyproject.toml", "rb") as fp: - pyproject_freesurfer = tomllib.load(fp)["tool"]["freesurfer"] + pyproject_toml = tomllib.load(fp) + pyproject_repository_url = pyproject_toml["project"]["urls"]["source"] + pyproject_freesurfer = pyproject_toml["tool"]["freesurfer"] if target not in get_args(Target): raise ValueError(f"Invalid target: {target}") @@ -660,6 +669,7 @@ def main( f"DEVICE={DEFAULTS.MapDeviceType.get(device, 'cpu')}", f"FREESURFER_URL={pyproject_freesurfer['urls']['linux'].format(version=pyproject_freesurfer['version'])}", f"FREESURFER_VERSION={pyproject_freesurfer['version']}", + f"INSECURE_FLAG={'--insecure' if insecure else ''}", ] if debug: kwargs["build_arg"].append("DEBUG=true") @@ -700,13 +710,14 @@ def main( build_info = parse_build_file(build_file) if has_git(): - repository_url = get_repository_url(build_info["git_status"], build_info["git_branch"]) kwargs["build_arg"].extend([ - f"REPOSITORY_URL={repository_url}", - f"GIT_HASH={build_info['git_hash']}", + f"GIT_HASH={build_info['git_hash']}", + f"REPOSITORY_URL={pyproject_repository_url}/tree/{build_info['git_branch']}", ]) - if "github.com/tree/stable" in repository_url: + if build_info["git_branch"] == "stable": kwargs["build_arg"].append("DOC_URL=https://deep-mi.org/fastsurfer/stable") + else: + kwargs["build_arg"].append(f"REPOSITORY_URL={pyproject_repository_url}/tree/dev") kwargs["build_arg"].append(f"FASTSURFER_VERSION={build_info['version_tag']}") version_tag = build_info["version_tag"] image_prefix = "" @@ -750,23 +761,6 @@ def main( return 0 -def get_repository_url(git_status_text: str, branch: str) -> str: - """Get the repository URL of the current git repository.""" - from FastSurferCNN.utils.run_tools import Popen - - remote = git_status_text.removeprefix(f"## {branch}...").split("/")[0] - repository_process = Popen(["git", "remote", "get-url", remote], stdout=subprocess.PIPE).finish() - if repository_process.retcode != 0: - logger.error(repository_process.err_str()) - raise RuntimeError("Could not get the repository URL from git.") - repository_url = repository_process.out_str().strip() - if repository_url.endswith(".git"): - repository_url = repository_url[:-4] - if repository_url.startswith("git@"): - repository_url = "https://" + repository_url[4:].replace(":/", "/") - return repository_url + "/tree/" + branch - - def default_home() -> Path: """ Find the fastsurfer path.