-
-
Notifications
You must be signed in to change notification settings - Fork 718
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
Log event print warn #5220
Log event print warn #5220
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6498,6 +6498,37 @@ def log_scheduler(dask_scheduler): | |
assert events[1][1] == ("alice", "bob") | ||
|
||
|
||
@gen_cluster(client=True) | ||
async def test_log_event_warn(c, s, a, b): | ||
def foo(): | ||
get_worker().log_event(["foo", "warn"], "Hello!") | ||
|
||
with pytest.warns(Warning, match="Hello!"): | ||
await c.submit(foo) | ||
|
||
|
||
@gen_cluster(client=True, Worker=Nanny) | ||
async def test_print(c, s, a, b, capsys): | ||
from dask.distributed import print | ||
|
||
def foo(): | ||
print("Hello!", 123, sep=":") | ||
|
||
await c.submit(foo) | ||
|
||
out, err = capsys.readouterr() | ||
assert "Hello!:123" in out | ||
|
||
|
||
def test_print_simple(capsys): | ||
from dask.distributed import print | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear to me if this from dask.distributed import print as dask_print to not override the builtin There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that we're ok here. I think that imports are properly scoped In [1]: def f():
...: from dask.distributed import print
...:
In [2]: print
Out[2]: <function print>
In [3]: print?
Docstring:
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
Type: builtin_function_or_method There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops, I forgot to call `f() there, but I just did it again and it's fine. |
||
|
||
print("Hello!", 123, sep=":") | ||
|
||
out, err = capsys.readouterr() | ||
assert "Hello!:123" in out | ||
|
||
|
||
@gen_cluster(client=True) | ||
async def test_annotations_task_state(c, s, a, b): | ||
da = pytest.importorskip("dask.array") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case that we're logging the same message under multiple topics (e.g.
name=["model_score", "print"]
) we won't sendprint
orwarn
ops to the client. I'd suggest modifying the logic above to be something along the lines ofThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went the other way, and called
self.log_event(...)
a few times, but I agree that not duplicating the logic twice is a good idea.