Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
7333647
Merge branch 'bugfix/avoid-detecting-changes-for-tasks-with-no-tests'…
Mar 5, 2024
3727b17
Add command to calculate coverage for each task and output
Mar 5, 2024
ceeb069
Add initial version of script/CLI command to output task and output c…
Mar 6, 2024
0b940ef
Make minor formatting adjustments
Mar 6, 2024
4abf55a
Make more minor formatting adjustments
Mar 6, 2024
2425e70
Remove check and append to list for tests with no tasks
Mar 6, 2024
cf8a6ed
Adjust formatting of print statements
Mar 6, 2024
45f99e8
Remove creation of unused list
Mar 7, 2024
013cdec
Adjust style of warnings to match internal format
Mar 7, 2024
0eea505
Initial commit for handling output key errors
Mar 7, 2024
bf59f2d
Add error message for when an output key is not found
Mar 8, 2024
89e896c
Add error message for when an output key is not found
Mar 8, 2024
bdd8e82
Reorganize and simplify handling of missing outputs key error
Mar 11, 2024
4ba4380
Further reorganize and simplify handling of missing outputs key error
Mar 11, 2024
76dda77
Fix creation of list of outputs
Mar 12, 2024
6171a33
Adjust style of warnings to match internal format
Mar 13, 2024
ebd8a3d
Merge branch 'develop' into feature/task-and-output-test-coverage
hkeward Mar 13, 2024
0639e9a
Test handling of output key error in submit script instead of write_w…
Mar 14, 2024
bd269ed
Add comments for clarity
Mar 14, 2024
331d6e8
Merge branch 'feature/task-and-output-test-coverage' into feature/han…
geneticsjesse Mar 14, 2024
2efa231
Revert all commits that handled output key errors in write_workflow
Mar 14, 2024
5334c53
Merge pull request #49 from DNAstack/feature/handle-output-key-error
geneticsjesse Mar 27, 2024
09d4094
Add documentation surrounding wdl-ci coverage command
Mar 27, 2024
b46ffae
Rename subcommand; remove old subcommand script
Apr 4, 2024
f611b09
Add coverage subcommand to calculate and display test coverage
Apr 4, 2024
8d9d5ce
Adjust subcommand to handle compound outputs; clean up calculations
Apr 5, 2024
d8c0ad7
Adjust formatting/organization of task coverage output
Apr 5, 2024
5bb45db
Wrap task name properly
Nov 15, 2024
2f0e8cc
Clarify parameter precedence
hkeward Nov 18, 2024
3ac87fc
Improve coverage calculation login; add specific warning for optional…
Nov 21, 2024
0a762f0
Merge branch 'feature/task-and-output-test-coverage' of https://githu…
Nov 21, 2024
8498965
Add threshold and workflow name arguments to coverage command
Nov 21, 2024
8e88ad1
Implement usage of threshold and workflow name within coverage command
Nov 21, 2024
a29df08
Add context to new features of wdl-ci coverage
Nov 21, 2024
a998e8f
Clean up documentation
Nov 22, 2024
eec18b2
Merge branch 'main' of https://github.com/DNAstack/wdl-ci into featur…
Nov 22, 2024
624b22a
Make formatting changes
Nov 22, 2024
b6a665e
Report to user any optional input not covered as part of wdl-ci tests
Nov 22, 2024
c4da040
Comment out print statement re: optional inputs; add relevant TODO
Nov 22, 2024
fb07f30
Remove unused input checking code; adjust TODO
Nov 25, 2024
09057ef
Merge branch 'main' into feature/task-and-output-test-coverage
hkeward Nov 29, 2024
2f3248c
Rename coverage_threshold to target_coverage to make it a bit clearer
hkeward Nov 29, 2024
149eb63
Update docs for changed arg name
hkeward Nov 29, 2024
8b8b032
Remove comment and creation of set; add check for length to avoid fal…
Dec 5, 2024
b24c357
Clarify workflow file name is required
Dec 5, 2024
5052744
Avoid more false-y traps; remove redundant checks if threshold is not…
Dec 5, 2024
3ec8f62
Fix check for threshold > task_coverage or threshold not specified
Dec 5, 2024
ac61953
Avoid more false-ys; add TODOs
Dec 6, 2024
5538a07
Begin working through PR revisions; making holistic changes to test n…
Dec 6, 2024
262f0ea
Add function for repeated code and import/implement
Dec 9, 2024
fbf2645
Clarify how to provide workflow name based on changes to coverage com…
Dec 10, 2024
7c8bc76
Get command in a functional state based on PR revisions; UX changes a…
Dec 10, 2024
f180629
Remove some dev code and a TODO
Dec 10, 2024
3647f99
Add TODOs for more flags for the coverage command
Dec 12, 2024
2b88c42
Add working version but still in dev
Dec 12, 2024
12edb32
Remove redundant code that was refactored with helper functions
Dec 12, 2024
a66bde7
Remove unnecessary print
Dec 13, 2024
e79a4ad
Handle case where test_tasks is an empty list; would have considered …
Dec 13, 2024
4ed57c1
Adjust comment wording
Dec 13, 2024
f1c3ee0
Add .DS_STORE
Dec 13, 2024
4237fd4
Adjust TODO
Dec 13, 2024
e243224
Add tests for coverage handler -- in dev
Dec 13, 2024
8187b2b
Improve naming conventions of coverage_summary keys; set boolean flag…
Dec 13, 2024
086c75a
Add additional handling of boolean checks
Dec 13, 2024
3cebce8
Added extra test; rename coverage summary keys
Dec 13, 2024
c6e774c
Improve prints; return tested outputs for each {workflow.task}
Dec 13, 2024
36b712b
Suppress ResourceWarning; add additional tests to add; comment out se…
Dec 13, 2024
7ff888e
Move tests dir
Dec 13, 2024
9f83394
Fix typo
Dec 13, 2024
32c214d
Remove unused file with single test
Dec 13, 2024
f7166e0
Add more tests to add
Dec 13, 2024
3a2100e
Comment our warning suppression so I can handle it later
Dec 13, 2024
9156cdc
Adjust name of coverage_summary dict keys
Dec 13, 2024
ba14693
Add threshold to test
Dec 13, 2024
4c589e2
rename test
Dec 13, 2024
a8833d4
Rename key
Dec 13, 2024
660f8be
Improve naming conventions
Dec 13, 2024
987a03c
Add explicit tests for any remaining instances of if <varname>
Dec 13, 2024
074bde5
Add clarity in some comments; add single TODO
Dec 13, 2024
0a0ec33
Avoid adding to untested_outputs_dict if there are no missing outputs
Dec 14, 2024
d6c82f4
Avoid adding to tested_outputs_dict if there are no tested outputs
Dec 14, 2024
351a3ad
Add a class method to reset the config and reset it at the end of the…
Dec 14, 2024
9e5a19b
Redirect stdout to hide coverage output; suppress warning as part of …
Dec 14, 2024
586ce4d
Set tasks below threshold to false if there is the workflow is skippe…
Dec 14, 2024
98e2c31
Add more tests; still in dev
Dec 14, 2024
b271da1
Set tasks_below_threshold to false if workflows are skipped based on …
Dec 16, 2024
2a59feb
Set workflow_found via else explicitly
Dec 16, 2024
47c97df
Remove TODO
Dec 16, 2024
9a667b9
Add three threshold tests; add test for optional inputs
Dec 16, 2024
db6c3fd
Clarify TODO
Dec 16, 2024
a727fbf
Remove TODO; improve naming of all tests list; handle case where no o…
Dec 16, 2024
1645d98
Remove another TODO
Dec 16, 2024
59e65cc
Rename for clarity
Dec 16, 2024
b1f68b9
Simplify workflow_name_filter returned to user; remove check for filt…
Dec 16, 2024
b2e46a9
Add test todo
Dec 17, 2024
3385477
Remove comment; explicitly check workflow name; rename function for c…
Dec 17, 2024
b21590a
Move reset of config into a finally block
Dec 18, 2024
87b6ae9
Adjust if to elif
Dec 18, 2024
7396c86
Add todo
Dec 18, 2024
b391d6e
Simplify checking for missing outputs
hkeward Dec 18, 2024
ac98336
Allow multiple workflow filters to be passed
hkeward Dec 18, 2024
7def2da
Move coverage summary inside function; change strategy for detecting
hkeward Dec 18, 2024
db8950c
Moved final output messages around
hkeward Dec 18, 2024
6d49270
Add skipped workflows to check prior to printing warnings
Dec 20, 2024
2103dac
Adjust total and workflow output counts to lists; write function to u…
Jan 8, 2025
f4d8b57
Remove redundant code; begin trying to handle nested imports - in dev
Jan 8, 2025
8c650d0
Revert "Remove redundant code; begin trying to handle nested imports …
Jan 8, 2025
e369b38
Revert "Adjust total and workflow output counts to lists; write funct…
Jan 8, 2025
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
10 changes: 10 additions & 0 deletions src/wdlci/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
from wdlci.cli.submit import submit_handler
from wdlci.cli.monitor import monitor_handler
from wdlci.cli.cleanup import cleanup_handler
from wdlci.cli.detect_task_and_output_coverage import (
Comment thread
geneticsjesse marked this conversation as resolved.
Outdated
detect_task_and_output_coverage_handler,
)
from wdlci.utils.ordered_group import OrderedGroup

remove_option = click.option(
Expand Down Expand Up @@ -100,3 +103,10 @@ def cleanup(**kwargs):
"""Clean Workbench namespace of transient artifacts"""

cleanup_handler(kwargs)


@main.command
def detect_task_and_output_coverage(**kwargs):
"""Outputs how much coverage each task and output has, and which tasks/outputs have no associated tests"""

detect_task_and_output_coverage_handler(kwargs)
6 changes: 0 additions & 6 deletions src/wdlci/cli/detect_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@ def detect_changes_handler(kwargs):

changeset = Changeset()

tasks_without_tests = []

for workflow, workflow_config in config.file.workflows.items():
doc = WDL.load(workflow)

for task in doc.tasks:
task_name = task.name
task_digest = task.digest

if not workflow_config.tasks[task_name].tests:
tasks_without_tests.append(task_name)

if task_name in workflow_config.tasks:
previous_digest = workflow_config.tasks[task_name].digest
if (
Expand All @@ -40,7 +35,6 @@ def detect_changes_handler(kwargs):
print(f"New task detected [{workflow} - {task_name}]")
workflow_change = changeset.add_workflow_change(workflow)
workflow_change.add_task_change(task_name)
print(f"The following tasks have no tests: {', '.join(tasks_without_tests)}")

if len(changeset.workflow_changes) == 0:
print("No new or modified tasks detected")
Expand Down
84 changes: 84 additions & 0 deletions src/wdlci/cli/detect_task_and_output_coverage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import sys
import WDL
from wdlci.config import Config
from wdlci.config.config_file import WorkflowTaskConfig, WorkflowTaskTestConfig
from wdlci.exception.wdl_test_cli_exit_exception import WdlTestCliExitException


def detect_task_and_output_coverage_handler(kwargs):
try:
Config.load(kwargs)
config = Config.instance()

tasks_without_tests = []
outputs_without_tests = []

task_coverage = {}
output_coverage = {}

for workflow, workflow_config in config.file.workflows.items():
doc = WDL.load(workflow)

for task in doc.tasks:
task_name = task.name
# task_test_configs is a list of WorkflowTaskTestConfig objects,
# which contain inputs and output_tests as attributes
task_test_configs = workflow_config.tasks[task_name].tests

if not task_test_configs:
tasks_without_tests.append(task_name)

task_coverage_count = 0

for task_test_config in task_test_configs:
output_tests_dict = task_test_config.output_tests
output_coverage[task_name] = {}

for output_key, output_value in output_tests_dict.items():
if (
isinstance(output_value, dict)
and "test_tasks" in output_value
):
output_tests_list = output_value["test_tasks"]
# Assign the length of test tasks to the key associated with a
# given output in a nested structure, where each task has a
# dictionary of outputs and their task counts
output_coverage[task_name][output_key] = len(
output_tests_list
)
task_coverage_count += len(output_tests_list)

if not output_tests_list:
outputs_without_tests.append(output_key)

task_coverage[task_name] = task_coverage_count

print("Task Coverage:")
for task_name, tests_count in task_coverage.items():
print(f"\t{task_name}: {tests_count}")

print("\nOutput coverage:")
for task_name, output_tests_dict in output_coverage.items():
print(f"\tTask name: {task_name}")
for output_name, tests_count in output_tests_dict.items():
print(
f"\t\tOutput name: {output_name}\n\t\t\tnumber of tests: {tests_count}"
)

if tasks_without_tests and outputs_without_tests:
print(
f"[WARN]: The following tasks have no tests:\n{', '.join(tasks_without_tests)}\n\n"
+ f"Additionally, the following outputs have no tests:\n{', '.join(outputs_without_tests)}\n\n"
)
elif tasks_without_tests:
print(
f"[WARN]: The following tasks have no tests:\n{', '.join(tasks_without_tests)}\n\n"
)
elif outputs_without_tests:
print(
f"[WARN]: The following outputs have no tests:\n{', '.join(outputs_without_tests)}\n\n"
)

except WdlTestCliExitException as e:
print(f"exiting with code {e.exit_code}, message: {e.message}")
sys.exit(e.exit_code)
47 changes: 47 additions & 0 deletions src/wdlci/wdl_tests/check_zip.wdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
version 1.0

# Check integrity of ZIP file
# Input type: ZIP file

task check_zip {
input {
File current_run_output
File validated_output
}

Int disk_size = ceil(size(current_run_output, "GB") + size(validated_output, "GB") + 50)

command <<<
set -euo pipefail

err() {
message=$1

echo -e "[ERROR] $message" >&2
}

if ! zip -T ~{validated_output}; then
err "Validated file: [~{basename(validated_output)}] did not pass zip check"
exit 1
else
if ! zip -T ~{current_run_output}; then
err "Current run file: [~{basename(current_run_output)}] did not pass zip check"
exit 1
else
echo "Current run file: [~{basename(current_run_output)}] passed zip check"
fi
fi
>>>

output {
}

runtime {
docker: "dnastack/dnastack-wdl-ci-tools:0.0.1"
cpu: 1
memory: "3.75 GB"
disk: disk_size + " GB"
disks: "local-disk " + disk_size + " HDD"
preemptible: 1
}
}