Skip to content

Commit

Permalink
adding the run id to the run directory
Browse files Browse the repository at this point in the history
  • Loading branch information
PhillipsOwen committed Mar 6, 2024
1 parent c8a64bf commit 6488bf0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
11 changes: 9 additions & 2 deletions src/staging/staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -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)
Expand Down
30 changes: 15 additions & 15 deletions src/tests/test_staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -42,28 +42,28 @@ 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')

# 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)
Expand All @@ -74,26 +74,26 @@ 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)

# 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")
Expand Down

0 comments on commit 6488bf0

Please sign in to comment.