From a2639e9103ec666df7e48c31c9fc2f0576690d5e Mon Sep 17 00:00:00 2001 From: Benjamin Gallusser Date: Sun, 1 Feb 2026 09:49:47 -0800 Subject: [PATCH] Fix cachedir type --- scripts/train.py | 4 ++-- trackastra/utils/__init__.py | 1 + trackastra/utils/utils.py | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/train.py b/scripts/train.py index 8393d64..9f6a520 100644 --- a/scripts/train.py +++ b/scripts/train.py @@ -40,7 +40,7 @@ from trackastra.utils import ( blockwise_causal_norm, blockwise_sum, - none_or_path, + none_or_str, normalize, preallocate_memory, random_label_cmap, @@ -1087,7 +1087,7 @@ def parse_train_args(): ) parser.add_argument( "--cachedir", - type=none_or_path, + type=none_or_str, default=".cache", help="cache dir for CTCData. Set to `None` to disable caching.", ) diff --git a/trackastra/utils/__init__.py b/trackastra/utils/__init__.py index 36b8cee..2a60cb8 100644 --- a/trackastra/utils/__init__.py +++ b/trackastra/utils/__init__.py @@ -4,6 +4,7 @@ blockwise_causal_norm, blockwise_sum, none_or_path, + none_or_str, normalize, preallocate_memory, random_label_cmap, diff --git a/trackastra/utils/utils.py b/trackastra/utils/utils.py index 606fe50..1087065 100644 --- a/trackastra/utils/utils.py +++ b/trackastra/utils/utils.py @@ -464,6 +464,14 @@ def str2path(x: str) -> Path: return Path(x).expanduser().resolve() +def none_or_str(x: str | None) -> str | None: + """Allow for none value in string parsing.""" + if x in (None, "None", "none"): + return None + else: + return str(x) + + def none_or_path(x: str | None) -> Path | None: """Cast string to resolved absolute path or return None.""" if x in (None, "None", "none"):