-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MHubAI:main' into m-gc-stoic-baseline
- Loading branch information
Showing
66 changed files
with
3,736 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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 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,77 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
"type": "object", | ||
"properties": { | ||
"sample": { | ||
"type": "object", | ||
"properties": { | ||
"idc_version": { | ||
"type": ["string", "number"] | ||
}, | ||
"data": { | ||
"type": "array", | ||
"minItems": 1, | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"SeriesInstanceUID": { | ||
"type": "string", | ||
"pattern": "^[\\d\\.]+$" | ||
}, | ||
"aws_url": { | ||
"type": "string", | ||
"pattern": "^s3://[\\w\\-/]+/\\*$" | ||
}, | ||
"url": { | ||
"type": "string", | ||
"format": "uri" | ||
}, | ||
"description": { | ||
"type": "string" | ||
}, | ||
"path": { | ||
"type": "string", | ||
"pattern": "^[^\\/][\\w\\-\\.\\/]+$" | ||
} | ||
}, | ||
"oneOf": [ | ||
{ | ||
"required": [ | ||
"SeriesInstanceUID", | ||
"aws_url", | ||
"path" | ||
] | ||
}, | ||
{ | ||
"required": [ | ||
"url", | ||
"path" | ||
] | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"required": [ | ||
"idc_version", | ||
"data" | ||
] | ||
}, | ||
"reference": { | ||
"type": "object", | ||
"properties": { | ||
"url": { | ||
"type": "string", | ||
"format": "uri" | ||
} | ||
}, | ||
"required": [ | ||
"url" | ||
] | ||
} | ||
}, | ||
"required": [ | ||
"sample", | ||
"reference" | ||
] | ||
} |
This file contains 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,81 @@ | ||
import sys, os, yaml, json, jsonschema | ||
|
||
YAML_TEST_DEFINITION_SCHEMA_FILE = ".github/schemas/testmodel.schema.json" | ||
|
||
def extract_yaml_test_definition(comment: str): | ||
|
||
# find a code block starting with ```yaml and ending with ``` | ||
start = comment.find("```yaml") | ||
end = comment.find("```", start + 1) | ||
if start == -1 or end == -1: | ||
raise Exception("No YAML code block found in comment") | ||
|
||
# extract the code block | ||
yaml_code = comment[start:end] | ||
|
||
# remove the code block markers | ||
yaml_code = yaml_code.replace("```yaml", "").strip() | ||
|
||
return yaml_code | ||
|
||
def validate_yaml_test_definition(yaml_str: str): | ||
|
||
# load yaml into dict | ||
test_definition = yaml.safe_load(yaml_str) | ||
|
||
# load schema | ||
with open(YAML_TEST_DEFINITION_SCHEMA_FILE, "r") as f: | ||
schema = json.load(f) | ||
|
||
# validate | ||
jsonschema.validate(test_definition, schema) | ||
|
||
|
||
def set_action_output(output_name, value) : | ||
"""Sets the GitHub Action output. | ||
Keyword arguments: | ||
output_name - The name of the output | ||
value - The value of the output | ||
""" | ||
if "GITHUB_OUTPUT" in os.environ : | ||
with open(os.environ["GITHUB_OUTPUT"], "a") as f : | ||
print("{0}={1}".format(output_name, value), file=f) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
try: | ||
# get comment body from first argument | ||
comment = sys.argv[1] | ||
|
||
# print comment | ||
print(f"Comment ----------------------") | ||
print(comment) | ||
print() | ||
|
||
# extract yaml test definition | ||
yaml_str = extract_yaml_test_definition(comment) | ||
|
||
# validate yaml test definition | ||
validate_yaml_test_definition(yaml_str) | ||
|
||
# print yaml | ||
print(f"Test Definition --------------") | ||
print(yaml_str) | ||
print() | ||
|
||
# print success message | ||
print("YAML test definition is valid") | ||
|
||
# set environment variable for following steps | ||
set_action_output("test_report", "passed") | ||
|
||
except Exception as e: | ||
# set environment variable for following steps | ||
set_action_output("test_report", "failed") | ||
|
||
# print error message | ||
print("YAML test definition is invalid") | ||
print(e) | ||
|
This file contains 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 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 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,77 @@ | ||
name: MHub Contribution Magic Keywords | ||
|
||
on: | ||
issue_comment: | ||
types: [created, edited] | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
request_review: | ||
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '/review')}} | ||
name: Request Review | ||
runs-on: [ubuntu-latest] | ||
|
||
steps: | ||
- name: Add Request Review Label | ||
uses: actions-ecosystem/action-add-labels@v1 | ||
with: | ||
labels: REQUEST REVIEW | ||
|
||
request_test: | ||
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '/test') }} | ||
name: Request Test | ||
runs-on: [ubuntu-latest] | ||
|
||
steps: | ||
|
||
# Checkout the latest code from the repo | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
|
||
# Setup which version of Python to use | ||
- name: Setup Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
|
||
# install python dependencies | ||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install jsonschema PyYAML | ||
# Display the Python version being used | ||
- name: Display Python version | ||
run: python -c "import sys; print(sys.version)" | ||
|
||
- name: Run check comment script | ||
id: check_comment | ||
env: | ||
COMMENT: ${{ github.event.comment.body }} | ||
run: python .github/scripts/comment_check.py "$COMMENT" | ||
|
||
- name: Add TEST REQUESTED Label | ||
uses: actions-ecosystem/action-add-labels@v1 | ||
if: ${{ steps.check_comment.outputs.test_report == 'passed' }} | ||
with: | ||
labels: TEST REQUESTED | ||
|
||
- name: Remove INVALID TEST REQUEST Label | ||
uses: actions-ecosystem/action-remove-labels@v1 | ||
if: ${{ steps.check_comment.outputs.test_report == 'passed' }} | ||
with: | ||
labels: INVALID TEST REQUEST | ||
|
||
- name: Remove TEST REQUESTED Label | ||
uses: actions-ecosystem/action-remove-labels@v1 | ||
if: ${{ steps.check_comment.outputs.test_report == 'failed' }} | ||
with: | ||
labels: TEST REQUESTED | ||
|
||
- name: Add INVALID TEST REQUEST Label | ||
uses: actions-ecosystem/action-add-labels@v1 | ||
if: ${{ steps.check_comment.outputs.test_report == 'failed' }} | ||
with: | ||
labels: INVALID TEST REQUEST |
This file contains 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 MHub.ai | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains 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 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 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
Oops, something went wrong.