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

[Train] Add PrintCallback #21261

Merged
merged 15 commits into from
Jan 3, 2022
Merged

Conversation

bveeramani
Copy link
Member

Why are these changes needed?

Related issue number

Closes #20806

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

@bveeramani bveeramani added the train Ray Train Related Issue label Dec 25, 2021
python/ray/train/callbacks/logging.py Outdated Show resolved Hide resolved
python/ray/train/callbacks/logging.py Outdated Show resolved Hide resolved
Copy link
Contributor

@matthewdeng matthewdeng left a comment

Choose a reason for hiding this comment

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

LGTM @amogkam can you merge?

class PrintCallback(TrainingCallback):
"""A callback that prints training results to STDOUT.

Example:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change the example to show usage with Trainer? Users shouldn't be calling handle_result directly, so I think this docstring could be confusing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, we can also take the handle_result example and move it to the handle_result docstring?

python/ray/train/callbacks/print.py Outdated Show resolved Hide resolved
Comment on lines 12 to 18
>>> from ray import train
>>> from ray.train import Trainer
>>> from ray.train.callbacks import PrintCallback

>>> def train_func():
... for i in range(2):
... train.report(worker_idx=train.world_rank(), epoch=i)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Preference on >>> vs. ..code-block formatting? Personally prefer to just be able to copy/paste the example and run it.

Copy link
Contributor

Choose a reason for hiding this comment

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

My reasoning was that the >>> formatting would be easier to show what's actually being printed out. If we do ..code-block then we would have to show the stdout as a comment. But good point on being able to copy paste. I don't really have a strong preference here, so am happy to change it to code block.

doc/source/train/user_guide.rst Outdated Show resolved Hide resolved
@amogkam amogkam merged commit 7efe1be into ray-project:master Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
train Ray Train Related Issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Train] Add PrintingCallback
3 participants