@@ -78,6 +78,12 @@ def load_env_config():
7878 "ALLOW_NON_ALIGNED_WRITE" : parse_bool (
7979 os .getenv ("ALLOW_NON_ALIGNED_WRITE" , "false" )
8080 ),
81+ # Process possible comma separated list of integers for manual chunk size
82+ "MANUAL_CHUNK_SIZE" : (
83+ [int (x ) for x in str (os .getenv ("MANUAL_CHUNK_SIZE" , "None" )).split ("," )]
84+ if os .getenv ("MANUAL_CHUNK_SIZE" , "None" ).lower () != "none"
85+ else None
86+ ),
8187 }
8288
8389 return config
@@ -101,6 +107,7 @@ def load_env_config():
101107mip_cutoff = config ["MIP_CUTOFF" ]
102108channel_limit = config ["CHANNEL_LIMIT" ]
103109allow_non_aligned_write = config ["ALLOW_NON_ALIGNED_WRITE" ]
110+ manual_chunk_size = config ["MANUAL_CHUNK_SIZE" ]
104111
105112# Print loaded configuration for verification
106113print ("Configuration loaded:" )
@@ -551,10 +558,18 @@ def compute_optimal_chunk_size(single_file_shape, num_mips, max_chunk_size=None)
551558 f"Computing optimal chunk size for shape { single_file_xyz_shape } with { num_mips } MIP levels..."
552559)
553560computed_chunk_size = compute_optimal_chunk_size (single_file_xyz_shape , num_mips )
554- # computed_chunk_size = [64, 64, 32] # Override here if needed
555-
556- print (f"Computed optimal chunk size: { computed_chunk_size } " )
557- chunk_size = computed_chunk_size
561+ if manual_chunk_size is not None :
562+ if len (manual_chunk_size ) != 3 :
563+ print (
564+ "Error: MANUAL_CHUNK_SIZE must be a list of three integers (e.g., 64,64,16)"
565+ )
566+ exit (1 )
567+ print (f"Using manual chunk size from configuration: { manual_chunk_size } " )
568+ chunk_size = manual_chunk_size
569+ else :
570+ computed_chunk_size = compute_optimal_chunk_size (single_file_xyz_shape , num_mips )
571+ print (f"Computed optimal chunk size: { computed_chunk_size } " )
572+ chunk_size = computed_chunk_size
558573
559574volume_size = [
560575 single_file_xyz_shape [0 ] * computed_num_rows ,
0 commit comments