From 6ba1da4fb7184dd8036f7aaa2bd2171ed1e2faf0 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Wed, 12 Jun 2024 18:39:55 +0300 Subject: 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 --- scripts/index-genenetwork | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'scripts') 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") -- cgit v1.2.3