You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10
Original file line number
Diff line number
Diff line change
@@ -98,6 +98,16 @@ requires `column`, `curl`, `mail`, and [jq](https://stedolan.github.io/jq/)
98
98
#### Update cromwell server
99
99
*`update-server`
100
100
* Change the cromwell server that new jobs will be submitted to.
101
+
102
+
#### Get cost for a workflow
103
+
* `cost`
104
+
* Get the cost for a workflow.
105
+
* Will only work for workflows that completed more than 8 hours ago on GCS.
106
+
* Requires the `gcp_bq_cost_table.config` configuration file to exist and contain the big query cost table for your organization.
107
+
* `cost-detailed`
108
+
* Get the cost for a workflow at the task level.
109
+
* Will only work for workflows that completed more than 8 hours ago on GCS.
110
+
* Requires the `gcp_bq_cost_table.config` configuration file to exist and contain the big query cost table for your organization.
101
111
102
112
### Features:
103
113
* Running `submit` will create a new folder in the `~/.cromshell/${CROMWELL_URL}/` directory named with the cromwell job id of the newly submitted job.
# Update cromshell submissions file if it needs updating:
48
51
grep -q 'ALIAS$'${CROMWELL_SUBMISSIONS_FILE}
49
52
r=$?
@@ -207,6 +210,20 @@ function usage()
207
210
echo -e " Update cromwell server:"
208
211
echo -e " update-server Change which cromwell server jobs will be submitted to."
209
212
echo -e ""
213
+
echo -e " Get cost for a workflow"
214
+
echo -e " cost [workflow-id] [[workflow-id]...] Get the cost for a workflow."
215
+
echo -e " Only works for workflows that completed"
216
+
echo -e " more than 8 hours ago on GCS."
217
+
echo -e " Requires the 'gcp_bq_cost_table.config'"
218
+
echo -e " configuration file to exist and contain"
219
+
echo -e " the big query cost table for your organization."
220
+
echo -e " cost-detailed [workflow-id] [[workflow-id]...] Get the cost for a workflow at the task level."
221
+
echo -e " Only works for workflows that completed"
222
+
echo -e " more than 8 hours ago on GCS."
223
+
echo -e " Requires the 'gcp_bq_cost_table.config'"
224
+
echo -e " configuration file to exist and contain"
225
+
echo -e " the big query cost table for your organization."
226
+
echo -e ""
210
227
echo -e "Return values:"
211
228
echo -e " 0 SUCCESS"
212
229
echo -e " ANYTHING_BUT_ZERO FAILURE/ERROR"
@@ -1471,6 +1488,148 @@ function fetch-all()
1471
1488
return 0
1472
1489
}
1473
1490
1491
+
function_cost_helper()
1492
+
{
1493
+
local id=$1
1494
+
local svr=$2
1495
+
1496
+
turtle
1497
+
which bq &>/dev/null
1498
+
local r=$?
1499
+
[[ ${r}-ne 0 ]] && error "bq does not exist. Must install the big query command-line client."&&exit 8
1500
+
1501
+
# Check for gdate:
1502
+
if [[ "$(uname)"=="Darwin" ]] ;then
1503
+
which gdate &> /dev/null
1504
+
r=$?
1505
+
[ $r-ne 0 ] && error "Must have coreutils installed for 'gdate'"&&exit 13
1506
+
fi
1507
+
1508
+
[ !-e${BQ_COST_TABLE_FILE} ] && error "Big Query cost table file does not exist. Must populate ${BQ_COST_TABLE_FILE} with big query cost table information."&&exit 9
1509
+
1510
+
# Make sure the given ID is actually in our file:
1511
+
grep -q "${id}"${CROMWELL_SUBMISSIONS_FILE}
1512
+
r=$?
1513
+
[ $r-ne 0 ] && error "Given ID is not in your cromwell submissions file (${CROMWELL_SUBMISSIONS_FILE}): ${id}"&&exit 10
bq query --use_legacy_sql=false "SELECT sum(cost) FROM \`${COST_TABLE}\`, UNNEST(labels) WHERE value = \"cromwell-${id}\" AND _PARTITIONDATE BETWEEN \"${START_DATE}\" AND \"${END_DATE}\";">${tmp_cost_file}
0 commit comments