From 6488bf070b47bfd5e24d77cb93f7ba222dd5c3a8 Mon Sep 17 00:00:00 2001 From: Phil Owen <19691521+PhillipsOwen@users.noreply.github.com> Date: Wed, 6 Mar 2024 13:08:54 -0500 Subject: [PATCH] adding the run id to the run directory --- src/staging/staging.py | 11 +++++++++-- src/tests/test_staging.py | 30 +++++++++++++++--------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/staging/staging.py b/src/staging/staging.py index 65fe99b..b249469 100644 --- a/src/staging/staging.py +++ b/src/staging/staging.py @@ -87,6 +87,9 @@ def initial_staging(self, run_id: str, run_dir: str, staging_type: StagingType, workflow_type) try: + # create the full run directory name + run_dir = os.path.join(run_dir, run_id) + # try to make the call for records run_data: json = self.db_info.get_run_def(run_id) @@ -224,7 +227,7 @@ def create_test_files(self, run_dir: str, run_data: json, workflow_type: Workflo def final_staging(self, run_id: str, run_dir: str, staging_type: StagingType) -> int: """ - Performs the initial staging + Performs the final staging :param run_dir: The path of the directory to use for the staging operations. :param run_id: The ID of the supervisor run request. @@ -234,6 +237,9 @@ def final_staging(self, run_id: str, run_dir: str, staging_type: StagingType) -> # init the return code ret_val: int = ReturnCodes.EXIT_CODE_SUCCESS + # create the full run directory name + run_dir = os.path.join(run_dir, run_id) + self.logger.info('Final staging version %s start: run_dir: %s', self.app_version, run_dir) try: @@ -242,7 +248,8 @@ def final_staging(self, run_id: str, run_dir: str, staging_type: StagingType) -> self.logger.info('Run dir exists. run_dir: %s', run_dir) # do more things here. - + else: + ret_val = ReturnCodes.ERROR_NO_RUN_DIR except Exception: # declare ready self.logger.exception('Exception: The iRODS K8s "%s" final staging request for run directory %s failed.', staging_type, run_dir) diff --git a/src/tests/test_staging.py b/src/tests/test_staging.py index a4fc7f0..051961e 100644 --- a/src/tests/test_staging.py +++ b/src/tests/test_staging.py @@ -14,7 +14,7 @@ from src.common.staging_enums import StagingType, WorkflowTypeName, ReturnCodes -@pytest.mark.skip(reason="Local test only") +#@pytest.mark.skip(reason="Local test only") def test_run(): """ tests doing the normal operations for initial and final staging. @@ -42,7 +42,7 @@ def test_run(): assert ret_val == ReturnCodes.DB_ERROR # set a valid run ID - run_id: str = '3' + run_id: str = '68' # set up the test directory run_dir: str = os.path.join(os.getenv('TEST_PATH'), 'grp3') @@ -50,20 +50,20 @@ def test_run(): # make the call to do an initial stage ret_val = staging.run(run_id, run_dir, StagingType.INITIAL_STAGING, WorkflowTypeName.TOPOLOGY) - # make sure of a successful return code and a json file - assert ret_val == ReturnCodes.EXIT_CODE_SUCCESS and os.path.isfile(os.path.join(run_dir, 'PROVIDER_test_list.sh')) + # make sure of a successful return code and a bash file + assert ret_val == ReturnCodes.EXIT_CODE_SUCCESS and os.path.isfile(os.path.join(run_dir, run_id, 'PROVIDER_test_list.sh')) # make the call to do a final stage. this dir was created above so it should be removed ret_val = staging.run(run_id, run_dir, StagingType.FINAL_STAGING) - # make sure of a successful return code and a missing json file - assert ret_val == ReturnCodes.EXIT_CODE_SUCCESS and not os.path.isdir(run_dir) + # make sure of a successful return code and a missing file + assert ret_val == ReturnCodes.EXIT_CODE_SUCCESS # final no longer removes directories and not os.path.isdir(os.path.join(run_dir, run_id)) # make the call to do an initial stage ret_val = staging.run(run_id, run_dir, StagingType.INITIAL_STAGING, WorkflowTypeName.CORE) - # make sure of a successful return code and a json file - assert ret_val == ReturnCodes.EXIT_CODE_SUCCESS and os.path.isfile(os.path.join(run_dir, 'PROVIDER_test_list.sh')) + # make sure of a successful return code and a bash file + assert ret_val == ReturnCodes.EXIT_CODE_SUCCESS and os.path.isfile(os.path.join(run_dir, run_id, 'PROVIDER_test_list.sh')) # make the call to do a final stage. this is an invalid directory and should fail ret_val = staging.run(run_id, os.path.join(os.getenv('TEST_PATH'), '0'), StagingType.FINAL_STAGING, WorkflowTypeName.CORE) @@ -74,11 +74,11 @@ def test_run(): # make the call to do a final stage. this dir was created above so it should be removed ret_val = staging.run(run_id, run_dir, StagingType.FINAL_STAGING) - # make sure of a successful return code and a missing json file - assert ret_val == ReturnCodes.EXIT_CODE_SUCCESS and not os.path.isdir(run_dir) + # make sure of a successful return code and a missing bash file + assert ret_val == ReturnCodes.EXIT_CODE_SUCCESS # final no longer removes directories and not os.path.isdir(os.path.join(run_dir, run_id)) # set a valid run ID. however, although this one has an executor specified it has no tests listed in the DB - run_id: str = '9' + run_id: str = '67' # set up the test directory run_dir: str = os.path.join(os.getenv('TEST_PATH'), run_id) @@ -86,14 +86,14 @@ def test_run(): # make the call to do an initial stage ret_val = staging.run(run_id, run_dir, StagingType.INITIAL_STAGING, WorkflowTypeName.CORE) - # make sure of a successful return code and a json file - assert ret_val == ReturnCodes.EXIT_CODE_SUCCESS and not os.path.isfile(os.path.join(run_dir, 'PROVIDER_test_list.sh')) + # make sure of a successful return code and a bash file + assert ret_val == ReturnCodes.EXIT_CODE_SUCCESS and os.path.isfile(os.path.join(run_dir, run_id, 'PROVIDER_test_list.sh')) # make the call to do a final stage. this dir was created above so it should be removed ret_val = staging.run(run_id, run_dir, StagingType.FINAL_STAGING) - # make sure of a successful return code and a missing json file - assert ret_val == ReturnCodes.EXIT_CODE_SUCCESS and not os.path.isdir(run_dir) + # make sure of a successful return code and a missing bash file + assert ret_val == ReturnCodes.EXIT_CODE_SUCCESS # final no longer removes directories and not os.path.isdir(os.path.join(run_dir, run_id)) @pytest.mark.skip(reason="Local test only")