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] Better exception handling #23695

Merged
merged 17 commits into from
Apr 6, 2022
Merged

Conversation

krfricke
Copy link
Contributor

@krfricke krfricke commented Apr 4, 2022

Why are these changes needed?

What: Raise meaningful exceptions when invalid parameters are passed.
Why: We want to catch invalid parameters and guide users to use the API in the correct way.

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 :(

"""Returns a PlacementGroupFactory to specify resources for Tune."""
from ray.tune.trainable import PlacementGroupFactory
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Avoid circular imports

Copy link
Contributor

@amogkam amogkam left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

python/ray/ml/trainer.py Outdated Show resolved Hide resolved
from ray.ml.config import RunConfig, ScalingConfig
from ray.ml.preprocessor import Preprocessor

__all__ = ["Checkpoint", "Preprocessor", "RunConfig", "ScalingConfig"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a minor point, but I personally like having users do fully qualified package imports instead of putting things into the ray.ml parent package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we may want to discuss this sometime - I think for the main concepts we can move them to the parent package as they will be used often. We shouldn't do this e.g. for trainer implementations

Comment on lines +215 to +217
def _validate_attributes(self):
super()._validate_attributes()

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, otherwise the parent classes validation is not executed

Copy link
Contributor

@amogkam amogkam Apr 5, 2022

Choose a reason for hiding this comment

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

Hmm if we're only calling just the super class method, then it doesn't seem necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't get it - we're doing more validation under the super call?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like in lines 218ff

Copy link
Contributor

Choose a reason for hiding this comment

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

Ohh I see, sorry that didn't show up in the diff. Yes you're right, there's more validation being done below

python/ray/ml/trainer.py Outdated Show resolved Hide resolved
@krfricke
Copy link
Contributor Author

krfricke commented Apr 5, 2022

@matthewdeng I've removed the custom exceptions for now, we should probably have a discussion on how to introduce these, first.

Comment on lines +215 to +217
def _validate_attributes(self):
super()._validate_attributes()

Copy link
Contributor

Choose a reason for hiding this comment

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

Ohh I see, sorry that didn't show up in the diff. Yes you're right, there's more validation being done below

@krfricke krfricke merged commit fb50e0a into ray-project:master Apr 6, 2022
@krfricke krfricke deleted the air/exceptions branch April 6, 2022 02:11
krfricke added a commit that referenced this pull request Apr 6, 2022
krfricke added a commit that referenced this pull request Apr 6, 2022
krfricke added a commit that referenced this pull request Apr 6, 2022
edoakes pushed a commit to edoakes/ray that referenced this pull request Apr 7, 2022
What: Raise meaningful exceptions when invalid parameters are passed.
Why: We want to catch invalid parameters and guide users to use the API in the correct way.
edoakes pushed a commit to edoakes/ray that referenced this pull request Apr 7, 2022
@richardliaw richardliaw added this to the Ray AIR milestone Apr 8, 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.

None yet

4 participants