Skip to content

Commit 9c1b901

Browse files
sjflemingbshifaw
andauthored
Fix cost (for methods cromwell), add explicit example (#278)
* Fix cost (for methods cromwell), add explicit example * Update cost unit test to query export_time * One more that I missed * Modify README for cost --------- Co-authored-by: bshifaw <[email protected]>
1 parent 4a485d4 commit 9c1b901

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ Cromshell is a CLI for submitting workflows to a Cromwell server and monitoring/
110110
* Requires the `bq_cost_table` key to exist in the cromshell
111111
configuration file and have a value equal to the BigQuery cost table
112112
for your GCP billing project.
113+
* For example, your `~/.cromshell/cromshell_config.json` should contain:
114+
```json
115+
{
116+
"cromwell_server": "<cromwell_server_url>",
117+
"requests_timeout": 5,
118+
"bq_cost_table": "<table_name>"
119+
}
120+
```
121+
where `<table_name>` can be found by navigating to [BigQuery](https://console.cloud.google.com/bigquery), selecting the appropriate google project, and locating the table containing cost information.
122+
123+
<img src="developer_docs/img/bq_cost_table.png" alt="BigQuery example image" width="500"/>
124+
125+
Clicking on the table and opening the "DETAILS" tab, you'll find the exact path to the table in the "Table ID" section. Everything after the google project name (after the first `.`) should be included in `<table_name>`.
113126
* `-c/--color` Color outliers in task level cost results.
114127
* `-d/--detailed` Get the cost for a workflow at the task level.
115128

developer_docs/img/bq_cost_table.png

133 KB
Loading

src/cromshell/cost/command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,15 +182,15 @@ def create_bq_query(detailed: bool, bq_cost_table: str) -> str:
182182
AND task.key LIKE "wdl-task-name"
183183
AND wfid.key LIKE "cromwell-workflow-id"
184184
AND wfid.value like @workflow_id
185-
AND partition_time BETWEEN @start_date AND @end_date
185+
AND export_time BETWEEN @start_date AND @end_date
186186
GROUP BY 1,2,3
187187
ORDER BY 4 DESC
188188
"""
189189
else:
190190
return f"""
191191
SELECT sum(cost) as cost
192192
FROM {bq_cost_table}, UNNEST(labels)
193-
WHERE value LIKE @workflow_id AND partition_time BETWEEN @start_date AND @end_date
193+
WHERE value LIKE @workflow_id AND export_time BETWEEN @start_date AND @end_date
194194
"""
195195

196196

tests/unit/test_cost.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class TestCost:
2323
AND task.key LIKE "wdl-task-name"
2424
AND wfid.key LIKE "cromwell-workflow-id"
2525
AND wfid.value like @workflow_id
26-
AND partition_time BETWEEN @start_date AND @end_date
26+
AND export_time BETWEEN @start_date AND @end_date
2727
GROUP BY 1,2,3
2828
ORDER BY 4 DESC
2929
""",
@@ -34,7 +34,7 @@ class TestCost:
3434
"""
3535
SELECT sum(cost) as cost
3636
FROM cost:table1, UNNEST(labels)
37-
WHERE value LIKE @workflow_id AND partition_time BETWEEN @start_date AND @end_date
37+
WHERE value LIKE @workflow_id AND export_time BETWEEN @start_date AND @end_date
3838
""",
3939
],
4040
],

0 commit comments

Comments
 (0)