chmp / ipytest

Pytest in IPython notebooks.
MIT License
314 stars 17 forks source link

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

Closed yuuuxt closed 4 years ago

yuuuxt commented 4 years ago

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: \some.ipynb (no name '\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:

chmp commented 4 years ago

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?

yuuuxt commented 4 years ago

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 4 years ago

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 4 years ago

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