Skip to content

Conversation

@AlenkaF
Copy link
Member

@AlenkaF AlenkaF commented Jan 16, 2023

Rationale for this change

Ensure docstrings for Streams and File Access - Stream Classes - have an Examples section.

What changes are included in this PR?

Docstrings are added to listed Stream Classes:

  • OSFile
  • PythonFile
  • BufferReader
  • BufferOutputStream
  • FixedSizeBufferWriter
  • MemoryMappedFile
  • CompressedInputStream
  • CompressedOutputStream

Are these changes tested?

Yes, locally with pytest --doctest-cython --disable-warnings pyarrow and on the CI with Python / AMD64 Conda Python 3.9 Sphinx & Numpydoc build.

Are there any user-facing changes?

No.

@github-actions
Copy link

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small comments!

>>> import pyarrow as pa
>>> data = b'reader data'
>>> f = pa.BufferReader(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should maybe also reference pa.input_stream() as the (preferred?) way to create BufferReader objects?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(and same for some of the others)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added changes regarding this comment in this commit: 10d5e89
I hope I captured all the necessary changes.

>>> data = b'reader data'
>>> f = pa.BufferReader(data)
>>> f.size()
>>> buf = memoryview(data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the memoryview(..) needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs some kind of a source (str, Path, buffer, file-like object, …):

>>> import pyarrow as pa
>>> data = b'reader data'
>>> with pa.input_stream(data) as stream:
...     stream.size()
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pyarrow/io.pxi", line 2403, in pyarrow.lib.input_stream
    hasattr(source, 'closed')):
TypeError: pa.input_stream() called with instance of '<class 'bytes'>'

Can change the source, if preferred.

@danepitkin
Copy link
Member

I ran through the examples and they all worked well for me. Nice work! LGTM (Looks Good To Me).

@AlenkaF AlenkaF merged commit f2d632e into apache:main Feb 20, 2023
@AlenkaF AlenkaF deleted the GH-31507-streams-docstrings branch February 20, 2023 08:45
@ursabot
Copy link

ursabot commented Feb 20, 2023

Benchmark runs are scheduled for baseline = 7db7e6a and contender = f2d632e. f2d632e is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Failed ⬇️0.12% ⬆️0.03%] test-mac-arm
[Finished ⬇️0.0% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.1% ⬆️0.0%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] f2d632e7 ec2-t3-xlarge-us-east-2
[Finished] f2d632e7 test-mac-arm
[Finished] f2d632e7 ursa-i9-9960x
[Finished] f2d632e7 ursa-thinkcentre-m75q
[Finished] 7db7e6ac ec2-t3-xlarge-us-east-2
[Failed] 7db7e6ac test-mac-arm
[Finished] 7db7e6ac ursa-i9-9960x
[Finished] 7db7e6ac ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] Address docstrings in Streams and File Access (Stream Classes)

4 participants