Title: GCS Blob does not support the io.IOBase interface · Issue #3903 · googleapis/google-cloud-python · GitHub
Open Graph Title: GCS Blob does not support the io.IOBase interface · Issue #3903 · googleapis/google-cloud-python
X Title: GCS Blob does not support the io.IOBase interface · Issue #3903 · googleapis/google-cloud-python
Description: I'm branching this issue from the (currently resolved) issue #2871. The title covers the request, but to add some context see below. Many python libraries (pandas, biopython, pillow, etc.) support reading from a 'python file object' whic...
Open Graph Description: I'm branching this issue from the (currently resolved) issue #2871. The title covers the request, but to add some context see below. Many python libraries (pandas, biopython, pillow, etc.) support ...
X Description: I'm branching this issue from the (currently resolved) issue #2871. The title covers the request, but to add some context see below. Many python libraries (pandas, biopython, pillow, etc.) supp...
Opengraph URL: https://github.com/googleapis/google-cloud-python/issues/3903
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"GCS Blob does not support the io.IOBase interface","articleBody":"I'm branching this issue from the (currently resolved) issue #2871. The title covers the request, but to add some context see below.\r\n\r\nMany python libraries (pandas, biopython, pillow, etc.) support reading from a 'python file object' which canonically are objects that implement the [io.IOBase](https://docs.python.org/2/library/io.html#io.IOBase) interface. If we could open a blob as a file object, we could do operations as shown in the example below where I'm just reading a few lines from a (possibly very large) file.\r\n\r\n```\r\nfrom Bio import SeqIO\r\nfrom google.cloud.storage import blob\r\n\r\nwith blob.Blob('/data/example.fastq', 'mybucket').open('rb') as fileobj:\r\n for i, rec in enumerate(SeqIO.parse(fileobj, 'fastq')):\r\n print(rec.seq)\r\n print(' name=%s\\n annotations=%r' % (rec.name, rec.annotations))\r\n if i \u003e 5:\r\n break\r\n```\r\n[`google-resumable-media`](https://googlecloudplatform.github.io/google-resumable-media-python/latest/) covers some of the need expressed in this bug, but it does not satisfy users who need blobs to be parsed by libraries expecting standard file objects. The standard advice might be to download files first but that advice ignores the expense and time of downloading large files when indexed operations are available.\r\n\r\nSome work has been done towards this end - the following two repositories have solutions. That said, I think most people would be far more happy to adopt a solution from this project since it has a far larger community and more active maintenance / governance.\r\n - https://github.com/Akrog/gcs-client\r\n - https://github.com/martindurant/gcsfs\r\n","author":{"url":"https://github.com/eap","@type":"Person","name":"eap"},"datePublished":"2017-08-30T21:49:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":7},"url":"https://github.com/3903/google-cloud-python/issues/3903"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:93ff5c23-a7ec-d211-02ae-026369707a43 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ECBC:31C072:3EB88C:54FA14:6A4D3A09 |
| html-safe-nonce | c70c9e571c01d3854d10fa76f2291c44e990d3032003ec0c1e764228bc3717bd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQ0JDOjMxQzA3MjozRUI4OEM6NTRGQTE0OjZBNEQzQTA5IiwidmlzaXRvcl9pZCI6IjY1Njg3MjE5MDYyNDkwNTQ3MzAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2ce90b2294b289a719828b35a9df4f4753cc1c7ac69ebec9339300186834f68d |
| hovercard-subject-tag | issue:254146249 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-cloud-python/3903/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bbdd77acc824334733d61af3d41c73ab3f6bc80eda16ff0bf1454912353efe64/googleapis/google-cloud-python/issues/3903 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bbdd77acc824334733d61af3d41c73ab3f6bc80eda16ff0bf1454912353efe64/googleapis/google-cloud-python/issues/3903 |
| og:image:alt | I'm branching this issue from the (currently resolved) issue #2871. The title covers the request, but to add some context see below. Many python libraries (pandas, biopython, pillow, etc.) support ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eap |
| hostname | github.com |
| expected-hostname | github.com |
| None | 92571a8944142227b7e19cd10918b1ddd06e5066c1ad5bc7e4769cf6140a87e6 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/google-cloud-python git https://github.com/googleapis/google-cloud-python.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 16316451 |
| octolytics-dimension-repository_nwo | googleapis/google-cloud-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16316451 |
| octolytics-dimension-repository_network_root_nwo | googleapis/google-cloud-python |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 56fc8347865a14e2ec811533d68f929cf4e0ec19 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width