feat: configurable case directory naming (case_naming), thread-safe signal handling - #78
Merged
Conversation
…ignal handling
fzr() gains a case_naming option ("path" default, "hash", "index") to avoid
exceeding filesystem filename length limits when many input variables are
used (var1=val1,var2=val2,... can exceed ~255 chars). With "hash"/"index",
a single cases.csv manifest is written at the results root mapping each
case directory to its variables; fzo() reads it back (falling back to each
case's own info.txt) when directory names don't parse as "key=val,...".
fzd() now runs its internal per-iteration fzr() calls with case_naming="index"
by default, since algorithm-generated design points can carry many variables
with long float values; cache:// matching is unaffected since it's based on
.fz_hash content, not directory names.
Also fixes fzr/fzd installing a SIGINT handler unconditionally, which raised
ValueError when called from a non-main thread (Streamlit reruns, a
ThreadPoolExecutor worker, or any background thread embedding fz).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Windows CI failed: the test built expected paths with a hardcoded "/" separator, which doesn't match fzr's native "\" paths on Windows. Compare directory basenames via Path instead. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fzr()gains acase_namingparameter (CLI--case_naming, envFZ_CASE_NAMING):"path"(default, unchangedvar1=val1,var2=val2,...subdirectories),"hash"(short content hash of the variable combination), or"index"(case_<i>)."path"can exceed filesystem filename length limits (~255 chars) with many input variables;"hash"/"index"avoid that."hash"/"index", a singlecases.csvmanifest is written at the results root mapping each case directory to its variables.fzo()reads it back (falling back to each case's owninfo.txt, which always hasinput.<var>=<value>lines) when a directory name doesn't parse askey=val,....fzd()now runs its internal per-iterationfzr()calls (file-based models) withcase_naming="index"by default, since algorithm-generated design points can carry many variables with long float values.cache://matching is by.fz_hashcontent, not directory name, so cross-iteration cache reuse is unaffected.fzr/fzdinstalled aSIGINThandler unconditionally, which raisesValueErrorwhen called from a non-main thread (e.g. Streamlit reruns, aThreadPoolExecutorworker, or a background thread embedding fz). Signal handler install/restore is now skipped outside the main thread instead of raising.Test plan
tests/test_case_naming.py(6 tests):path/hash/indexnaming,cases.csvmanifest content,fzofallback toinfo.txtwhen the manifest is missing, invalidcase_namingvalidation,FZ_CASE_NAMINGenv var default.tests/test_skill_static.pyupdated (scoped a too-broadchoices=[...]regex to--formatspecifically) and passing.pythonvspython3PATH issue intest_debug_execution.py, reproduced on unmodifiedmain), 82 skipped.fzr/fzoround-trip forhash/indexnaming, including after a cache-hit (fzd-like iteration reuse), and the no-variables case.🤖 Generated with Claude Code