Skip to content

Commit b3cf25e

Browse files
committed
fix(review): 6 issues from PR self-review
- completion_gen: fix zsh --gpu completion ('acc:mp' -> 'acc mp') - case_validator: move recon_type prohibit to check_parameter_types (was duplicated 4x) - CMakeLists: remove nonexistent namelist_targets.py stamp watch; add registry.py + schema.py - fortran_gen: guard nl_with_cont[-1] against empty normal list - docs_gen: use .get() for REGISTRY lookups to avoid KeyError on unknown params
1 parent 4901c32 commit b3cf25e

5 files changed

Lines changed: 14 additions & 12 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,9 @@ set(_mfc_gen_stamp "${CMAKE_BINARY_DIR}/mfc_params_gen.stamp")
468468
set(_mfc_gen_inputs
469469
"${CMAKE_CURRENT_SOURCE_DIR}/toolchain/mfc/params/generators/cmake_gen.py"
470470
"${CMAKE_CURRENT_SOURCE_DIR}/toolchain/mfc/params/generators/fortran_gen.py"
471-
"${CMAKE_CURRENT_SOURCE_DIR}/toolchain/mfc/params/namelist_targets.py"
472471
"${CMAKE_CURRENT_SOURCE_DIR}/toolchain/mfc/params/definitions.py"
472+
"${CMAKE_CURRENT_SOURCE_DIR}/toolchain/mfc/params/registry.py"
473+
"${CMAKE_CURRENT_SOURCE_DIR}/toolchain/mfc/params/schema.py"
473474
)
474475
set(_mfc_needs_regen FALSE)
475476
if(NOT EXISTS "${_mfc_gen_stamp}")

toolchain/mfc/case_validator.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,7 @@ def _check_order_fits_grid(self, order: int, param_name: str) -> None:
260260
self.prohibit(p > 0 and p + 1 < order, f"For 3D: p must be at least {param_name} - 1 (= {order - 1})")
261261

262262
def _get_recon_type(self) -> int:
263-
"""Return recon_type after validating it is 1 (WENO) or 2 (MUSCL)."""
264-
recon_type = self.get("recon_type", 1)
265-
self.prohibit(recon_type not in [1, 2], "recon_type must be 1 (WENO) or 2 (MUSCL)")
266-
return recon_type
263+
return self.get("recon_type", 1)
267264

268265
def check_parameter_types(self):
269266
"""Validate parameter types before other checks.
@@ -280,6 +277,8 @@ def check_parameter_types(self):
280277
if param in self.params: # Only validate params that are set
281278
self._validate_logical(param)
282279

280+
self.prohibit(self.get("recon_type", 1) not in [1, 2], "recon_type must be 1 (WENO) or 2 (MUSCL)")
281+
283282
# Required domain parameters when m > 0
284283
m = self.get("m")
285284
if m is not None and m > 0:

toolchain/mfc/cli/completion_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _mfc_config_zsh_flags() -> List[str]:
2828
from ..state import MFCConfig, gpuConfigOptions
2929

3030
specs = []
31-
modes = ":".join(e.value for e in gpuConfigOptions if e.value != gpuConfigOptions.NONE.value)
31+
modes = " ".join(e.value for e in gpuConfigOptions if e.value != gpuConfigOptions.NONE.value)
3232
for f in dataclasses.fields(MFCConfig):
3333
cli = f.name.replace("_", "-")
3434
label = cli.replace("-", " ").title()

toolchain/mfc/params/generators/docs_gen.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,8 @@ def generate_parameter_docs() -> str:
463463
pattern_has_symbols = False
464464
for _pattern, examples in patterns.items():
465465
for ex in examples:
466-
p = REGISTRY.all_params[ex]
467-
if p.constraints or ex in by_trigger or ex in by_param:
466+
p = REGISTRY.all_params.get(ex)
467+
if p and (p.constraints or ex in by_trigger or ex in by_param):
468468
pattern_has_constraints = True
469469
if get_math_symbol(ex):
470470
pattern_has_symbols = True
@@ -484,7 +484,8 @@ def generate_parameter_docs() -> str:
484484

485485
for pattern, examples in sorted(patterns.items()):
486486
example = examples[0]
487-
desc = REGISTRY.all_params[example].description
487+
_ep = REGISTRY.all_params.get(example)
488+
desc = _ep.description if _ep else ""
488489
# Truncate long descriptions
489490
if len(desc) > 60:
490491
desc = desc[:57] + "..."
@@ -497,8 +498,9 @@ def generate_parameter_docs() -> str:
497498
sym = get_math_symbol(example)
498499
row += f" | {sym}"
499500
if pattern_has_constraints:
500-
p = REGISTRY.all_params[example]
501-
row += f" | {_format_constraints_cell(example, p, by_trigger, by_param)}"
501+
p = REGISTRY.all_params.get(example)
502+
if p:
503+
row += f" | {_format_constraints_cell(example, p, by_trigger, by_param)}"
502504
lines.append(row + " |")
503505

504506
lines.append("")

toolchain/mfc/params/generators/fortran_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def generate_namelist_fpp(target: str) -> str:
8787
normal = [v for v in all_vars if v not in CASE_OPT_PARAMS]
8888
opt = sorted(v for v in CASE_OPT_PARAMS if v in NAMELIST_VARS and "sim" in NAMELIST_VARS[v])
8989
nl_lines = _pack_namelist(normal, _FIRST_PREFIX, _CONT_PREFIX, _MAX_LINE)
90-
if opt:
90+
if opt and nl_lines:
9191
opt_lines = _pack_namelist(opt, _CONT_PREFIX, _CONT2_PREFIX, _MAX_LINE)
9292
nl_with_cont = nl_lines[:]
9393
nl_with_cont[-1] += ", &"

0 commit comments

Comments
 (0)