mirror of
https://github.com/facebookresearch/faiss.git
synced 2025-06-03 21:54:02 +08:00
Summary: After initial positive feedback to the idea in https://github.com/facebookresearch/faiss/issues/1741 from mdouze, here are the patches I currently have as a basis for discussion. Matthijs suggests to not bother with the deprecation warnings at all, which is fine for me as well, though I would normally still advocate to provide users with _some_ advance notice before removing parts of an interface. Fixes https://github.com/facebookresearch/faiss/issues/1741 PS. The deprecation warning is only shown once per session (per class) PPS. I have tested in https://github.com/conda-forge/faiss-split-feedstock/pull/32 that the respective classes remain available both through `import faiss` and `from faiss import *`. Pull Request resolved: https://github.com/facebookresearch/faiss/pull/1742 Reviewed By: mdouze Differential Revision: D26978886 Pulled By: beauby fbshipit-source-id: b52e2b5b5b0117af7cd95ef5df3128e9914633ad
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
# Copyright (c) Facebook, Inc. and its affiliates.
|
|
#
|
|
# This source code is licensed under the MIT license found in the
|
|
# LICENSE file in the root directory of this source tree.
|
|
|
|
import sys
|
|
import faiss
|
|
import unittest
|
|
import platform
|
|
|
|
class TestOOMException(unittest.TestCase):
|
|
@unittest.skipIf(platform.system() != 'Linux',
|
|
'Test is Linux only.')
|
|
def test_outrageous_alloc(self):
|
|
import resource
|
|
|
|
# https://github.com/facebookresearch/faiss/issues/758
|
|
soft_as, hard_as = resource.getrlimit(resource.RLIMIT_AS)
|
|
# make sure that allocing more than 10G will fail
|
|
resource.setrlimit(resource.RLIMIT_AS, (10 * 1024 * 1024, hard_as))
|
|
try:
|
|
x = faiss.Int32Vector()
|
|
try:
|
|
x.resize(10**11) # 400 G of RAM
|
|
except MemoryError:
|
|
pass # good, that's what we expect
|
|
else:
|
|
assert False, "should raise exception"
|
|
finally:
|
|
resource.setrlimit(resource.RLIMIT_AS, (soft_as, hard_as))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|