Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration discrimination fails if Pydantic algorithm models are passed #384

Open
jdeschamps opened this issue Jan 30, 2025 · 0 comments
Labels
bug Something isn't working
Milestone

Comments

@jdeschamps
Copy link
Member

Describe the bug

Since a recent PR, passing a configuration as dictionary, albeit with a an algorithm Pydantic model (rather than a dict itself ), will cause an error:

value = {'algorithm_config': N2VAlgorithm(algorithm='n2v', loss='n2v', model=UNetModel(architecture='UNet', conv_dims=2, num_c...e=True, stopping_threshold=None, divergence_threshold=None, check_on_train_epoch_end=False, log_rank_zero_only=False))}

    def _algorithm_config_discriminator(value: Union[dict, Configuration]) -> str:
        """Discriminate algorithm-specific configurations based on the algorithm.
    
        Parameters
        ----------
        value : Any
            Value to discriminate.
    
        Returns
        -------
        str
            Discriminator value.
        """
        if isinstance(value, dict):
>           return value["algorithm_config"]["algorithm"]
E           TypeError: 'N2VAlgorithm' object is not subscriptable

Indeed, we only check for the overall object being a dict, not the algorithm_config. However, it is perfectly legal to pass it as N2VAlgorithmConfig.

This will be superseded and solved by #367.

@jdeschamps jdeschamps added the bug Something isn't working label Jan 30, 2025
@jdeschamps jdeschamps added this to the v0.1.0 milestone Jan 30, 2025
@jdeschamps jdeschamps moved this to Todo in v0.1.0 Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

1 participant