[ 
https://issues.apache.org/jira/browse/BEAM-4747?focusedWorklogId=147913&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-147913
 ]

ASF GitHub Bot logged work on BEAM-4747:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Sep/18 03:11
            Start Date: 26/Sep/18 03:11
    Worklog Time Spent: 10m 
      Work Description: charlesccychen closed pull request #6494: Revert 
"[BEAM-4747] mkdirs if they don't exist in localfilesystem (#5903)
URL: https://github.com/apache/beam/pull/6494
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/sdks/python/apache_beam/io/localfilesystem.py 
b/sdks/python/apache_beam/io/localfilesystem.py
index ddd5022b2bb..b634d2adc7e 100644
--- a/sdks/python/apache_beam/io/localfilesystem.py
+++ b/sdks/python/apache_beam/io/localfilesystem.py
@@ -144,9 +144,6 @@ def create(self, path, mime_type='application/octet-stream',
 
     Returns: file handle with a close function for the user to use
     """
-    parent = os.path.dirname(path)
-    if not os.path.exists(parent):
-      os.makedirs(parent)
     return self._path_open(path, 'wb', mime_type, compression_type)
 
   def open(self, path, mime_type='application/octet-stream',
@@ -188,10 +185,6 @@ def _copy_path(source, destination):
         if os.path.isdir(source):
           shutil.copytree(source, destination)
         else:
-          parent = os.path.dirname(destination)
-          if not os.path.exists(parent):
-            os.makedirs(parent)
-
           shutil.copy2(source, destination)
       except OSError as err:
         raise IOError(err)
@@ -224,10 +217,6 @@ def rename(self, source_file_names, 
destination_file_names):
     def _rename_file(source, destination):
       """Rename a single file object"""
       try:
-        parent = os.path.dirname(destination)
-        if not os.path.exists(parent):
-          os.makedirs(parent)
-
         os.rename(source, destination)
       except OSError as err:
         raise IOError(err)
diff --git a/sdks/python/apache_beam/io/localfilesystem_test.py 
b/sdks/python/apache_beam/io/localfilesystem_test.py
index bc45e4221dd..5187dc0f93a 100644
--- a/sdks/python/apache_beam/io/localfilesystem_test.py
+++ b/sdks/python/apache_beam/io/localfilesystem_test.py
@@ -196,8 +196,8 @@ def test_copy_error(self):
                      [(path1, path2)])
 
   def test_copy_directory(self):
-    path_t1 = os.path.join(self.tmpdir, 't1/11')
-    path_t2 = os.path.join(self.tmpdir, 't2/22')
+    path_t1 = os.path.join(self.tmpdir, 't1')
+    path_t2 = os.path.join(self.tmpdir, 't2')
     self.fs.mkdirs(path_t1)
     self.fs.mkdirs(path_t2)
 
@@ -209,19 +209,6 @@ def test_copy_directory(self):
     self.fs.copy([path_t1], [path_t2])
     self.assertTrue(filecmp.cmp(path1, path2))
 
-  def test_create_mkdirs_open(self):
-    path = os.path.join(self.tmpdir, 't1/t2/t3')
-    with self.fs.create(path) as f:
-      f.write("yay")
-
-    with self.fs.open(path) as f:
-      self.assertEqual(f.read(), "yay")
-
-  def test_open_error(self):
-    path = os.path.join(self.tmpdir, 't1')
-    with self.assertRaisesRegexp(IOError, r'No such file or directory'):
-      self.fs.open(path)
-
   def test_rename(self):
     path1 = os.path.join(self.tmpdir, 'f1')
     path2 = os.path.join(self.tmpdir, 'f2')
@@ -257,22 +244,6 @@ def test_rename_directory(self):
     self.assertTrue(self.fs.exists(path2))
     self.assertFalse(self.fs.exists(path1))
 
-  def test_rename_mkdirs(self):
-    path_t1 = os.path.join(self.tmpdir, 't1')
-    path_t2 = os.path.join(self.tmpdir, 't2/t3/t4')
-    self.fs.mkdirs(path_t1)
-
-    path1 = os.path.join(path_t1, 'f1')
-    path2 = os.path.join(path_t2, 'f1')
-    with open(path1, 'a') as f:
-      f.write('Hello')
-
-    self.fs.rename([path_t1], [path_t2])
-    self.assertTrue(self.fs.exists(path_t2))
-    self.assertFalse(self.fs.exists(path_t1))
-    self.assertTrue(self.fs.exists(path2))
-    self.assertFalse(self.fs.exists(path1))
-
   def test_exists(self):
     path1 = os.path.join(self.tmpdir, 'f1')
     path2 = os.path.join(self.tmpdir, 'f2')


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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: 147913)
    Time Spent: 2h 40m  (was: 2.5h)

> Python LocalFileSystem directory-creation semantics
> ---------------------------------------------------
>
>                 Key: BEAM-4747
>                 URL: https://issues.apache.org/jira/browse/BEAM-4747
>             Project: Beam
>          Issue Type: Improvement
>          Components: sdk-py-core
>    Affects Versions: 2.5.0
>            Reporter: Ryan Williams
>            Assignee: Ryan Williams
>            Priority: Minor
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> Coming out of discussion on 
> [BEAM-4742|https://issues.apache.org/jira/browse/BEAM-4742] / 
> [#5903|https://github.com/apache/beam/pull/5903] is a question of whether 
> {{LocalFileSystem.{open,create,copy,rename}}} should create 
> intermediate (destination) directories, or fail with {{IOError}}'s (as the 
> stdlib {{os}} module generally will).
> If the semantics of {{LocalFileSystem}} should mimic those of distributed 
> filesystems (in the spirit of [recent discussion about {{DirectRunner}} being 
> more like a local simulation of a distributed runner than a production-grade 
> local 
> runner|https://www.mail-archive.com/[email protected]/msg08410.html]), then 
> this makes sense, and it sounds like [~lcwik] and [~angoenka] are in favor of 
> this interpretation.
> I'll repurpose [#5903|https://github.com/apache/beam/pull/5903] to this end 
> unless I hear otherwise.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to