Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default data format with enviroment variable #958

Merged
merged 9 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions webknossos/webknossos/dataset/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
DEFAULT_WKW_FILE_LEN = 32
DEFAULT_CHUNK_SHAPE = Vec3Int.full(32)
DEFAULT_DATA_FORMAT = (
DataFormat.WKW
if not os.environ.get("WK_DEFAULT_DATA_FORMAT") == "zarr3"
else DataFormat.Zarr3
DataFormat(os.environ["WK_DEFAULT_DATA_FORMAT"])
if "WK_DEFAULT_DATA_FORMAT" in os.environ
else DataFormat.WKW
)
DEFAULT_CHUNKS_PER_SHARD = Vec3Int.full(
int(os.environ.get("WK_DEFAULT_CHUNKS_PER_SHARD", 32))
DEFAULT_CHUNKS_PER_SHARD = (
Vec3Int.from_str(os.environ["WK_DEFAULT_CHUNKS_PER_SHARD"])
if "WK_DEFAULT_CHUNKS_PER_SHARD" in os.environ
else Vec3Int.full(32)
)
DEFAULT_CHUNKS_PER_SHARD_ZARR = Vec3Int.full(1)
DEFAULT_CHUNKS_PER_SHARD_FROM_IMAGES = Vec3Int(128, 128, 1)
Expand Down
6 changes: 6 additions & 0 deletions webknossos/webknossos/geometry/vec3_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@ def from_vec_or_int(vec_or_int: Union["Vec3IntLike", int]) -> "Vec3Int":
else:
return Vec3Int(vec_or_int)

@staticmethod
def from_str(string: str):
s = eval(string)
normanrz marked this conversation as resolved.
Show resolved Hide resolved
if type(s) == tuple or type(s) == int:
return Vec3Int.from_vec_or_int(s)

@property
def x(self) -> int:
return self[0]
Expand Down
Loading