Skip to content

Commit dbd59e8

Browse files
gchalumpfacebook-github-bot
authored andcommitted
Back out "Manifold wrapper and Add make directory to filestore abstraction" (#4386)
Summary: X-link: facebookresearch/FBGEMM#1456 Pull Request resolved: #4386 Original commit changeset: 2c365c2d3804 Original Phabricator Diff: D76603891 D76186007 S532997 Reviewed By: q10 Differential Revision: D77039847 fbshipit-source-id: d0308f01c336e108b6eb59897cd429c419c0c584
1 parent 74d24ea commit dbd59e8

File tree

2 files changed

+4
-105
lines changed

2 files changed

+4
-105
lines changed

fbgemm_gpu/fbgemm_gpu/utils/filestore.py

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -155,53 +155,4 @@ def exists(self, path: str) -> bool:
155155
True if file exists, False otherwise.
156156
"""
157157
filepath = f"{self.bucket}/{path}"
158-
return os.path.exists(filepath)
159-
160-
def create_directory(self, path: str) -> "FileStore":
161-
"""
162-
Creates a directory in the file store.
163-
164-
Args:
165-
path (str): The path of the node or symlink to a directory (relative
166-
to `self.bucket`) to be created.
167-
168-
Returns:
169-
self. This allows for method-chaining.
170-
"""
171-
filepath = f"{self.bucket}/{path}"
172-
event = f"creating directory {filepath}"
173-
logger.info(f"FileStore: {event}")
174-
175-
try:
176-
if not os.path.exists(filepath):
177-
os.makedirs(filepath, exist_ok=True)
178-
except Exception as e:
179-
logger.error(f"FileStore: exception occurred when {event}: {e}")
180-
raise e
181-
182-
return self
183-
184-
def remove_directory(self, path: str) -> "FileStore":
185-
"""
186-
Removes a directory from the file store.
187-
188-
Args:
189-
path (str): The path of the node or symlink to a directory (relative
190-
to `self.bucket`) to be removed.
191-
192-
Returns:
193-
self. This allows for method-chaining.
194-
"""
195-
filepath = f"{self.bucket}/{path}"
196-
event = f"deleting {filepath}"
197-
logger.info(f"FileStore: {event}")
198-
199-
try:
200-
if os.path.isdir(filepath):
201-
os.rmdir(filepath)
202-
203-
except Exception as e:
204-
logger.error(f"Manifold: exception occurred when {event}: {e}")
205-
raise e
206-
207-
return self
158+
return os.path.isfile(filepath)

fbgemm_gpu/test/utils/filestore_test.py

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -60,41 +60,6 @@ def _test_filestore_readwrite(
6060
store.remove(path)
6161
assert not store.exists(path), f"{path} is not removed"
6262

63-
def _test_filestore_directory(
64-
self,
65-
# pyre-fixme[2]
66-
store, # FileStore
67-
root_dir: Optional[str] = None,
68-
) -> None:
69-
"""
70-
Generic FileStore routines to test creating and removing directories
71-
72-
Args:
73-
store (FileStore): The FileStore to test
74-
root_dir (str): The root directory to create
75-
"""
76-
if root_dir is not None:
77-
root_dir += "/"
78-
else:
79-
root_dir = ""
80-
81-
dir1 = f"{''.join(random.choices(string.ascii_letters, k=15))}"
82-
dir2 = f"{''.join(random.choices(string.ascii_letters, k=15))}"
83-
84-
store.create_directory(f"{root_dir}{dir1}/{dir2}")
85-
assert store.exists(
86-
f"{root_dir}{dir1}/{dir2}"
87-
), f"Failed creating directories /{dir1}/{dir2}, directoies does not exist"
88-
89-
store.remove_directory(f"{root_dir}{dir1}/{dir2}")
90-
assert not store.exists(
91-
f"{root_dir}{dir1}/{dir2}"
92-
), f"Failed removing directories /{dir1}/{dir2}, directory still exists"
93-
store.remove_directory(f"{root_dir}{dir1}")
94-
assert not store.exists(
95-
f"{root_dir}{dir1}"
96-
), f"Failed removing directories /{dir1}, directory still exists"
97-
9863
def test_filestore_oss_bad_bucket(self) -> None:
9964
"""
10065
Test that OSS FileStore raises ValueError when an invalid bucket is provided
@@ -139,14 +104,6 @@ def test_filestore_oss_file(self) -> None:
139104

140105
self._test_filestore_readwrite(FileStore("/tmp"), Path(infile.name))
141106

142-
def test_filestore_oss_directory(self) -> None:
143-
"""
144-
Test that OSS FileStore can create and remove directories
145-
"""
146-
from fbgemm_gpu.utils import FileStore
147-
148-
self._test_filestore_directory(FileStore("/tmp"))
149-
150107
@unittest.skipIf(open_source, "Test does not apply to OSS")
151108
def test_filestore_fb_bad_bucket(self) -> None:
152109
"""
@@ -168,7 +125,7 @@ def test_filestore_fb_binaryio(self) -> None:
168125
self._test_filestore_readwrite(
169126
FileStore("tlparse_reports"),
170127
io.BytesIO("".join(random.choices(string.ascii_letters, k=128)).encode()),
171-
f"tree/unit_tests/{''.join(random.choices(string.ascii_letters, k=15))}.unittest",
128+
f"tree/{''.join(random.choices(string.ascii_letters, k=15))}.unittest",
172129
)
173130

174131
@unittest.skipIf(open_source, "Test does not apply to OSS")
@@ -181,7 +138,7 @@ def test_filestore_fb_tensor(self) -> None:
181138
self._test_filestore_readwrite(
182139
FileStore("tlparse_reports"),
183140
torch.rand((random.randint(100, 1000), random.randint(100, 1000))),
184-
f"tree/unit_tests/{''.join(random.choices(string.ascii_letters, k=15))}.unittest",
141+
f"tree/{''.join(random.choices(string.ascii_letters, k=15))}.unittest",
185142
)
186143

187144
@unittest.skipIf(open_source, "Test does not apply to OSS")
@@ -198,14 +155,5 @@ def test_filestore_fb_file(self) -> None:
198155
self._test_filestore_readwrite(
199156
FileStore("tlparse_reports"),
200157
Path(infile.name),
201-
f"tree/unit_tests/{''.join(random.choices(string.ascii_letters, k=15))}.unittest",
158+
f"tree/{''.join(random.choices(string.ascii_letters, k=15))}.unittest",
202159
)
203-
204-
@unittest.skipIf(open_source, "Test does not apply to OSS")
205-
def test_filestore_fb_directory(self) -> None:
206-
"""
207-
Test that FB FileStore can create and remove directories
208-
"""
209-
from fbgemm_gpu.fb.utils import FileStore
210-
211-
self._test_filestore_directory(FileStore("tlparse_reports"), "tree/unit_tests")

0 commit comments

Comments
 (0)