Преглед на файлове

Do not throw error when trying to delete non-existing parent in benchmark.

Stefano Cossu преди 6 години
родител
ревизия
479615aef7
променени са 1 файла, в които са добавени 7 реда и са изтрити 1 реда
  1. 7 1
      lakesuperior/util/benchmark.py

+ 7 - 1
lakesuperior/util/benchmark.py

@@ -15,6 +15,7 @@ from matplotlib import pyplot as plt
 
 from lakesuperior.util.generators import (
         random_image, random_graph, random_utf8_string)
+from lakesuperior.exceptions import ResourceNotExistsError
 
 __doc__ = '''
 Benchmark script to measure write performance.
@@ -95,6 +96,7 @@ def run(
         parent = '{}/{}'.format(endpoint.strip('/'), parent.strip('/'))
 
         if delete_container:
+            print('Removing previously existing container.')
             requests.delete(parent, headers={'prefer': 'no-tombstone'})
         requests.put(parent)
 
@@ -103,7 +105,11 @@ def run(
         from lakesuperior.api import resource as rsrc_api
 
         if delete_container:
-            rsrc_api.delete(parent, soft=False)
+            try:
+                print('Removing previously existing container.')
+                rsrc_api.delete(parent, soft=False)
+            except ResourceNotExistsError:
+                pass
         rsrc_api.create_or_replace(parent)
     else:
         raise ValueError(f'Mode not supported: {mode}')