chmp/ipytest

run test error when having python locally and notebooks in remote server

yuuuxt opened this issue · 4 comments

I'm not sure what caused the following issue. I have python installed and run on a local PC, and have notebooks on a remote server.

I have __file__ correctly defined and try to have a sample test using %%run_pytest[clean] -q, the following error will appear. If I run it again, it will run as usual.

ERROR: not found: <remote_path_to_notebook>\some.ipynb
(no name '<remote_path_to_notebook>\some.ipynb' in any of [])

This issue didn't appear when I also have notebooks locally.

It's just a little annoying, but it would be nice if we could fix it.

using:

  • notebook 6.0.3
  • pytest 5.4.2
  • ipytest 0.8.1
chmp commented

Thanks for reporting the issue. I imagine there is is no shared filesystem, right?

As a quickfix, you could try to remove the __file__ definition and to make sure the tempfile_fallback is configured by either using ipytest.autoconfig() or ipytest.config(tempfile_fallback=True). This way a new temporary notebook file will be created on the remote system.

Does this work for you?

Hi chmp,

This works as expected, and thanks for your help!

Buy the way, I'm not sure what you mean by "shared filesystem". For me, the remote path is just a shared folder on another windows PC.

chmp commented

The "issue" is that only the frontend knows about the notebook files, whereas only the kernel knows about the code being executed. Typically, both the frontend and the kernel are accessing the same filesystem and this split is not visible.

In any case, I will change ipytest that it automatically picks up on missing notebook files and uses the tempfile fallback automatically:

  1. Test whether __file__ is set and whether it exists. If so use it.
  2. Otherwise, depending on whether the tempfile fallback is activated:
    • fallback onto the tempfile, issuing a warning if __file__ is set
    • otherwise, raise a descriptive error
chmp commented

Changed on develop. Will be released with ipytest==0.9.0.