Uploaded image for project: 'Beam'
  1. Beam
  2. BEAM-11135

pathlib.Path, PathLike and __fspath__ support (PEP 519)

Details

    Description

      It would be nice to support `pathlib.Path`-like objects, as per PEP 519: https://www.python.org/dev/peps/pep-0519/

      Currently, the following fail with: TypeError: file_path_prefix must be a string or ValueProvider;got PosixPath('/tmp/pytest-of-forge-00/pytest-0/test_ptransform_beam0/output0.txt') instead

      import pathlib
      
      path = pathlib.Path('/path/to/home')
      beam.io.WriteToText(path)
      

      Raised by FileBasedSink:

      class FileBasedSink(iobase.Sink):
      
        def __init__(self)
          if not isinstance(file_path_prefix, ((str, unicode), ValueProvider)):
            raise TypeError(...)
      

      It could be implemented by calling os.fspath(file_path_prefix)

      Attachments

        Activity

          People

            Unassigned Unassigned
            conchylicultor Etienne POT
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: