From f8c7a4309547c6a402cb00c056e97fe0555cfa8b Mon Sep 17 00:00:00 2001 From: Josh Borrow Date: Wed, 28 Jan 2026 18:29:48 -0500 Subject: [PATCH 1/3] Added functionality to load sources from file --- tilemaker/metadata/generation.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tilemaker/metadata/generation.py b/tilemaker/metadata/generation.py index 91649fd..5567253 100644 --- a/tilemaker/metadata/generation.py +++ b/tilemaker/metadata/generation.py @@ -10,10 +10,11 @@ import structlog from astropy import units from astropy.io import fits -from pydantic import BaseModel +from pydantic import BaseModel, TypeAdapter from tilemaker.metadata.core import DataConfiguration from tilemaker.metadata.definitions import Band, FITSLayerProvider, Layer, Map, MapGroup +from tilemaker.metadata.sources import Source, SourceGroup # Define the hits unit hits = units.def_unit("hits", units.dimensionless_unscaled) @@ -25,14 +26,30 @@ def generate( ) -> DataConfiguration: map_files = [x for x in filenames if "fits" in x.name] map_group = map_group_from_fits(map_files, force_auto_contrast=force_auto_contrast) + source_files = [x for x in filenames if "json" in x.name] + source_groups = [source_group_from_json(x) for x in source_files] - return DataConfiguration(map_groups=[map_group], boxes=[], source_groups=[]) + return DataConfiguration( + map_groups=[map_group], boxes=[], source_groups=source_groups + ) def filename_to_id(filename: str | Path) -> str: return md5(str(filename).encode("utf-8")).hexdigest()[:6] +def source_group_from_json(source_file: Path) -> SourceGroup: + with open(source_file, "r") as handle: + SourceListTypeAdapter = TypeAdapter(list[Source]) + return SourceGroup( + source_group_id=filename_to_id(source_file), + name=source_file.name, + description="Source group read from file", + sources=SourceListTypeAdapter.validate_json(handle.read()), + grant=None, + ) + + def map_group_from_fits( filenames: list[Path], force_auto_contrast: bool = False, From 96b3021ab7710c2abbd63446057c32909f8d13ff Mon Sep 17 00:00:00 2001 From: Josh Borrow Date: Wed, 28 Jan 2026 18:31:01 -0500 Subject: [PATCH 2/3] Docs --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 354924a..835bc71 100644 --- a/README.md +++ b/README.md @@ -488,6 +488,10 @@ called 'extra' that will be rendered in the UI. For example: } ] ``` +Such a list of sources can be loaded using `tilemaker open` by passing the JSON filename, e.g. +``` +tilemaker open my_catalog.json my_map.fits +``` ### Highlight Boxes From 5afc0d907590853129bbcb20a560f017f7bc9021 Mon Sep 17 00:00:00 2001 From: Josh Borrow Date: Wed, 28 Jan 2026 18:31:23 -0500 Subject: [PATCH 3/3] Rev version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9152bb6..826134e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ tilemaker = ["server/static/*", "server/static/assets/*"] [project] name = "tilemaker" -version = "2.3.3" +version = "2.4.0" requires-python = ">=3.11" dependencies = [ "pixell",