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

Add non_zero to common_fields.NumFCLayersField #3215

Merged
merged 4 commits into from
Mar 7, 2023

Conversation

abidwael
Copy link
Contributor

@abidwael abidwael commented Mar 7, 2023

A dense encoder with 0 num_layers doesn't make sense. This PR adds the option for specifying a non_zero argument in common_fields.NumFCLayersField.

@@ -11,6 +11,7 @@
from typing import Any, Dict, Optional

import pytest
from marshmallow import ValidationError
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to just use ConfigValidationError

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It fails with the marshmallow ValidationError

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's strange. The code should be wrapping it in a ConfigValidationError. CC @justinxzhao

Copy link
Collaborator

@ksbrar ksbrar Mar 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually glancing through the code we manually raise a ValidationError in quite a few locations. (Worth a separate refactoring/investigation.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConfigValidationError is only raised at the ModelConfig level.

Copy link
Collaborator

@ksbrar ksbrar Mar 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but ideally this is an error that should bubble up and either be caught and wrapped by:

Am I missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed it might be good to clarify some of our semantics about ConfigValidationError vs. ValidationError from marshmallow, perhaps moving all Ludwig-specific validation code to ConfigValidationError.

@abidwael It would be good to understand how the test gets through raises a marshmallow ValidationError. Perhaps it's because we don't except it in this block.

Otherwise, LGTM.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah @justinxzhao thanks for the link, I totally missed that <imblind.gif>

ludwig/schema/common_fields.py Show resolved Hide resolved
ludwig/schema/common_fields.py Show resolved Hide resolved
@@ -11,6 +11,7 @@
from typing import Any, Dict, Optional

import pytest
from marshmallow import ValidationError
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed it might be good to clarify some of our semantics about ConfigValidationError vs. ValidationError from marshmallow, perhaps moving all Ludwig-specific validation code to ConfigValidationError.

@abidwael It would be good to understand how the test gets through raises a marshmallow ValidationError. Perhaps it's because we don't except it in this block.

Otherwise, LGTM.

@abidwael abidwael merged commit 938d0bf into master Mar 7, 2023
@abidwael abidwael deleted the binary-output-out-of-range branch March 7, 2023 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants