Skip to content

Commit

Permalink
cli: fix download when workflow does not have outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonadoni committed Nov 13, 2023
1 parent fd6fc24 commit 73ccc51
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
9 changes: 5 additions & 4 deletions cmd/download.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of REANA.
Copyright (C) 2022 CERN.
Copyright (C) 2022, 2023 CERN.
REANA is free software; you can redistribute it and/or modify it
under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -95,9 +95,10 @@ func (o *downloadOptions) run(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
downloadFiles := spec.Specification.Outputs.Files
downloadDirs := spec.Specification.Outputs.Directories
downloadPaths = append(downloadFiles, downloadDirs...)
if outputs := spec.Specification.Outputs; outputs != nil {
downloadPaths = append(downloadPaths, outputs.Files...)
downloadPaths = append(downloadPaths, outputs.Directories...)
}
}
log.Debugf("Download paths: %s", strings.Join(downloadPaths, ", "))

Expand Down
11 changes: 10 additions & 1 deletion cmd/download_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of REANA.
Copyright (C) 2022 CERN.
Copyright (C) 2022, 2023 CERN.
REANA is free software; you can redistribute it and/or modify it
under the terms of the MIT License; see LICENSE file for more details.
Expand Down Expand Up @@ -45,6 +45,15 @@ func TestFileDownload(t *testing.T) {
fmt.Sprintf("%s was successfully downloaded.", fileName),
},
},
"download from workflow without outputs": {
serverResponses: map[string]ServerResponse{
fmt.Sprintf(downloadWorkflowSpecServerPath, "my_workflow"): {
statusCode: http.StatusOK,
responseFile: "workflow_specification_without_outputs.json",
},
},
args: []string{"-w", "my_workflow"},
},
"download file specified as argument": {
serverResponses: map[string]ServerResponse{
fmt.Sprintf(downloadServerPath, "my_workflow", fileName): {
Expand Down
40 changes: 40 additions & 0 deletions testdata/inputs/workflow_specification_without_outputs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"parameters": {},
"specification": {
"inputs": {
"files": [
"code/gendata.C",
"code/fitdata.C"
],
"parameters": {
"data": "results/data.root",
"events": 20000,
"plot": "results/plot.png"
}
},
"version": "0.6.0",
"workflow": {
"specification": {
"steps": [
{
"commands": [
"mkdir -p results && root -b -q 'code/gendata.C(${events},\"${data}\")'"
],
"environment": "reanahub/reana-env-root6:6.18.04",
"kubernetes_memory_limit": "256Mi",
"name": "gendata"
},
{
"commands": [
"root -b -q 'code/fitdata.C(\"${data}\",\"${plot}\")'"
],
"environment": "reanahub/reana-env-root6:6.18.04",
"kubernetes_memory_limit": "256Mi",
"name": "fitdata"
}
]
},
"type": "serial"
}
}
}

0 comments on commit 73ccc51

Please sign in to comment.