[
https://issues.apache.org/jira/browse/BEAM-10937?focusedWorklogId=586786&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-586786
]
ASF GitHub Bot logged work on BEAM-10937:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 21/Apr/21 18:03
Start Date: 21/Apr/21 18:03
Worklog Time Spent: 10m
Work Description: davidcavazos commented on a change in pull request
#14431:
URL: https://github.com/apache/beam/pull/14431#discussion_r617768208
##########
File path: examples/notebooks/tour-of-beam/reading-and-writing-data.ipynb
##########
@@ -724,16 +740,21 @@
" self.batch_size = batch_size\n",
"\n",
" @staticmethod\n",
+ " def expand_pattern(pattern):\n",
+ " for match_result in beam_fs.match([pattern])[0].metadata_list:\n",
+ " yield match_result.path\n",
+ "\n",
+ " @staticmethod\n",
" def write_file(lines, file_name_prefix, file_name_suffix):\n",
" file_name =
f\"{file_name_prefix}-{uuid.uuid4().hex}{file_name_suffix}\"\n",
- " with open(file_name, 'w') as f:\n",
+ " with beam_fs.create(file_name) as f:\n",
" for line in lines:\n",
- " f.write(f\"{line}\\n\")\n",
+ " f.write(f\"{line}\\n\".encode('utf-8'))\n",
"\n",
" def expand(self, pcollection):\n",
" # Remove existing files matching the output file_name pattern.\n",
- " for f in
glob.glob(f\"{self.file_name_prefix}*{self.file_name_suffix}\"):\n",
- " os.remove(f)\n",
+ " for path in
self.expand_pattern(f\"{self.file_name_prefix}*{self.file_name_suffix}\"):\n",
Review comment:
Again, this was more to show how to create custom I/O transforms, but
I'll definitely add a note pointing them to `WriteToText`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 586786)
Time Spent: 9h 20m (was: 9h 10m)
> Create "Tour of Beam" introductory section
> ------------------------------------------
>
> Key: BEAM-10937
> URL: https://issues.apache.org/jira/browse/BEAM-10937
> Project: Beam
> Issue Type: Improvement
> Components: website
> Reporter: David Cavazos
> Priority: P3
> Time Spent: 9h 20m
> Remaining Estimate: 0h
>
> Create a new "Tour of Beam" section in the docs, with links to all the
> notebooks we have to improve the onboarding experience for beginners.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)