Skip to content

Commit ad30776

Browse files
authored
Fixes cost and detailed cost queries for new billing setup as of 2022 Aug 11 (#219)
* Updated `_PARTITIONTIME` to `partition_time` as per SADA billing changes. * Fixing parsing error in `cost-detailed` function.
1 parent e119c23 commit ad30776

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cromshell

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ function cost()
15881588
local tmp_cost_file=$( makeTemp )
15891589

15901590
# Get the cost from Big Query:
1591-
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}
1591+
bq query --use_legacy_sql=false "SELECT sum(cost) FROM \`${COST_TABLE}\`, UNNEST(labels) WHERE value = \"cromwell-${id}\" AND partition_time BETWEEN \"${START_DATE}\" AND \"${END_DATE}\";" > ${tmp_cost_file}
15921592
r=$?
15931593

15941594
# Display the cost:
@@ -1626,14 +1626,14 @@ function cost-detailed()
16261626
AND task.key LIKE \"wdl-task-name\"
16271627
AND wfid.key LIKE \"cromwell-workflow-id\"
16281628
AND wfid.value like \"%${id}\"
1629-
AND _PARTITIONDATE BETWEEN \"${START_DATE}\" AND \"${END_DATE}\"
1629+
AND partition_time BETWEEN \"${START_DATE}\" AND \"${END_DATE}\"
16301630
GROUP BY 1,2,3
16311631
ORDER BY 4 DESC
16321632
;" | tail -n+4 | grep -v '^+' | tr -d '|' | awk 'BEGIN{OFS="\t"}{print $(NF-1), $NF}' | sort > ${tmp_cost_file}
16331633

16341634
r=$?
16351635

1636-
local total_cost=$(awk '{print $2}' ${tmp_cost_file} | tr '\n' '+' | sed 's#$#0#' | bc)
1636+
local total_cost=$(awk '{print $2}' ${tmp_cost_file} | tr '\n' '~' | sed -e 's#$#0#' -e 's@~@ + @g' -e 's@^@print(@' -e 's@$@)@' | python)
16371637
local total_cost=$(echo "scale=2;${total_cost}/1" | bc)
16381638

16391639
local tmpf2=$(makeTemp)

0 commit comments

Comments
 (0)