ale
07/24/2022, 5:55 PMpyfakefs
, so that I can mock files on the file system.
However, it seems something is not working as expected.
It seems related to pyfakefs
and prefect
, but I’m not 100% sure.
Anyone able to help me figuring out what’s going on? 😊
Stack trace in the thread!
Thanks! 🙌Anna Geller
07/24/2022, 8:42 PMale
07/25/2022, 7:25 AM/Users/alessandro.lollo/.pyenv/versions/3.9.10/envs/prefect-metricflow/lib/python3.9/site-packages/prefect/flows.py:367: in __call__
return enter_flow_run_engine_from_flow_call(
/Users/alessandro.lollo/.pyenv/versions/3.9.10/envs/prefect-metricflow/lib/python3.9/site-packages/prefect/engine.py:110: in enter_flow_run_engine_from_flow_call
setup_logging()
/Users/alessandro.lollo/.pyenv/versions/3.9.10/envs/prefect-metricflow/lib/python3.9/site-packages/prefect/logging/configuration.py:66: in setup_logging
config = load_logging_config(
/Users/alessandro.lollo/.pyenv/versions/3.9.10/envs/prefect-metricflow/lib/python3.9/site-packages/prefect/logging/configuration.py:33: in load_logging_config
template = string.Template(path.read_text())
/Users/alessandro.lollo/.pyenv/versions/3.9.10/lib/python3.9/pathlib.py:1266: in read_text
with self.open(mode='r', encoding=encoding, errors=errors) as f:
/Users/alessandro.lollo/.pyenv/versions/3.9.10/lib/python3.9/pathlib.py:1252: in open
return io.open(self, mode, buffering, encoding, errors, newline,
/Users/alessandro.lollo/.pyenv/versions/3.9.10/envs/prefect-metricflow/lib/python3.9/site-packages/pyfakefs/fake_filesystem.py:5036: in open
return fake_open(file, mode, buffering, encoding, errors,
/Users/alessandro.lollo/.pyenv/versions/3.9.10/envs/prefect-metricflow/lib/python3.9/site-packages/pyfakefs/fake_filesystem.py:5721: in __call__
return self.call(*args, **kwargs)
/Users/alessandro.lollo/.pyenv/versions/3.9.10/envs/prefect-metricflow/lib/python3.9/site-packages/pyfakefs/fake_filesystem.py:5778: in call
file_object, file_path, filedes, real_path = self._handle_file_arg(
/Users/alessandro.lollo/.pyenv/versions/3.9.10/envs/prefect-metricflow/lib/python3.9/site-packages/pyfakefs/fake_filesystem.py:5912: in _handle_file_arg
wrapper = self.filesystem.get_open_file(filedes)
/Users/alessandro.lollo/.pyenv/versions/3.9.10/envs/prefect-metricflow/lib/python3.9/site-packages/pyfakefs/fake_filesystem.py:1552: in get_open_file
self.raise_os_error(errno.EBADF, str(file_des))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <pyfakefs.fake_filesystem.FakeFilesystem object at 0x119554e20>, err_no = 9, filename = '11', winerror = None
def raise_os_error(self, err_no: int,
filename: Optional[AnyString] = None,
winerror: Optional[int] = None) -> NoReturn:
"""Raises OSError.
The error message is constructed from the given error code and shall
start with the error string issued in the real system.
Note: this is not true under Windows if winerror is given - in this
case a localized message specific to winerror will be shown in the
real file system.
Args:
err_no: A numeric error code from the C variable errno.
filename: The name of the affected file, if any.
winerror: Windows only - the specific Windows error code.
"""
message = os.strerror(err_no) + ' in the fake filesystem'
if (winerror is not None and sys.platform == 'win32' and
self.is_windows_fs):
raise OSError(err_no, message, filename, winerror)
> raise OSError(err_no, message, filename)
E OSError: [Errno 9] Bad file descriptor in the fake filesystem: '11'
/Users/alessandro.lollo/.pyenv/versions/3.9.10/envs/prefect-metricflow/lib/python3.9/site-packages/pyfakefs/fake_filesystem.py:1122: OSError
============================================================================================================================= short test summary info =============================================================================================================================
FAILED tests/test_tasks.py::test_materialize_success_with_config - OSError: [Errno 9] Bad file descriptor in the fake filesystem: '11'
prefect==2.0b12
pyfakefs
installed, you can reproduce the error with this very simple test
from prefect import flow
def test_example(fs):
msg = "This is an example flow"
@flow
def test_flow():
return msg
response = test_flow()
assert response == msg