Skip to content

Commit d3daf12

Browse files
committed
update registry to be a separate dir
1 parent a18fab0 commit d3daf12

File tree

3 files changed

+40
-15
lines changed

3 files changed

+40
-15
lines changed

geotessera/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _load_tiles_registry_index(self):
143143

144144
# Download the master tiles registry index
145145
tiles_index_file = pooch.retrieve(
146-
url=f"{TESSERA_BASE_URL}/{self.version}/global_0.1_degree_tiff_all/registry_index.txt",
146+
url=f"{TESSERA_BASE_URL}/{self.version}/registry/tiles_registry_index.txt",
147147
known_hash=None,
148148
fname="tiles_registry_index.txt",
149149
path=cache_path,
@@ -165,7 +165,7 @@ def _load_registry_index(self):
165165

166166
# Download the master registry index
167167
registry_index_file = pooch.retrieve(
168-
url=f"{TESSERA_BASE_URL}/{self.version}/global_0.1_degree_representation/registry_index.txt",
168+
url=f"{TESSERA_BASE_URL}/{self.version}/registry/registry_index.txt",
169169
known_hash=None,
170170
fname="registry_index.txt",
171171
path=cache_path,
@@ -192,7 +192,7 @@ def _ensure_block_loaded(self, year: int, lon: float, lat: float):
192192
registry_filename = get_block_registry_filename(str(year), block_lon, block_lat)
193193

194194
# Download the specific block registry file
195-
registry_url = f"{TESSERA_BASE_URL}/{self.version}/global_0.1_degree_representation/{registry_filename}"
195+
registry_url = f"{TESSERA_BASE_URL}/{self.version}/registry/{registry_filename}"
196196
registry_file = pooch.retrieve(
197197
url=registry_url,
198198
known_hash=None,
@@ -227,7 +227,7 @@ def _ensure_tile_block_loaded(self, lon: float, lat: float):
227227
registry_filename = get_tiles_registry_filename(block_lon, block_lat)
228228

229229
# Download the specific tile block registry file
230-
registry_url = f"{TESSERA_BASE_URL}/{self.version}/global_0.1_degree_tiff_all/{registry_filename}"
230+
registry_url = f"{TESSERA_BASE_URL}/{self.version}/registry/{registry_filename}"
231231
registry_file = pooch.retrieve(
232232
url=registry_url,
233233
known_hash=None,

geotessera/registry_cli.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@ def update_representations_command(args):
121121
print(f"Error: Directory {base_dir} does not exist")
122122
return
123123

124-
# Determine registry output directory
124+
# Determine registry output directory - go up to parent of base_dir
125125
if hasattr(args, 'registry_dir') and args.registry_dir:
126-
registry_dir = os.path.join(os.path.abspath(args.registry_dir), "embeddings")
126+
registry_dir = os.path.join(os.path.abspath(args.registry_dir), "registry")
127127
else:
128-
registry_dir = base_dir
128+
# Place registry at same level as global_0.1_degree_representation
129+
parent_dir = os.path.dirname(base_dir)
130+
registry_dir = os.path.join(parent_dir, "registry")
129131

130132
# Ensure registry directory exists
131133
os.makedirs(registry_dir, exist_ok=True)
@@ -240,6 +242,27 @@ def update_representations_command(args):
240242

241243
print(f"Master index written with {len(all_registry_files)} registry files")
242244
print(f"Total blocks processed: {total_blocks}")
245+
246+
# Generate master registry.txt that includes all individual registries
247+
master_registry_path = os.path.join(registry_dir, "registry.txt")
248+
print(f"Generating master registry.txt: {master_registry_path}")
249+
250+
with open(master_registry_path, 'w') as f:
251+
f.write("# GeoTessera Master Registry\n")
252+
f.write("# This file combines all block registries for embeddings\n")
253+
f.write(f"# Contains entries from {len(all_registry_files)} block registry files\n\n")
254+
255+
total_entries = 0
256+
for registry_file in sorted(all_registry_files):
257+
if os.path.exists(registry_file):
258+
with open(registry_file, 'r') as reg_f:
259+
for line in reg_f:
260+
line = line.strip()
261+
if line and not line.startswith('#'):
262+
f.write(f"{line}\n")
263+
total_entries += 1
264+
265+
print(f"Master registry.txt written with {total_entries} total entries")
243266

244267

245268

@@ -250,11 +273,13 @@ def update_tiles_command(args):
250273
print(f"Error: Directory {base_dir} does not exist")
251274
return
252275

253-
# Determine registry output directory
276+
# Determine registry output directory - go up to parent of base_dir
254277
if hasattr(args, 'registry_dir') and args.registry_dir:
255-
registry_dir = os.path.join(os.path.abspath(args.registry_dir), "tiles")
278+
registry_dir = os.path.join(os.path.abspath(args.registry_dir), "registry")
256279
else:
257-
registry_dir = base_dir
280+
# Place registry at same level as global_0.1_degree_tiff_all
281+
parent_dir = os.path.dirname(base_dir)
282+
registry_dir = os.path.join(parent_dir, "registry")
258283

259284
# Ensure registry directory exists
260285
os.makedirs(registry_dir, exist_ok=True)
@@ -348,7 +373,7 @@ def update_tiles_command(args):
348373

349374
# Generate master index of all tile registry files
350375
if all_registry_files:
351-
master_index_path = os.path.join(registry_dir, "registry_index.txt")
376+
master_index_path = os.path.join(registry_dir, "tiles_registry_index.txt")
352377
print(f"\nGenerating master tiles registry index: {master_index_path}")
353378

354379
with open(master_index_path, 'w') as f:

geotessera/registry_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get_registry_path_for_tile(registry_base_dir: str, year: str, lon: float, la
8282
Get the full path to the registry file containing a specific tile.
8383
8484
Args:
85-
registry_base_dir: Base directory for registry files
85+
registry_base_dir: Base directory for registry files (should be the parent directory)
8686
year: Year string (e.g., "2024")
8787
lon: Longitude in decimal degrees
8888
lat: Latitude in decimal degrees
@@ -93,7 +93,7 @@ def get_registry_path_for_tile(registry_base_dir: str, year: str, lon: float, la
9393
import os
9494
block_lon, block_lat = get_block_coordinates(lon, lat)
9595
registry_filename = get_block_registry_filename(year, block_lon, block_lat)
96-
return os.path.join(registry_base_dir, "embeddings", registry_filename)
96+
return os.path.join(registry_base_dir, "registry", registry_filename)
9797

9898

9999
def get_tiles_registry_filename(block_lon: int, block_lat: int) -> str:
@@ -118,7 +118,7 @@ def get_registry_path_for_tiles(registry_base_dir: str, lon: float, lat: float)
118118
Get the full path to the tiles registry file containing a specific coordinate.
119119
120120
Args:
121-
registry_base_dir: Base directory for registry files
121+
registry_base_dir: Base directory for registry files (should be the parent directory)
122122
lon: Longitude in decimal degrees
123123
lat: Latitude in decimal degrees
124124
@@ -128,7 +128,7 @@ def get_registry_path_for_tiles(registry_base_dir: str, lon: float, lat: float)
128128
import os
129129
block_lon, block_lat = get_block_coordinates(lon, lat)
130130
registry_filename = get_tiles_registry_filename(block_lon, block_lat)
131-
return os.path.join(registry_base_dir, "tiles", registry_filename)
131+
return os.path.join(registry_base_dir, "registry", registry_filename)
132132

133133

134134
def get_all_blocks_in_range(min_lon: float, max_lon: float,

0 commit comments

Comments
 (0)