Skip to content

Commit

Permalink
changes for release 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen2x committed Mar 14, 2024
1 parent af467f3 commit 7e8dae5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ python -m pytest --cov

## Changelog

### v0.2.1
* Accept json report from report object

### v0.2.0
* Able to submit reports to Testbed API via standard `POST` request

Expand Down
22 changes: 15 additions & 7 deletions ga4gh/testbed/submit/report_submitter.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
from re import sub
import requests

import json
from ga4gh.testbed.report.report import Report

class ReportSubmitter():

def submit_report(series_id, series_token, report, url="http://localhost:4500/reports"):
def submit_report(series_id, series_token, report:Report, url="http://localhost:4500/reports"):
'''
Submits a report to the GA4GH testbed api.
Required arguments:
series_id - A series ID is needed by server to group the report
series_token - A token is needed to verify authenticity
report - GA4GH report in JSON format
report - GA4GH report object
url - URL of the testbed server
'''
header = {"GA4GH-TestbedReportSeriesId": series_id, "GA4GH-TestbedReportSeriesToken": series_token}
submit_request = requests.post(url, headers=header ,json=report)

results = {
"status_code": submit_request.status_code,
"status_code": None,
"error_message": None,
"report_id": None
}

if type(report) != Report:
results["status_code"] = 400
results["error_message"] = "Report submitted is not a GA4GH Report object"
return results

header = {"GA4GH-TestbedReportSeriesId": series_id, "GA4GH-TestbedReportSeriesToken": series_token}
submit_request = requests.post(url, headers=header ,json=json.loads(report.to_json()))

results["status_code"] = submit_request.status_code

if submit_request.status_code == 200:
results["report_id"] = submit_request.json()["id"]
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import setuptools

NAME = "ga4gh-testbed-lib"
VERSION = "0.2.0"
VERSION = "0.2.1"
AUTHOR = "Jeremy Adams"
EMAIL = "jeremy.adams@ga4gh.org"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import pytest
from ga4gh.testbed.report.report import Report
from ga4gh.testbed.submit.report_submitter import ReportSubmitter

sample_report = {"schema_name":"ga4gh-testbed-report","schema_version":"0.1.0","testbed_name":"refget-compliance-suite","testbed_version":"","testbed_description":"","platform_name":"","platform_description":"","input_parameters":{},"start_time":"2022-03-22T17:45:37Z","end_time":"2022-03-22T17:46:32Z","status":"PASS","summary":{"unknown":0,"passed":49,"warned":0,"failed":0,"skipped":20},"phases":[]}
sample_report = Report()

submit_report_inputs = "series_id,series_token,report,url,status_code"
submit_report_cases = [
Expand All @@ -26,13 +27,6 @@
"http://localhost:4500/reports",
400
),
(
"1edb5213-52a2-434f-a7b8-b101fea8fb30",
"K5pLbwScVu8rEoLLj8pRy5Wv7EXTVahn",
{},
"http://localhost:4500/reports",
500
),
(
"",
"K5pLbwScVu8rEoLLj8pRy5Wv7EXTVahn",
Expand Down

0 comments on commit 7e8dae5

Please sign in to comment.