Hey folks :wave: Iโ€™m currently working on an integ...
# prefect-contributors
a
Hey folks ๐Ÿ‘‹ Iโ€™m currently working on an integration between Prefect 2.0 and MetricFlow. For testing purposes, I use
pyfakefs
, 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! ๐Ÿ™Œ
a
Hi Ale, could you move the traceback to the thread? Which Prefect beta version did you use?
I haven't used pyfakefs, so hard to say, perhaps you could open an issue in this repo directly? https://github.com/jmcgeheeiv/pyfakefs/issues the error seems to be coming from the library directly rather than from Prefect if you can't figure it out and opening an issue in their repo doesn't help, please LMK and I'll ask someone from the team to have a look
a
Copy code
/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'
Hey @Anna Geller ๐Ÿ‘‹ Iโ€™m using
prefect==2.0b12
If you have
pyfakefs
installed, you can reproduce the error with this very simple test
Copy code
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
I opened this issue.
๐Ÿ™Œ 1
๐Ÿ™ 1