You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "Etienne POT (Jira)" <ji...@apache.org> on 2020/10/27 10:11:00 UTC
[jira] [Updated] (BEAM-11135) pathlib.Path, PathLike and __fspath__
support (PEP 519)
[ https://issues.apache.org/jira/browse/BEAM-11135?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Etienne POT updated BEAM-11135:
-------------------------------
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}}
{code:python}
import pathlib
path = pathlib.Path('/path/to/home')
beam.io.WriteToText(path)
{code}
Raised by FileBasedSink:
{code:python}
class FileBasedSink(iobase.Sink):
def __init__(self)
if not isinstance(file_path_prefix, ((str, unicode), ValueProvider)):
raise TypeError(...)
{code}
was:
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}}
{code:python}
import pathlib
path = pathlib.Path('/path/to/home')
beam.io.WriteToText(path)
{code}
Raised by FileBasedSink:
{code:python}
class FileBasedSink(iobase.Sink):
def __init__(self)
if not isinstance(file_path_prefix, ((str, unicode), ValueProvider)):
raise TypeError(...)
{code}
{code:python}
class FileBasedSink(iobase.Sink):
def __init__(self)
if not isinstance(file_path_prefix, ((str, unicode), ValueProvider)):
raise TypeError(...)
{code}
```
```
> pathlib.Path, PathLike and __fspath__ support (PEP 519)
> -------------------------------------------------------
>
> Key: BEAM-11135
> URL: https://issues.apache.org/jira/browse/BEAM-11135
> Project: Beam
> Issue Type: Bug
> Components: io-py-avro, io-py-files, io-py-parquet, io-py-tfrecord
> Affects Versions: 2.25.0
> Reporter: Etienne POT
> Priority: P2
>
> 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}}
> {code:python}
> import pathlib
> path = pathlib.Path('/path/to/home')
> beam.io.WriteToText(path)
> {code}
> Raised by FileBasedSink:
> {code:python}
> class FileBasedSink(iobase.Sink):
> def __init__(self)
> if not isinstance(file_path_prefix, ((str, unicode), ValueProvider)):
> raise TypeError(...)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)