diff --git a/socialgene/neo4j/utils/admin_import.py b/socialgene/neo4j/utils/admin_import.py index e2af8464..02a57672 100644 --- a/socialgene/neo4j/utils/admin_import.py +++ b/socialgene/neo4j/utils/admin_import.py @@ -159,13 +159,25 @@ def _check_files(self): else: log.info("Found all expected input files. Huzzah!") - def _neo4j_admin_import_args(self, docker=False): + def _neo4j_admin_import_args(self, docker=False, dryrun=False): """Function used to create a list of all the commands/arguments for a docker/neo4j admin import run Returns: list: commands/arguments to pass to a subprocess """ + if dryrun: + docker_command = [ + "#!/bin/bash", + "# This script was generated by the SocialGene python package", + "# It is meant to be run in the same directory as the neo4j import directory", + "# otherwise you should change neo4j_top_dir to the correct path that contains", + "# the neo4j import, data, and plugins directories and the import.report file", + "neo4j_top_dir = $(realpath)" "", + ] + else: + neo4j_top_dir = self.neo4j_top_dir + docker_command = [] docker_command = [ "docker", "run", @@ -173,10 +185,10 @@ def _neo4j_admin_import_args(self, docker=False): "--interactive", f"--publish={self.dbms_connector_http_listen_address}:{self.dbms_connector_http_listen_address}", f"--publish={self.dbms_connector_bolt_listen_address}:{self.dbms_connector_bolt_listen_address}", - f"--volume={self.neo4j_top_dir}/data:/opt/conda/bin/neo4j/data", - f"--volume={self.neo4j_top_dir}/import:/opt/conda/bin/neo4j/import", - f"--volume={self.neo4j_top_dir}/plugins:/opt/conda/bin/neo4j/plugins", - f"--volume={self.neo4j_top_dir}/import.report:/opt/conda/bin/neo4j/import.report", + f"--volume={neo4j_top_dir}/data:/opt/conda/bin/neo4j/data", + f"--volume={neo4j_top_dir}/import:/opt/conda/bin/neo4j/import", + f"--volume={neo4j_top_dir}/plugins:/opt/conda/bin/neo4j/plugins", + f"--volume={neo4j_top_dir}/import.report:/opt/conda/bin/neo4j/import.report", f"--user={self.uid}:{self.gid}", f"chasemc2/sgnf-sgpy:{self.docker_version}", ] @@ -222,7 +234,7 @@ def _prerun(self): def run(self, docker=False, dryrun=False): """Run the created commands/arguments in a separate process""" self._prerun() - cmd_arg_list = self._neo4j_admin_import_args(docker) + cmd_arg_list = self._neo4j_admin_import_args(docker=docker, dryrun=dryrun) if dryrun: return cmd_arg_list else: