-
Notifications
You must be signed in to change notification settings - Fork 91
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
OSError: [Errno 9] Bad file descriptor in the fake filesystem #697
Comments
At a first glance, this look like the code is trying to read a file in the real fs that is not present in the fake filesystem, specifically the logging config. As the fake filesystem does not use any real filesysystem contents by defaults, these have to be mapped into the fake filesystem on setup if needed. I may have a closer look at this tonight. |
I had a closer look, and there is another issue here that may take some time to fix. As mentioned, I confirmed that disabling the import os
import pytest
from prefect import flow, logging, orion
import pytzdata
@pytest.fixture
def fs_with_config(fs):
module_paths = (logging, pytzdata, orion)
for module_path in module_paths:
data_path = os.path.dirname(getattr(module_path, "__file__"))
fs.add_real_directory(data_path)
def test_example(fs_with_config):
... Though you won't able to use this until the issue is fixed. |
Ok, I added a commit to master that ignores the opener in pathlib (basically the same behavior regarding |
Hey @mrbean-bremen 👋 I will try your suggestion and let you know how it goes! Thanks again 🙏 |
@AlessandroLollo - did you get a chance to test this? |
As there is a regression in the new package release, the dependency is downgraded to the previous one. (pytest-dev/pyfakefs#697)
As there is a regression in the new package release, the dependency is downgraded to the previous one. (pytest-dev/pyfakefs#697)
Hey @mrbean-bremen 👋
I'm using |
Thanks, that's unfortunate - I will have a closer look tonight. |
Thanks @mrbean-bremen 🙌 |
Hm, this looks like the error you get if you don't map the needed module paths into the fake filesystem. |
Actually, I can see that you didn't change the setup, as that would show in the error output. Without that setup, it cannot work, as pyfakefs has no way of knowing which files in the real filesystem it needs to copy to the fake filesystem. Can you please retry using the setup mentioned above? As for the actual problem, I have confimed that the error occurs, because |
Hey @mrbean-bremen 👋 Here's the updated test:
Running
I think warnings can be ignored, since they're related to Pandas (which is used by MetricFlow behind the scenes). |
Ok, I could not have seen this, as I had tested under Windows, and this is Posix-specific code. We actually fake the Anyway, thanks for the investigation - this is the kind of information we need to improve |
I'm glad I was able to help! 🙌 |
I now fixed the return value for @pytest.fixture
def fs_with_config(fs):
module_paths = (logging, pytzdata, orion)
for module_path in module_paths:
data_path = os.path.dirname(getattr(module_path, "__file__"))
fs.add_real_directory(data_path)
if fs.is_linux:
fs.add_real_file("/etc/localtime")
elif fs.is_macos:
fs.add_real_symlink("/etc/localtime") Note that there is no guarantee that this will still work of the test code gets more complicated and uses more functionalities from the involved libraries. |
Closing as fixed, feel free to reopen if it does not work for you. |
Is it possible to link the PR that fixed this? (Apologies if I missed it amongst the comments.) |
My bad - forgot to mention the issue in the commit. |
Hey folks 👋
I'm facing an issue that seems to be related to
pyfakefs
, but I'm not 100% sure.While implementing an integration between MetricFlow and Prefect 2.0, I'm using
pyfakefs
to mock some files I need.I was able to reproduce the issue with this minimal script:
I'm using
pyfakefs==4.6.3
andprefect==2.0b12
Below you can find the trace back generated by
pytest
:My environment is Python 3.9.10 on MacOS 12.4
Anyone that can help me understanding what's going on?
Thanks! 🙌
The text was updated successfully, but these errors were encountered: