Repository navigation
Support filesystem paths for config_file in build_sam2 / build_sam2_video_predictor - #771
Open
Sanjays2402 wants to merge 1 commit into
Open
Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
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.
build_sam2()andbuild_sam2_video_predictor()passconfig_filestraight to Hydra ascompose(config_name=...), so a filesystem path (e.g. an absolute path to a user-provided config) fails withMissingConfigException-- Hydra resolves config names against its config search path, not arbitrary paths. Reported in #758 (also #531, #701).This PR adds a small
_compose_config()helper used by both builders: ifconfig_fileis an existing filesystem path, its containing directory is temporarily added to Hydra's config search path (via a short-livedConfigStorewrapper primary config, following the approach @omry outlined in #758), and the config is composed from there. That keeps the config's owndefaultslist and relative subconfigs resolving, and the wrapper entry is always removed from theConfigStoreafterwards, even on failure. Plain config names (e.g."configs/sam2.1/sam2.1_hiera_l.yaml") behave exactly as before, as do nonexistent names (stillMissingConfigException).Also documented the
config_filecontract in both builders' docstrings.Fixes #758.
Test evidence (local, hydra-core 1.3.6 / omegaconf 2.3.1, with a stub
sam2package mirroringinitialize_config_module("sam2", version_base="1.2")since torch isn't installed here):configs/sam2.1/sam2.1_hiera_t.yamlcomposes as beforedefaultslist references sibling subconfigs now resolves (previously raisedMissingConfigException-- bug reproduced before the fix)pathlib.Pathinputs work;hydra_overrides_extraoverrides still apply to externally composed configsMissingConfigException(unchanged behavior)_sam2_external_config_*leftovers inConfigStoreafter success or failureblack==24.2.0andusort==1.0.2checks pass (theufmttoolchain from CONTRIBUTING)