aiidateam / kiwipy

A python messaging library for RPC, task queues and broadcasts
https://kiwipy.readthedocs.io
Other
15 stars 4 forks source link

Fix tests #108

Closed muhrin closed 2 years ago

muhrin commented 2 years ago

Fixed tests by removing async_generator

This was being used for compatibility with py3.5 but we are not supporting this anymore so we can rely on the build-in support for async yields and test-asyncio for fixtures.

@chrisjsewell do you understand why the out jupyter notebook test fails? I don't understand the error message at all...

sphuber commented 2 years ago

I thought this may have to do with the fact that a kernel is not installed. By installing one with pip install ipykernel the error is fixed, but another one appears:

        with open(my_dir / pathlib.Path('notebooks/communicator.ipynb')) as handle:
>           fixture.check(handle)

test/rmq/test_rmq_thread_communicator.py:269: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/sph/.virtualenvs/aiida_dev/lib/python3.9/site-packages/pytest_notebook/execution.py:262: in execute_notebook
    proc.preprocess(new_notebook, resources)
/home/sph/.virtualenvs/aiida_dev/lib/python3.9/site-packages/pytest_notebook/execution.py:159: in preprocess
    nb, resources = super(ExecutePreprocessor, self).preprocess(
/home/sph/.virtualenvs/aiida_dev/lib/python3.9/site-packages/nbconvert/preprocessors/base.py:69: in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
/home/sph/.virtualenvs/aiida_dev/lib/python3.9/site-packages/pytest_notebook/execution.py:175: in preprocess_cell
    return super().preprocess_cell(cell, resources, cell_index)
/home/sph/.virtualenvs/aiida_dev/lib/python3.9/site-packages/nbconvert/preprocessors/execute.py:438: in preprocess_cell
    reply, outputs = self.run_cell(cell, cell_index, store_history)
/home/sph/.virtualenvs/aiida_dev/lib/python3.9/site-packages/nbconvert/preprocessors/execute.py:578: in run_cell
    exec_reply = self._poll_for_reply(parent_msg_id, cell, timeout)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <pytest_notebook.execution.ExecuteCoveragePreprocessor object at 0x7f7e4d40e9a0>, msg_id = '3b785650-759ab2172974b2accbec6521_76727_1'
cell = {'cell_type': 'code', 'execution_count': 1, 'metadata': {'pycharm': {'name': '#%%\n'}}, 'outputs': [], 'source': 'impo...turn "Thanks!"\n\n\ncomm.add_rpc_subscriber(rpc_call, \'tester\')\n\nresponse = comm.rpc_send(\'tester\', \'hello!\')'}
timeout = 1

    def _poll_for_reply(self, msg_id, cell=None, timeout=None):
        try:
            # check with timeout if kernel is still alive
            msg = self.kc.shell_channel.get_msg(timeout=timeout)
>           if msg['parent_header'].get('msg_id') == msg_id:
E           TypeError: 'coroutine' object is not subscriptable

This seems to come from @chrisjsewell 's pytest-notebook library. Any ideas why msg is still a coroutine and not resolved to what it is expected to be?

chrisjsewell commented 2 years ago

See https://github.com/chrisjsewell/pytest-notebook/issues/17, I'll try and whip up a fix today

codecov[bot] commented 2 years ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 90.34%. Comparing base (cfc0498) to head (e7431b1).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #108 +/- ## ======================================== Coverage 90.34% 90.34% ======================================== Files 16 16 Lines 1138 1138 ======================================== Hits 1028 1028 Misses 110 110 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

chrisjsewell commented 2 years ago

Ok all fixed:

  1. You made me spend all day updating pytest-notebook lol
  2. It now supports python>=3.7, so I changed that here as well (inline with our support policy anyway)
  3. https://github.com/pytest-dev/pytest-asyncio/releases/tag/v0.17.0 (just released) is failing with some weird errors (maybe incompatible with pytest~=5.4), so pinned to <0.17
sphuber commented 2 years ago

3. https://github.com/pytest-dev/pytest-asyncio/releases/tag/v0.17.0 (just released) is failing with some weird errors (maybe incompatible with pytest~=5.4), so pinned to <0.17

Indeed, had already encountered this with aiida-core and opened an issue. Also had to pin it temporarily