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

[AIR] Refactor ScalingConfig key validation #25549

Merged
merged 8 commits into from
Jun 13, 2022

Conversation

JiahaoYao
Copy link
Contributor

@JiahaoYao JiahaoYao commented Jun 7, 2022

Follow another approach mentioned in #25350.

The scaling config is now converted to the dataclass letting us use a single function for validation of both user supplied dicts and dataclasses. This PR also fixes the fact the scaling config wasn't validated in the GBDT Trainer and validates that allowed keys set in Trainers are present in the dataclass.

Why are these changes needed?

Related issue number

Checks

  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@JiahaoYao
Copy link
Contributor Author

@Yard1 could u please take a look?

@Yard1 Yard1 changed the title restruct #25350 [AIR] Refactor ScalingConfig key validation Jun 7, 2022
@Yard1 Yard1 self-requested a review June 7, 2022 15:37
@Yard1 Yard1 self-assigned this Jun 7, 2022
@Yard1 Yard1 requested review from amogkam and matthewdeng June 7, 2022 15:37
Copy link
Member

@Yard1 Yard1 left a comment

Choose a reason for hiding this comment

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

Looks good to me! I added an extra validation step and removed the now unused function, PTAL @JiahaoYao

@Yard1
Copy link
Member

Yard1 commented Jun 7, 2022

Also enabled validation for the GBDT trainer which didn't have it in the first place!

@richardliaw richardliaw added this to the Ray AIR milestone Jun 8, 2022
Comment on lines +22 to +29
keys_not_in_dict = [key for key in allowed_keys if key not in default_data.__dict__]
if keys_not_in_dict:
raise ValueError(
f"Key(s) {keys_not_in_dict} are not present in "
f"{dataclass.__class__.__name__}. "
"Remove them from `allowed_keys`. "
f"Valid keys: {list(default_data.__dict__.keys())}"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Somehow this feels weird to me, as this is meant to be for the developer rather than the end user. I.e. if we check in a Trainer that fails here this isn't really actionable for the user.

Is this more suitable to be added in tests instead?

Copy link
Member

@Yard1 Yard1 Jun 9, 2022

Choose a reason for hiding this comment

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

Well, this will fail in the tests. There is no chance a user will see this error, unless they develop their own trainer (in which case that's actually good IMO. Makes it harder to shoot yourself in the foot).

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah sounds reasonable. Can we update method name/docs?

Longer term maybe we should split this logic out so that we have one validation step for the Trainer definition (developer), and one for the instantiation (end user).

Copy link
Member

Choose a reason for hiding this comment

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

@matthewdeng done, ptal

@Yard1 Yard1 requested a review from matthewdeng June 9, 2022 21:02
@Yard1 Yard1 requested a review from matthewdeng June 9, 2022 21:09
@krfricke krfricke merged commit 7bb142e into ray-project:master Jun 13, 2022
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.

6 participants