Skip to content

Commit

Permalink
fix: improve Neo4j admin import dry run script
Browse files Browse the repository at this point in the history
  • Loading branch information
chasemc committed Oct 22, 2024
1 parent 8b0e96e commit 9f42252
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions socialgene/neo4j/utils/admin_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,24 +159,36 @@ 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",
"--rm",
"--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}",
]
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 9f42252

Please sign in to comment.