Skip to content

Instantly share code, notes, and snippets.

@feelobot
Created January 3, 2019 04:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feelobot/a51d778272c01d75bf0b639e872ad1b1 to your computer and use it in GitHub Desktop.
Save feelobot/a51d778272c01d75bf0b639e872ad1b1 to your computer and use it in GitHub Desktop.
guardant health data normalizer

About

Script that ingests ``*.robot` files and either outputs the json to the screen or uploads the data to the JAMA API

Config

  1. Create an API Token, Click Username in GUI -> Set API Credentils -> Create API Credentials (or use an existing credential)
  2. set the following ENVS: * JAMA_CLIENT_ID (created above) * JAMA_CLIENT_SECRET (created above) * JAMA_PROJECT_ID (derived from URL when viewing a project in the gui)

Basic Functionality

  1. Pass a robot file to script to convert to json (enable --dryrun to only output json):
./normalize_robot.py --dryrun cnv_pipeline.robot
  1. Pass a directory to script to automatically convert all files ending in .robot to json
./normalize_robot.py --dryrun ./
  1. Run and upload to JAMA API:
./normalize_robot.py ./cnv_pipeline.robot
  1. Enable verbosity to display info logs:
./normalize_robot.py -v ./
  1. Enable verbosity to display debug logs:
./normalize_robot.py -vv ./

Duplicates

Tests of the same name will not be re-added to the insert-tests folder, unless the test plan name differs in the robot text. The test plan name is extracted from the Defualt Tag: line in the robot text under settings.

ex. output with verbosity enabled:

checking for new test cases...
2018-01-03T11:37:10 Test case already exists: TC_CNV_1: Verify CNV run successfully
2018-01-03T11:37:10 Test case already exists: TC_CNV_2: Verify CNV load to GHDB successfully
2018-01-03T11:37:10 Test case already exists: TC_CNV_3:Verify output files generated by CNV pipeline
2018-01-03T11:37:10 Test case already exists: TC_CNV_4:Verify content in ghcnv_gene table in GHDB from CNV pipeline result
2018-01-03T11:37:10 Test case already exists: TC_CNV_5: Verify content in ghcnv_probe table in GHDB from CNV pipeline result
2018-01-03T11:37:10 Test case already exists: TC_CNV_6: Verify content in ghcnv_qc table in GHDB from CNV pipeline result
2018-01-03T11:37:10 New Test Items IDs to Add to Test Plan: []

Updating

Tests in robot file will get updated if fields like prerequesites and summary change in the robot output but don't match in JAMA.

./normalize_robot.py test/panel.robot --update -vv

Deleting

Tests that are removed from the robot file can be deleted from JAMA: ./normalize_robot.py test/panel.robot -vv --delete

This checks if the test exists in the test plan tied to the robot file, if the test exists in JAMA but not in the robot file it will delete the test. The test however can still be referenced in other test plans and will have to be removed manually. ( this can be fixed in the future but can be very dangerous as we would have to list all tests plans, traverse all tests, match by name and remove)

Renaming

If you rename a test in the robot file it will be treated as a new test, as there is no way to know that it was a previously existing test, everything is matched by name. A new test will be created and the old test will look like it was an existing test that needs to be deleted using the --delete flag

Uploading Test Results

check xml_normalizer folder README.md

Tests

➜ pytest normalize_robot.py -vv
=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 2.7.10, pytest-3.3.1, py-1.5.2, pluggy-0.6.0 -- /usr/bin/python
cachedir: .cache
rootdir: /Users/feelobot/src/guardant, inifile:
collected 7 items

normalize_robot.py::test_titles_first_matches PASSED                                                                                                                                                 [ 14%]
normalize_robot.py::test_tittles_all_found PASSED                                                                                                                                                    [ 28%]
normalize_robot.py::test_documentation_summary PASSED                                                                                                                                                [ 42%]
normalize_robot.py::test_documentation_summary_all_found PASSED                                                                                                                                      [ 57%]
normalize_robot.py::test_documentation_summary_all_prereqs_found PASSED                                                                                                                              [ 71%]
normalize_robot.py::test_documentation_all_steps_found PASSED                                                                                                                                        [ 85%]
normalize_robot.py::test_generateJSON PASSED                                                                                                                                                         [100%]

========================================================================================= 7 passed in 0.29 seconds =========================================================================================

## Workflow


References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment