Skip to content

Commit a2ed3b9

Browse files
CopilotturbomamCopilot
authored
fix(metpo.Makefile): improve debuggability, document no-prereq rules, guard host-only targets (#544)
* Initial plan * 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 * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Mark Andrew Miller <MAM@lbl.gov> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 074e563 commit a2ed3b9

1 file changed

Lines changed: 31 additions & 7 deletions

File tree

src/ontology/metpo.Makefile

Lines changed: 31 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,20 @@ 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+
@git rev-parse --is-inside-work-tree >/dev/null 2>&1 || { echo "ERROR: diff-release must be run from within a git work tree."; exit 1; }
98+
@release_ref=$$(git describe --tags --abbrev=0 2>/dev/null); \
99+
if [ -z "$$release_ref" ]; then \
100+
echo "WARN: No git tags found; falling back to 'main'."; \
101+
release_ref=main; \
102+
fi; \
103+
cd ../.. && uv run diff-templates -a "$$release_ref" -b HEAD --cell-diffs
85104

86105
#$(MIRRORDIR)/mpo.owl: ../../assets/mpo_v0.74.en_only.owl
87106
# cp $^ $@
@@ -95,12 +114,17 @@ diff-release:
95114
../templates/stubs.tsv: ../templates/metpo_sheet.tsv ../templates/metpo-properties.tsv ../../metpo/bactotraits/create_stubs.py
96115
python ../../metpo/bactotraits/create_stubs.py -o $@ ../templates/metpo_sheet.tsv ../templates/metpo-properties.tsv
97116

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

103125
.PHONY: regenerate-deprecated
126+
# WARNING: recovery-only helper. Do not run as part of normal updates; prefer
127+
# manual edits to ../templates/deprecated.tsv.
104128
regenerate-deprecated:
105129
rm -f ../templates/deprecated.tsv
106130
$(MAKE) -f metpo.Makefile ../templates/deprecated.tsv

0 commit comments

Comments
 (0)