Repository navigation
[Fix] Pass config keys through to dataset classes that forward **kwargs - #1684
Closed
reinainblood wants to merge 1 commit into
Closed
reinainblood wants to merge 1 commit into
reinainblood wants to merge 1 commit into
Conversation
build_dataset_from_config filtered the config keys against
inspect.signature(cls.__init__). A dataset class whose __init__ is
`(self, **kwargs)` and forwards to its parent therefore exposed no named
parameters, so every key was dropped: `{"class": "MMMUProDataset",
"dataset": "MMMU_Pro_10c"}` built the default dataset instead, and with
`strict=True` it raised "Unsupported parameter(s) ... dataset". Seven
dataset classes have a **kwargs-only __init__ and about thirty more forward
**kwargs after their own parameters, losing keys such as skip_noimg, nframe
and fps.
Collect the accepted parameters by walking the __init__ chain through the
MRO until an __init__ that does not take **kwargs, and filter against that
set. Classes whose __init__ names every parameter behave exactly as before.
Fixes open-compass#1185
Co-Authored-By: Claude <[email protected]>
Collaborator
|
Thank you for your contribution. This problem has been resolved in #1622 |
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.
Fixes #1185
Problem
build_dataset_from_configinrun.pykeeps only the config keys that appear ininspect.signature(cls.__init__).MMMUProDataset.__init__is(self, **kwargs)and forwards toMMMUDataset, so its signature names no parameters and every key in the config is dropped. The config from the issue builds the defaultMMBench-named dataset instead ofMMMU_Pro_10c, and with--strict(thestrict=Truepath added in #1573) it raisesUnsupported parameter(s) for dataset class MMMUProDataset: dataset.Scanning
vlmeval/dataset, seven classes have a**kwargs-only__init__(MMMUProDataset,VLADBench,VLRMBench,Spatial457,ERQADataset,SiteBenchBase,RefCOCODataset) and about thirty more name one or two parameters and forward the rest, so keys likeskip_noimg,nframeandfpsare silently lost for those too. For a video class that forwardsfps/nframethis turns into the "fps and nframe should be set at least one valid value" error even when the config sets one.Change
run.py: a small helper_accepted_init_params(cls)walkscls.__mro__, collecting the named parameters of each__init__and stopping at the first one that does not take**kwargs.build_dataset_from_configfilters (and, in strict mode, validates) against that set instead of the leaf signature. Classes whose__init__names all their parameters get exactly the same set as before.tests/test_dataset_config.py: unit tests for the helper on three constructor shapes, and forbuild_dataset_from_configwith a**kwargs-forwarding class in both lenient and strict mode.Verification
Probe with the issue's config (constructor replaced by one that records its kwargs, so nothing downloads):
python -m unittest tests.test_dataset_config: 5 pass on this branch, 1 failure and 4 errors onmain.pre-commit run --files run.py tests/test_dataset_config.pyis clean. I do not have a GPU here, so I did not run an end-to-endrun.py --configevaluation.Disclosure
Drafted by Claude from the Hive Fidelity Usage-Surplus OSS Program. All code reviewed by a human prior to submission. To request us back for more, email [email protected] or [email protected]. Usage-Surplus OSS Program