Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DI-809 - fix upload of output file to job destination #15

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/vcf_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,22 @@ def upload_output_file(outfile) -> None:
outfile : str
name of file to upload
"""
print(f"\nUploading {outfile}")
output_project = os.environ.get("DX_PROJECT_CONTEXT_ID")
output_folder = (
dxpy.bindings.dxjob.DXJob(os.environ.get("DX_JOB_ID"))
.describe()
.get("folder", "/")
)
print(f"\nUploading {outfile} to {output_project}:{output_folder}")

dxpy.set_workspace_id(output_project)
dxpy.api.project_new_folder(
output_project, input_params={"folder": output_folder, "parents": True}
)

url_file = dxpy.upload_local_file(
filename=outfile,
folder=dxpy.bindings.dxjob.DXJob(
os.environ.get("DX_JOB_ID")
).describe()["folder"],
folder=output_folder,
wait_on_close=True,
)

Expand Down
7 changes: 5 additions & 2 deletions tests/test_vcf_qc.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,10 @@ def test_output_file_contents_correctly_written(self):


@patch("src.vcf_qc.dxpy.upload_local_file")
@patch("src.vcf_qc.dxpy.api.project_new_folder")
@patch("src.vcf_qc.dxpy.bindings.dxjob.DXJob")
class TestUploadOutputFile(unittest.TestCase):
def test_upload_params_correct(self, mock_job, mock_upload):
def test_upload_params_correct(self, mock_job, mock_folder, mock_upload):
mock_job.return_value.describe.return_value = {
"folder": "/output/sub_folder"
}
Expand All @@ -389,7 +390,9 @@ def test_upload_params_correct(self, mock_job, mock_upload):

self.assertEqual(mock_upload.call_args[1], expected_args)

def test_expected_dxlink_format_returned(self, mock_job, mock_upload):
def test_expected_dxlink_format_returned(
self, mock_job, mock_folder, mock_upload
):
mock_upload.return_value = "file-xxx"

self.assertEqual(
Expand Down
Loading