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

Manage asyncio loop creation manually #7591

Merged
merged 35 commits into from
Jan 7, 2025
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e60c1fc
Manage asyncio loop creation manually
philippjfr Jan 6, 2025
95921e2
Handle async task scheduling manually
philippjfr Jan 6, 2025
40c8f72
Small fixes
philippjfr Jan 6, 2025
2bb86d9
Do not use async tests for threaded executions
philippjfr Jan 6, 2025
559f058
Do not set up global event loop
philippjfr Jan 6, 2025
de6bef1
Update async tests consistently
philippjfr Jan 6, 2025
4096d4a
Declare async tests
philippjfr Jan 6, 2025
a1c8af3
Ensure an event loop is set
philippjfr Jan 6, 2025
2682b26
More async tests
philippjfr Jan 6, 2025
44fee87
More changes
philippjfr Jan 6, 2025
821f9ef
Fix all async chat tests
philippjfr Jan 6, 2025
e23a297
Do not create Tornado IOLoop
philippjfr Jan 6, 2025
36977ce
Fix test
philippjfr Jan 6, 2025
76ed9d4
Small adjustments
philippjfr Jan 6, 2025
f620db9
Cleanup thread pool for ioloops
philippjfr Jan 6, 2025
3442e8d
Ensure streamz event loop gets shut down
philippjfr Jan 6, 2025
85d1ada
Revert changes to async_execute
philippjfr Jan 6, 2025
0e3c9a4
Make doc tests async
philippjfr Jan 6, 2025
6caabf9
Re-enable test
philippjfr Jan 6, 2025
bd21e64
fix types
philippjfr Jan 6, 2025
93ad2fc
Remove loop creation and cleanup
philippjfr Jan 7, 2025
933273c
Fixes
philippjfr Jan 7, 2025
9dabd29
Disable autouse on asyncio_loop
philippjfr Jan 7, 2025
78aaa36
Do not reuse ioloop
philippjfr Jan 7, 2025
bc4586a
Explicit asyncio loop for subprocess tests
philippjfr Jan 7, 2025
89fc247
Avoid creating Tornado IOLoop again
philippjfr Jan 7, 2025
50af057
Minor fixes
philippjfr Jan 7, 2025
e16a019
Updates to jupyterlite pins
philippjfr Jan 7, 2025
55c6a28
Bump lock version
philippjfr Jan 7, 2025
51a106d
Fix pins
philippjfr Jan 7, 2025
fda7cfd
Do not use custom bokeh wheel for now
philippjfr Jan 7, 2025
32ba68e
Do not piggyback on Tornado event loop for periodic callbacks
philippjfr Jan 7, 2025
ae6a11b
Make tests more robust
philippjfr Jan 7, 2025
62e3564
Use async test instead of explicit loop
philippjfr Jan 7, 2025
35ff450
Fix PeriodicCallback.stop()
philippjfr Jan 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More async tests
  • Loading branch information
philippjfr committed Jan 6, 2025
commit 2682b263cf2e15ef53d672dec445bf474c957fff
42 changes: 20 additions & 22 deletions panel/tests/chat/test_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
raise ValueError("Testing")
assert "Traceback" in step.objects[0].object

def test_add_step_last_messages(self, chat_feed):
async def test_add_step_last_messages(self, chat_feed):
# create steps
with chat_feed.add_step("Object 1", title="Step 1"):
assert len(chat_feed) == 1
Expand Down Expand Up @@ -338,7 +338,7 @@
message = chat_feed.stream(
"Streaming with user and avatar", user=user, avatar=avatar
)
assert message.user == user

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-core:ubuntu-latest

TestChatFeed.test_stream pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-core/lib/python3.13/site-packages/param/depends.py", line 92, in depends elif hasattr(dep, '_dinfo'): ~~~~~~~^^^^^^^^^^^^^^^ ResourceWarning: unclosed <socket.socket fd=16, family=1, type=1, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-core:ubuntu-latest

TestChatFeedCallback.test_return_chat_message[C-None] pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-core/lib/python3.13/contextlib.py", line 141, in __enter__ return next(self.gen) ResourceWarning: unclosed <socket.socket fd=187, family=1, type=1, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-core:ubuntu-latest

TestChatFeedCallback.test_renderers_widget pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-core/lib/python3.13/site-packages/param/parameterized.py", line 4317, in __init__ self._param__private = _InstancePrivate( ~~~~~~~~~~~~~~~~^ explicit_no_refs=type(self)._param__private.explicit_no_refs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ) ^ ResourceWarning: unclosed <socket.socket fd=235, family=1, type=1, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-core:ubuntu-latest

TestChatFeedSerializeForTransformers.test_role_names pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-core/lib/python3.13/site-packages/param/depends.py", line 64, in <genexpr> tuple(transform_reference(arg) for arg in dependencies), ResourceWarning: unclosed <socket.socket fd=331, family=1, type=1, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-core:ubuntu-latest

TestChatFeedPostHook.test_stream pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-core/lib/python3.13/site-packages/param/reactive.py", line 728, in __init__ for k, o in opts.items(): ~~~~~~~~~~^^ ResourceWarning: unclosed <socket.socket fd=346, family=1, type=1, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-minimum:ubuntu-latest

TestChatFeed.test_add_step_explict_not_append pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-minimum/lib/python3.10/site-packages/param/parameterized.py", line 885, in __new__ values = dict(zip(cls_._fields, args)) ResourceWarning: unclosed <socket.socket fd=31, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-minimum:ubuntu-latest

TestChatFeed.test_stream_message pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-minimum/lib/python3.10/functools.py", line 58, in update_wrapper getattr(wrapper, attr).update(getattr(wrapped, attr, {})) ResourceWarning: unclosed <socket.socket fd=49, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-minimum:ubuntu-latest

TestChatFeedCallback.test_callback_mix_positional_argument pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-minimum/lib/python3.10/site-packages/param/parameterized.py", line 885, in __new__ values = dict(zip(cls_._fields, args)) ResourceWarning: unclosed <socket.socket fd=280, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-minimum:ubuntu-latest

TestChatFeedSerializeForTransformers.test_default_role pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-minimum/lib/python3.10/site-packages/param/parameterized.py", line 1408, in __getattribute__ v = object.__getattribute__(self, key) ResourceWarning: unclosed <socket.socket fd=337, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-minimum:ubuntu-latest

TestChatFeedSerializeForTransformers.test_serialize_kwargs pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-minimum/lib/python3.10/site-packages/param/parameterized.py", line 1736, in is_equal for t in gen(): ResourceWarning: unclosed <socket.socket fd=337, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:ubuntu-latest

TestChatFeed.test_width_message_offset_80 pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-310/lib/python3.10/site-packages/param/reactive.py", line 1051, in __getattribute__ self_dict = super().__getattribute__('__dict__') ResourceWarning: unclosed <socket.socket fd=55, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:ubuntu-latest

TestChatFeed.test_forward_message_params pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/panel/pane/base.py", line 155, in __init__ super().__init__(object=object, **params) ResourceWarning: unclosed <socket.socket fd=193, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:ubuntu-latest

TestChatFeedCallback.test_callback_stop_async_function pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-310/lib/python3.10/site-packages/param/_utils.py", line 287, in _f return lambda actual_f: f(actual_f, *args, **kwargs) ResourceWarning: unclosed <socket.socket fd=247, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:ubuntu-latest

TestChatFeedSerializeForTransformers.test_default_role pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-310/lib/python3.10/site-packages/param/parameterized.py", line 3074, in _register_watcher getattr(watchers[parameter_name][what], action)(watcher) ResourceWarning: unclosed <socket.socket fd=349, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:ubuntu-latest

TestChatFeedPostHook.test_generator pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-310/lib/python3.10/site-packages/param/parameterized.py", line 143, in transform_reference if isinstance(arg, Parameter) or hasattr(arg, '_dinfo'): ResourceWarning: unclosed <socket.socket fd=193, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:macos-latest

TestChatFeed.test_set_entries pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/Users/runner/work/panel/panel/.pixi/envs/test-310/lib/python3.10/site-packages/param/parameterized.py", line 1408, in __getattribute__ v = object.__getattribute__(self, key) ResourceWarning: unclosed <socket.socket fd=18, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:macos-latest

TestChatFeedCallback.test_yield pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/Users/runner/work/panel/panel/.pixi/envs/test-310/lib/python3.10/site-packages/param/parameterized.py", line 2853, in get_value_generator param_obj = cls_or_slf.param.objects('existing').get(name) ResourceWarning: unclosed <socket.socket fd=201, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:macos-latest

TestChatFeedCallback.test_callback_stop_async_generator pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/Users/runner/work/panel/panel/.pixi/envs/test-310/lib/python3.10/site-packages/param/parameterized.py", line 2523, in objects return dict(pdict, **self_.self._param__private.params) ResourceWarning: unclosed <socket.socket fd=249, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:macos-latest

TestChatFeedSerializeForTransformers.test_default_role pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0> Traceback (most recent call last): File "/Users/runner/work/panel/panel/.pixi/envs/test-310/lib/python3.10/site-packages/param/parameterized.py", line 3074, in _register_watcher getattr(watchers[parameter_name][what], action)(watcher) ResourceWarning: unclosed <socket.socket fd=351, family=AddressFamily.AF_UNIX, type=SocketKind.SOCK_STREAM, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:macos-latest

TestChatFeed.test_add_step pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0> Traceback (most recent call last): File "/Users/runner/work/panel/panel/.pixi/envs/test-312/lib/python3.12/site-packages/param/parameterized.py", line 2859, in get_value_generator elif hasattr(param_obj,'attribs'): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ResourceWarning: unclosed <socket.socket fd=33, family=1, type=1, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:macos-latest

TestChatFeedCallback.test_callback_stop_generator pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0> Traceback (most recent call last): File "/Users/runner/work/panel/panel/.pixi/envs/test-312/lib/python3.12/site-packages/param/parameterized.py", line 4317, in __init__ self._param__private = _InstancePrivate( ^^^^^^^^^^^^^^^^^ ResourceWarning: unclosed <socket.socket fd=240, family=1, type=1, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:macos-latest

TestChatFeedSerializeForTransformers.test_case_insensitivity pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0> Traceback (most recent call last): File "/Users/runner/work/panel/panel/.pixi/envs/test-312/lib/python3.12/site-packages/param/parameterized.py", line 1999, in _setup_refs refnames, pnames = zip(*pnames) ^^^^^^^^^^^^ ResourceWarning: unclosed <socket.socket fd=342, family=1, type=1, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:ubuntu-latest

TestChatFeed.test_add_step_last_messages pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-312/lib/python3.12/site-packages/param/parameterized.py", line 1805, in __init__ def __init__(self_, cls, self=None): ResourceWarning: unclosed <socket.socket fd=31, family=1, type=1, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:ubuntu-latest

TestChatFeed.test_layout_parameters_are_propogated_to_card[width-101] pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-312/lib/python3.12/site-packages/param/depends.py", line 87, in depends deps = list(dependencies)+list(kw.values()) ^^^^^^^^^^^^^^^^^ ResourceWarning: unclosed <socket.socket fd=16, family=1, type=1, proto=0>

Check failure on line 341 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:ubuntu-latest

TestChatFeedCallback.test_yield_chat_message[None-Bob] pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=1, type=1, proto=0> Traceback (most recent call last): File "/home/runner/work/panel/panel/.pixi/envs/test-312/lib/python3.12/site-packages/param/parameterized.py", line 2859, in get_value_generator elif hasattr(param_obj,'attribs'): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ResourceWarning: unclosed <socket.socket fd=202, family=1, type=1, proto=0>
assert message.avatar == avatar

def test_stream_dict(self, chat_feed):
Expand Down Expand Up @@ -838,7 +838,7 @@
chat_feed.callback = echo
chat_feed.send("Message", respond=True)
await async_wait_until(lambda: len(chat_feed.objects) == 2)
assert chat_feed.objects[1].object == "Message"
await async_wait_until(lambda: chat_feed.objects[1].object == "Message")

@pytest.mark.parametrize("callback_user", [None, "Bob"])
@pytest.mark.parametrize("callback_avatar", [None, "C"])
Expand Down Expand Up @@ -886,8 +886,7 @@
chat_feed.callback = echo
chat_feed.send("Message", respond=True)
await async_wait_until(lambda: len(chat_feed.objects) == 2)
assert len(chat_feed.objects) == 2
assert chat_feed.objects[1].object == "Message"
await async_wait_until(lambda: chat_feed.objects[1].object == "Message")

async def test_generator(self, chat_feed):
def echo(contents, user, instance):
Expand All @@ -900,8 +899,7 @@
chat_feed.callback = echo
chat_feed.send("Message", respond=True)
await async_wait_until(lambda: len(chat_feed.objects) == 2)
assert len(chat_feed.objects) == 2
assert chat_feed.objects[1].object == "Message"
await async_wait_until(lambda: chat_feed.objects[1].object == "Message")
assert not chat_feed.objects[-1].show_activity_dot

@pytest.mark.parametrize("key", ["value", "object"])
Expand Down Expand Up @@ -1323,7 +1321,7 @@
@pytest.mark.xdist_group("chat")
class TestChatFeedSerializeForTransformers:

def test_defaults(self):
async def test_defaults(self):
chat_feed = ChatFeed()
chat_feed.send("I'm a user", user="user")
chat_feed.send("I'm the assistant", user="assistant")
Expand All @@ -1338,7 +1336,7 @@
chat_feed = ChatFeed()
assert chat_feed.serialize() == []

def test_case_insensitivity(self):
async def test_case_insensitivity(self):
chat_feed = ChatFeed()
chat_feed.send("I'm a user", user="USER")
chat_feed.send("I'm the assistant", user="ASSISTant")
Expand All @@ -1349,7 +1347,7 @@
{"role": "assistant", "content": "I'm a bot"},
]

def test_default_role(self):
async def test_default_role(self):
chat_feed = ChatFeed()
chat_feed.send("I'm a user", user="user")
chat_feed.send("I'm the assistant", user="assistant")
Expand All @@ -1360,7 +1358,7 @@
{"role": "system", "content": "I'm a bot"},
]

def test_empty_default_role(self):
async def test_empty_default_role(self):
chat_feed = ChatFeed()
chat_feed.send("I'm a user", user="user")
chat_feed.send("I'm the assistant", user="assistant")
Expand All @@ -1380,7 +1378,7 @@
{"role": "assistant", "content": "I'm the assistant"},
]

def test_custom_serializer(self):
async def test_custom_serializer(self):
def custom_serializer(obj):
if isinstance(obj, str):
return "new string"
Expand All @@ -1395,7 +1393,7 @@
{"role": "assistant", "content": "0"},
]

def test_custom_serializer_invalid_output(self):
async def test_custom_serializer_invalid_output(self):
def custom_serializer(obj):
if isinstance(obj, str):
return "new string"
Expand All @@ -1408,7 +1406,7 @@
with pytest.raises(ValueError, match="must return a string"):
chat_feed.serialize(custom_serializer=custom_serializer)

def test_serialize_filter_by(self, chat_feed):
async def test_serialize_filter_by(self, chat_feed):
def filter_by_reactions(messages):
return [obj for obj in messages if "favorite" in obj.reactions]

Expand All @@ -1418,7 +1416,7 @@
assert len(filtered) == 1
assert filtered[0]["content"] == "yes"

def test_serialize_exclude_users_default(self):
async def test_serialize_exclude_users_default(self):
def say_hi(contents, user, instance):
return f"Hi {user}!"

Expand All @@ -1427,12 +1425,12 @@
callback=say_hi
)
chat_feed.send("Hello there!")
assert chat_feed.serialize() == [

Check failure on line 1428 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-core:ubuntu-latest

TestChatFeedSerializeForTransformers.test_serialize_exclude_users_default AssertionError: assert [{'content': ...ole': 'user'}] == [{'content': ... 'assistant'}] Right contains one more item: {'content': 'Hi User!', 'role': 'assistant'} Full diff: [ { 'content': 'Hello there!', 'role': 'user', }, - { - 'content': 'Hi User!', - 'role': 'assistant', - }, ]

Check failure on line 1428 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-minimum:ubuntu-latest

TestChatFeedSerializeForTransformers.test_serialize_exclude_users_default AssertionError: assert [{'content': ...ole': 'user'}] == [{'content': ... 'assistant'}] Right contains one more item: {'content': 'Hi User!', 'role': 'assistant'} Full diff: [ { 'content': 'Hello there!', 'role': 'user', }, - { - 'content': 'Hi User!', - 'role': 'assistant', - }, ]

Check failure on line 1428 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:ubuntu-latest

TestChatFeedSerializeForTransformers.test_serialize_exclude_users_default AssertionError: assert [{'content': ...ole': 'user'}] == [{'content': ... 'assistant'}] Right contains one more item: {'content': 'Hi User!', 'role': 'assistant'} Full diff: [ { 'content': 'Hello there!', 'role': 'user', }, - { - 'content': 'Hi User!', - 'role': 'assistant', - }, ]

Check failure on line 1428 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:macos-latest

TestChatFeedSerializeForTransformers.test_serialize_exclude_users_default AssertionError: assert [{'content': ...ole': 'user'}] == [{'content': ... 'assistant'}] Right contains one more item: {'content': 'Hi User!', 'role': 'assistant'} Full diff: [ { 'content': 'Hello there!', 'role': 'user', }, - { - 'content': 'Hi User!', - 'role': 'assistant', - }, ]

Check failure on line 1428 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:macos-latest

TestChatFeedSerializeForTransformers.test_serialize_exclude_users_default AssertionError: assert [{'content': ...ole': 'user'}] == [{'content': ... 'assistant'}] Right contains one more item: {'content': 'Hi User!', 'role': 'assistant'} Full diff: [ { 'content': 'Hello there!', 'role': 'user', }, - { - 'content': 'Hi User!', - 'role': 'assistant', - }, ]

Check failure on line 1428 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:ubuntu-latest

TestChatFeedSerializeForTransformers.test_serialize_exclude_users_default AssertionError: assert [{'content': ...ole': 'user'}] == [{'content': ... 'assistant'}] Right contains one more item: {'content': 'Hi User!', 'role': 'assistant'} Full diff: [ { 'content': 'Hello there!', 'role': 'user', }, - { - 'content': 'Hi User!', - 'role': 'assistant', - }, ]
{"role": "user", "content": "Hello there!"},
{"role": "assistant", "content": "Hi User!"}
]

def test_serialize_exclude_users_custom(self):
async def test_serialize_exclude_users_custom(self):
def say_hi(contents, user, instance):
return f"Hi {user}!"

Expand All @@ -1446,7 +1444,7 @@
{"role": "user", "content": "Hello there!"},
]

def test_serialize_exclude_placeholder(self):
async def test_serialize_exclude_placeholder(self):
def say_hi(contents, user, instance):
assert len(instance.serialize()) == 1
return f"Hi {user}!"
Expand All @@ -1457,12 +1455,12 @@
)

chat_feed.send("Hello there!")
assert chat_feed.serialize() == [

Check failure on line 1458 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-core:ubuntu-latest

TestChatFeedSerializeForTransformers.test_serialize_exclude_placeholder AssertionError: assert [{'content': ...ole': 'user'}] == [{'content': ... 'assistant'}] Right contains one more item: {'content': 'Hi User!', 'role': 'assistant'} Full diff: [ { 'content': 'Hello there!', 'role': 'user', }, - { - 'content': 'Hi User!', - 'role': 'assistant', - }, ]

Check failure on line 1458 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-minimum:ubuntu-latest

TestChatFeedSerializeForTransformers.test_serialize_exclude_placeholder AssertionError: assert [{'content': ...ole': 'user'}] == [{'content': ... 'assistant'}] Right contains one more item: {'content': 'Hi User!', 'role': 'assistant'} Full diff: [ { 'content': 'Hello there!', 'role': 'user', }, - { - 'content': 'Hi User!', - 'role': 'assistant', - }, ]

Check failure on line 1458 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:ubuntu-latest

TestChatFeedSerializeForTransformers.test_serialize_exclude_placeholder AssertionError: assert [{'content': ...ole': 'user'}] == [{'content': ... 'assistant'}] Right contains one more item: {'content': 'Hi User!', 'role': 'assistant'} Full diff: [ { 'content': 'Hello there!', 'role': 'user', }, - { - 'content': 'Hi User!', - 'role': 'assistant', - }, ]

Check failure on line 1458 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:macos-latest

TestChatFeedSerializeForTransformers.test_serialize_exclude_placeholder AssertionError: assert [{'content': ...ole': 'user'}] == [{'content': ... 'assistant'}] Right contains one more item: {'content': 'Hi User!', 'role': 'assistant'} Full diff: [ { 'content': 'Hello there!', 'role': 'user', }, - { - 'content': 'Hi User!', - 'role': 'assistant', - }, ]

Check failure on line 1458 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:macos-latest

TestChatFeedSerializeForTransformers.test_serialize_exclude_placeholder AssertionError: assert [{'content': ...ole': 'user'}] == [{'content': ... 'assistant'}] Right contains one more item: {'content': 'Hi User!', 'role': 'assistant'} Full diff: [ { 'content': 'Hello there!', 'role': 'user', }, - { - 'content': 'Hi User!', - 'role': 'assistant', - }, ]

Check failure on line 1458 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:ubuntu-latest

TestChatFeedSerializeForTransformers.test_serialize_exclude_placeholder AssertionError: assert [{'content': ...ole': 'user'}] == [{'content': ... 'assistant'}] Right contains one more item: {'content': 'Hi User!', 'role': 'assistant'} Full diff: [ { 'content': 'Hello there!', 'role': 'user', }, - { - 'content': 'Hi User!', - 'role': 'assistant', - }, ]
{"role": "user", "content": "Hello there!"},
{"role": "assistant", "content": "Hi User!"}
]

def test_serialize_limit(self):
async def test_serialize_limit(self):
chat_feed = ChatFeed()
chat_feed.send("I'm a user", user="user")
chat_feed.send("I'm the assistant", user="assistant")
Expand All @@ -1471,7 +1469,7 @@
{"role": "assistant", "content": "I'm a bot"},
]

def test_serialize_class(self, chat_feed):
async def test_serialize_class(self, chat_feed):
class Test():

def __repr__(self):
Expand All @@ -1480,7 +1478,7 @@
chat_feed.send(Test())
assert chat_feed.serialize() == [{"role": "user", "content": "Test()"}]

def test_serialize_kwargs(self, chat_feed):
async def test_serialize_kwargs(self, chat_feed):
chat_feed.send("Hello")
chat_feed.add_step("Hello", "World")
assert chat_feed.serialize(
Expand All @@ -1495,7 +1493,7 @@
@pytest.mark.xdist_group("chat")
class TestChatFeedSerializeBase:

def test_transformers_format(self):
async def test_transformers_format(self):
chat_feed = ChatFeed()
chat_feed.send("I'm a user", user="user")
chat_feed.send("I'm the assistant", user="assistant")
Expand All @@ -1506,7 +1504,7 @@
{"role": "assistant", "content": "I'm a bot"},
]

def test_invalid(self):
async def test_invalid(self):
with pytest.raises(NotImplementedError, match="is not supported"):
chat_feed = ChatFeed()
chat_feed.send("I'm a user", user="user")
Expand All @@ -1516,7 +1514,7 @@
@pytest.mark.xdist_group("chat")
class TestChatFeedPostHook:

def test_return_string(self, chat_feed):
async def test_return_string(self, chat_feed):
def callback(contents, user, instance):
return f"Echo: {contents}"

Expand All @@ -1527,7 +1525,7 @@
chat_feed.callback = callback
chat_feed.post_hook = append_callback
chat_feed.send("Hello World!")
wait_until(lambda: chat_feed.objects[-1].object == "Echo: Hello World!")

Check failure on line 1528 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / core:test-core:ubuntu-latest

TestChatFeedPostHook.test_return_string TimeoutError: wait_until timed out in 5000 milliseconds

Check failure on line 1528 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:ubuntu-latest

TestChatFeedPostHook.test_return_string TimeoutError: wait_until timed out in 5000 milliseconds

Check failure on line 1528 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-310:macos-latest

TestChatFeedPostHook.test_return_string TimeoutError: wait_until timed out in 5000 milliseconds

Check failure on line 1528 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:macos-latest

TestChatFeedPostHook.test_return_string TimeoutError: wait_until timed out in 5000 milliseconds

Check failure on line 1528 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:ubuntu-latest

TestChatFeedPostHook.test_return_string TimeoutError: wait_until timed out in 5000 milliseconds
assert logs == ["Hello World!", "Echo: Hello World!"]

async def test_yield_string(self, chat_feed):
Expand Down Expand Up @@ -1559,7 +1557,7 @@
chat_feed.post_hook = append_callback
chat_feed.send("Hello World!")
await async_wait_until(lambda: chat_feed.objects[-1].object == "Echo: Hello World!")
assert logs == ["Hello World!", "Echo: Hello World!"]

Check failure on line 1560 in panel/tests/chat/test_feed.py

View workflow job for this annotation

GitHub Actions / unit:test-312:ubuntu-latest

TestChatFeedPostHook.test_generator AssertionError: assert ['Hello World!'] == ['Hello World...Hello World!'] Right contains one more item: 'Echo: Hello World!' Full diff: [ 'Hello World!', - 'Echo: Hello World!', ]

async def test_async_generator(self, chat_feed):
async def callback(contents, user, instance):
Expand Down
Loading