about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorArun Isaac2023-05-31 15:19:13 +0100
committerArun Isaac2023-05-31 15:19:13 +0100
commit7855758c7f17c32cad3c73f5a5677fb87146e32a (patch)
treed3761c94156c8bb22cc865b68b126277d804716f /scripts
parent4e572eba5fa89a0ae4c5c732babe8c4bc011d435 (diff)
downloadgenenetwork3-7855758c7f17c32cad3c73f5a5677fb87146e32a.tar.gz
scripts: Ensure only one indexing job may run at a time.
* scripts/index-genenetwork (main): Ensure no other indexing job is running.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/index-genenetwork11
1 files changed, 10 insertions, 1 deletions
diff --git a/scripts/index-genenetwork b/scripts/index-genenetwork
index 4da82e4..f7d4415 100755
--- a/scripts/index-genenetwork
+++ b/scripts/index-genenetwork
@@ -20,6 +20,7 @@ import os
 import pathlib
 import resource
 import shutil
+import sys
 import tempfile
 from typing import Callable, Generator, Iterable, List
 
@@ -359,7 +360,15 @@ def xapian_compact(combined_index: pathlib.Path, indices: List[pathlib.Path]) ->
 def main(xapian_directory: str, sql_uri: str) -> None:
     logging.basicConfig(level=os.environ.get("LOGLEVEL", "DEBUG"),
                         format='%(relativeCreated)s: %(levelname)s: %(message)s')
-    pathlib.Path(xapian_directory).mkdir(exist_ok=True)
+
+    # Ensure no other build process is running.
+    if pathlib.Path(xapian_directory).exists():
+        logging.error("Build directory %s already exists; "
+                      "perhaps another build process is running.",
+                      xapian_directory)
+        sys.exit(1)
+
+    pathlib.Path(xapian_directory).mkdir()
     with temporary_directory("combined", xapian_directory) as combined_index:
         with temporary_directory("build", xapian_directory) as xapian_build_directory:
             logging.info("Indexing genes")