about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMunyoki Kilyungi2024-06-12 18:39:55 +0300
committerBonfaceKilz2024-06-12 19:21:50 +0300
commit6ba1da4fb7184dd8036f7aaa2bd2171ed1e2faf0 (patch)
treeddea9565b49466296e67c8311884d7c517f0f12d
parentf34550b5a1fd3158d1a0662f65d4501ebfc6e4d5 (diff)
downloadgenenetwork3-6ba1da4fb7184dd8036f7aaa2bd2171ed1e2faf0.tar.gz
Check for a running process by viewing the build dir's contents.
In the CI build, the actual build is run in the
xapian_directory/build, which is seen as the xapian_directory in this
script.  The CI handles clean up WRT removing files related to the
build process.

* scripts/index-genenetwork (create_xapian_index): Create the xapian
directory if it doesn't exist.  If the xapian directory has files,
exit.  Create the temporary directory inside the xapian_directory.
Remove "build_directory.rmdir()"

Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
-rwxr-xr-xscripts/index-genenetwork15
1 files changed, 7 insertions, 8 deletions
diff --git a/scripts/index-genenetwork b/scripts/index-genenetwork
index 9a5bd88..ec203e2 100755
--- a/scripts/index-genenetwork
+++ b/scripts/index-genenetwork
@@ -479,18 +479,18 @@ def create_xapian_index(xapian_directory: str, sql_uri: str,
 
     logging.info("Verifying the checksums")
 
-    build_directory = pathlib.Path(xapian_directory) / "build"
+    if not pathlib.Path(xapian_directory).exists():
+        pathlib.Path(xapian_directory).mkdir()
 
     # Ensure no other build process is running.
-    if build_directory.exists():
-        logging.error("Build directory %s already exists; "
+    if any(pathlib.Path(xapian_directory).iterdir()):
+        logging.error("Build directory %s has build files; "
                       "perhaps another build process is running.",
-                      build_directory)
+                      xapian_directory)
         sys.exit(1)
 
-    build_directory.mkdir()
-    with temporary_directory("combined", build_directory) as combined_index:
-        with temporary_directory("build", build_directory) as xapian_build_directory:
+    with temporary_directory("combined", xapian_directory) as combined_index:
+        with temporary_directory("build", xapian_directory) as xapian_build_directory:
             logging.info("Indexing genes")
             index_query(index_genes, genes_query, xapian_build_directory, sql_uri, sparql_uri)
             logging.info("Indexing phenotypes")
@@ -514,7 +514,6 @@ def create_xapian_index(xapian_directory: str, sql_uri: str,
                 db.set_metadata("generif-checksum", hash_generif_graph(sparql_uri).encode())
         for child in combined_index.iterdir():
             shutil.move(child, pathlib.Path(xapian_directory) / child.name)
-    build_directory.rmdir()
     logging.info("Index built")