-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/task-and-output-test-coverage #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
geneticsjesse
wants to merge
108
commits into
main
Choose a base branch
from
feature/task-and-output-test-coverage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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'…
3727b17
Add command to calculate coverage for each task and output
ceeb069
Add initial version of script/CLI command to output task and output c…
0b940ef
Make minor formatting adjustments
4abf55a
Make more minor formatting adjustments
2425e70
Remove check and append to list for tests with no tasks
cf8a6ed
Adjust formatting of print statements
45f99e8
Remove creation of unused list
013cdec
Adjust style of warnings to match internal format
0eea505
Initial commit for handling output key errors
bf59f2d
Add error message for when an output key is not found
89e896c
Add error message for when an output key is not found
bdd8e82
Reorganize and simplify handling of missing outputs key error
4ba4380
Further reorganize and simplify handling of missing outputs key error
76dda77
Fix creation of list of outputs
6171a33
Adjust style of warnings to match internal format
ebd8a3d
Merge branch 'develop' into feature/task-and-output-test-coverage
hkeward 0639e9a
Test handling of output key error in submit script instead of write_w…
bd269ed
Add comments for clarity
331d6e8
Merge branch 'feature/task-and-output-test-coverage' into feature/han…
geneticsjesse 2efa231
Revert all commits that handled output key errors in write_workflow
5334c53
Merge pull request #49 from DNAstack/feature/handle-output-key-error
geneticsjesse 09d4094
Add documentation surrounding wdl-ci coverage command
b46ffae
Rename subcommand; remove old subcommand script
f611b09
Add coverage subcommand to calculate and display test coverage
8d9d5ce
Adjust subcommand to handle compound outputs; clean up calculations
d8c0ad7
Adjust formatting/organization of task coverage output
5bb45db
Wrap task name properly
2f0e8cc
Clarify parameter precedence
hkeward 3ac87fc
Improve coverage calculation login; add specific warning for optional…
0a762f0
Merge branch 'feature/task-and-output-test-coverage' of https://githu…
8498965
Add threshold and workflow name arguments to coverage command
8e88ad1
Implement usage of threshold and workflow name within coverage command
a29df08
Add context to new features of wdl-ci coverage
a998e8f
Clean up documentation
eec18b2
Merge branch 'main' of https://github.com/DNAstack/wdl-ci into featur…
624b22a
Make formatting changes
b6a665e
Report to user any optional input not covered as part of wdl-ci tests
c4da040
Comment out print statement re: optional inputs; add relevant TODO
fb07f30
Remove unused input checking code; adjust TODO
09057ef
Merge branch 'main' into feature/task-and-output-test-coverage
hkeward 2f3248c
Rename coverage_threshold to target_coverage to make it a bit clearer
hkeward 149eb63
Update docs for changed arg name
hkeward 8b8b032
Remove comment and creation of set; add check for length to avoid fal…
b24c357
Clarify workflow file name is required
5052744
Avoid more false-y traps; remove redundant checks if threshold is not…
3ec8f62
Fix check for threshold > task_coverage or threshold not specified
ac61953
Avoid more false-ys; add TODOs
5538a07
Begin working through PR revisions; making holistic changes to test n…
262f0ea
Add function for repeated code and import/implement
fbf2645
Clarify how to provide workflow name based on changes to coverage com…
7c8bc76
Get command in a functional state based on PR revisions; UX changes a…
f180629
Remove some dev code and a TODO
3647f99
Add TODOs for more flags for the coverage command
2b88c42
Add working version but still in dev
12edb32
Remove redundant code that was refactored with helper functions
a66bde7
Remove unnecessary print
e79a4ad
Handle case where test_tasks is an empty list; would have considered …
4ed57c1
Adjust comment wording
f1c3ee0
Add .DS_STORE
4237fd4
Adjust TODO
e243224
Add tests for coverage handler -- in dev
8187b2b
Improve naming conventions of coverage_summary keys; set boolean flag…
086c75a
Add additional handling of boolean checks
3cebce8
Added extra test; rename coverage summary keys
c6e774c
Improve prints; return tested outputs for each {workflow.task}
36b712b
Suppress ResourceWarning; add additional tests to add; comment out se…
7ff888e
Move tests dir
9f83394
Fix typo
32c214d
Remove unused file with single test
f7166e0
Add more tests to add
3a2100e
Comment our warning suppression so I can handle it later
9156cdc
Adjust name of coverage_summary dict keys
ba14693
Add threshold to test
4c589e2
rename test
a8833d4
Rename key
660f8be
Improve naming conventions
987a03c
Add explicit tests for any remaining instances of if <varname>
074bde5
Add clarity in some comments; add single TODO
0a0ec33
Avoid adding to untested_outputs_dict if there are no missing outputs
d6c82f4
Avoid adding to tested_outputs_dict if there are no tested outputs
351a3ad
Add a class method to reset the config and reset it at the end of the…
9e5a19b
Redirect stdout to hide coverage output; suppress warning as part of …
586ce4d
Set tasks below threshold to false if there is the workflow is skippe…
98e2c31
Add more tests; still in dev
b271da1
Set tasks_below_threshold to false if workflows are skipped based on …
2a59feb
Set workflow_found via else explicitly
47c97df
Remove TODO
9a667b9
Add three threshold tests; add test for optional inputs
db6c3fd
Clarify TODO
a727fbf
Remove TODO; improve naming of all tests list; handle case where no o…
1645d98
Remove another TODO
59e65cc
Rename for clarity
b1f68b9
Simplify workflow_name_filter returned to user; remove check for filt…
b2e46a9
Add test todo
3385477
Remove comment; explicitly check workflow name; rename function for c…
b21590a
Move reset of config into a finally block
87b6ae9
Adjust if to elif
7396c86
Add todo
b391d6e
Simplify checking for missing outputs
hkeward ac98336
Allow multiple workflow filters to be passed
hkeward 7def2da
Move coverage summary inside function; change strategy for detecting
hkeward db8950c
Moved final output messages around
hkeward 6d49270
Add skipped workflows to check prior to printing warnings
2103dac
Adjust total and workflow output counts to lists; write function to u…
f4d8b57
Remove redundant code; begin trying to handle nested imports - in dev
8c650d0
Revert "Remove redundant code; begin trying to handle nested imports …
e369b38
Revert "Adjust total and workflow output counts to lists; write funct…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.