From 8cb66b4e223913027a3a7e3a97a6bcc5556b6e38 Mon Sep 17 00:00:00 2001 From: Finn Gruwier Larsen Date: Tue, 28 Nov 2023 11:25:34 +0100 Subject: [PATCH] Export dir as envvar --- bifrost_chewbbaca/run_standalone.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bifrost_chewbbaca/run_standalone.py b/bifrost_chewbbaca/run_standalone.py index 704f078..aab6559 100755 --- a/bifrost_chewbbaca/run_standalone.py +++ b/bifrost_chewbbaca/run_standalone.py @@ -99,7 +99,8 @@ def run_pipeline(self): if __name__ == '__main__': - assert os.path.exists('~/mongoexports') + export_dir = pathlib.Path(os.environ["MONGOEXPORT_DIR"]) + assert export_dir.exists() start_time = datetime.now() instance = BifrostchewBBACA() instance.run_pipeline() @@ -108,9 +109,10 @@ def run_pipeline(self): print(f"Run took {run_time.seconds} seconds") print("Will now run mongoexport") export_filename = now.isoformat(timespec='seconds').replace(':', '') + '.json' - path = f"~/mongoexports/{export_filename}" + export_filepath = pathlib.Path(export_dir, export_filename) + print(f"Export will be saved in {export_filepath}") command = \ - f"mongoexport --db bifrost_test_db --collection samples --pretty --out {path}" + f"mongoexport --db bifrost_test_db --collection samples --pretty --out {str(export_filepath)}" process: subprocess.Popen = subprocess.Popen( command, stdout=sys.stdout, stderr=sys.stderr, shell=True )