Skip to content

Commit c38b0c9

Browse files
authored
fix: improve metpo.Makefile debuggability, document no-prereq rules, guard host-only targets
- Redirect sheets_config.py stderr to a warning log file instead of /dev/null - Add comments explaining intentional no-prerequisites on template fetch rules - Add uv availability check to diff-sheets target - Improve diff-release with explicit uv/git guards and WARN on missing tags - Clarify deprecated.tsv comment and add recovery-only warning to regenerate-deprecated
1 parent 62ad921 commit c38b0c9

1 file changed

Lines changed: 30 additions & 7 deletions

File tree

src/ontology/metpo.Makefile

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,25 @@
1515
# hosts with `pip install pyyaml`, and inside an active uv venv), we
1616
# override the defaults by reading sheets.yaml via
1717
# metpo/sheets_config.py invoked as a script (no package install
18-
# required). The shell command's stderr is swallowed so a missing
19-
# python3 or pyyaml falls through silently to the hardcoded defaults.
18+
# required). The shell command's stderr is redirected to
19+
# $(SHEETS_CONFIG_WARN_LOG) so a missing python3 or pyyaml still falls
20+
# through silently to the hardcoded defaults, but errors are preserved
21+
# for debugging.
2022
#
2123
# If the sheet's GIDs ever change, update both the hardcoded defaults here
2224
# AND sheets.yaml. See docs/google_sheets_template_sync.md.
2325
SPREADSHEET_ID := 1_Lr-9_5QHi8QLvRyTZFSciUhzGKD4DbUObyTpJ16_RU
2426
SRC_URL_MAIN := https://docs.google.com/spreadsheets/d/$(SPREADSHEET_ID)/export?exportFormat=tsv&gid=1569766102
2527
SRC_URL_PROPERTIES := https://docs.google.com/spreadsheets/d/$(SPREADSHEET_ID)/export?exportFormat=tsv&gid=681401984
28+
SHEETS_CONFIG_WARN_LOG := ../templates/sheets_config_warnings.log
29+
$(shell : > $(SHEETS_CONFIG_WARN_LOG))
2630

27-
SRC_URL_MAIN_FROM_YAML := $(shell python3 ../../metpo/sheets_config.py classes 2>/dev/null)
31+
SRC_URL_MAIN_FROM_YAML := $(shell python3 ../../metpo/sheets_config.py classes 2>>$(SHEETS_CONFIG_WARN_LOG))
2832
ifneq ($(SRC_URL_MAIN_FROM_YAML),)
2933
SRC_URL_MAIN := $(SRC_URL_MAIN_FROM_YAML)
3034
endif
3135

32-
SRC_URL_PROPERTIES_FROM_YAML := $(shell python3 ../../metpo/sheets_config.py properties 2>/dev/null)
36+
SRC_URL_PROPERTIES_FROM_YAML := $(shell python3 ../../metpo/sheets_config.py properties 2>>$(SHEETS_CONFIG_WARN_LOG))
3337
ifneq ($(SRC_URL_PROPERTIES_FROM_YAML),)
3438
SRC_URL_PROPERTIES := $(SRC_URL_PROPERTIES_FROM_YAML)
3539
endif
@@ -56,12 +60,18 @@ diff-drafts: ../templates/metpo_sheet.tsv ../templates/metpo-properties.tsv
5660
@diff $(DRAFTS_DIR)/metpo_sheet.tsv ../templates/metpo_sheet.tsv || true
5761
@diff $(DRAFTS_DIR)/metpo-properties.tsv ../templates/metpo-properties.tsv || true
5862

63+
# Intentionally no prerequisites: Make fetches this file only if it is missing.
64+
# This preserves committed/local snapshots by default; run `make squeaky-clean`
65+
# (or delete the file) to force re-download from Google Sheets.
5966
../templates/metpo_sheet.tsv:
6067
curl -L -s "$(SRC_URL_MAIN)" > $@
6168

6269
#../templates/metpo-synonyms.tsv:
6370
# curl -L -s "$(SRC_URL_SYNONYMS)" > $@
6471

72+
# Intentionally no prerequisites: Make fetches this file only if it is missing.
73+
# This preserves committed/local snapshots by default; run `make squeaky-clean`
74+
# (or delete the file) to force re-download from Google Sheets.
6575
../templates/metpo-properties.tsv:
6676
curl -L -s "$(SRC_URL_PROPERTIES)" > $@
6777

@@ -77,11 +87,19 @@ clean-templates:
7787

7888
# Diff current working templates against Google Sheets
7989
diff-sheets:
90+
@command -v uv >/dev/null 2>&1 || { echo "Error: 'uv' is required for diff-sheets. Run this target on a host with uv installed."; exit 1; }
8091
cd ../.. && uv run diff-templates -a gsheet -b HEAD --cell-diffs
8192

8293
# Diff current working templates against the last tagged release
8394
diff-release:
84-
cd ../.. && uv run diff-templates -a $(shell git describe --tags --abbrev=0 2>/dev/null || echo "main") -b HEAD --cell-diffs
95+
@command -v uv >/dev/null 2>&1 || { echo "ERROR: 'uv' is required for diff-release (host-only target)."; exit 1; }
96+
@command -v git >/dev/null 2>&1 || { echo "ERROR: 'git' is required for diff-release."; exit 1; }
97+
@release_ref=$$(git describe --tags --abbrev=0 2>/dev/null); \
98+
if [ -z "$$release_ref" ]; then \
99+
echo "WARN: No git tags found; falling back to 'main'."; \
100+
release_ref=main; \
101+
fi; \
102+
cd ../.. && uv run diff-templates -a "$$release_ref" -b HEAD --cell-diffs
85103

86104
#$(MIRRORDIR)/mpo.owl: ../../assets/mpo_v0.74.en_only.owl
87105
# cp $^ $@
@@ -95,12 +113,17 @@ diff-release:
95113
../templates/stubs.tsv: ../templates/metpo_sheet.tsv ../templates/metpo-properties.tsv ../../metpo/bactotraits/create_stubs.py
96114
python ../../metpo/bactotraits/create_stubs.py -o $@ ../templates/metpo_sheet.tsv ../templates/metpo-properties.tsv
97115

98-
# Generated from historical BioPortal submissions + tagged releases.
99-
# Repo-only — not in Google Sheets. Regenerate with: make -f metpo.Makefile regenerate-deprecated
116+
# Repo-only — not in Google Sheets.
117+
# IMPORTANT: ../templates/deprecated.tsv is hand-maintained source-of-truth.
118+
# The generation rule below exists ONLY as a recovery/bootstrap tool from
119+
# historical BioPortal submissions + tagged releases, and should not be used
120+
# for routine maintenance.
100121
../templates/deprecated.tsv: ../../metpo/scripts/generate_deprecated_template.py
101122
cd ../.. && uv run generate-deprecated-template -o $(abspath $@)
102123

103124
.PHONY: regenerate-deprecated
125+
# WARNING: recovery-only helper. Do not run as part of normal updates; prefer
126+
# manual edits to ../templates/deprecated.tsv.
104127
regenerate-deprecated:
105128
rm -f ../templates/deprecated.tsv
106129
$(MAKE) -f metpo.Makefile ../templates/deprecated.tsv

0 commit comments

Comments
 (0)