Skip to content

Commit

Permalink
Merge pull request #250 from tbirdso/tutorial-metadata
Browse files Browse the repository at this point in the history
Utility: Add tutorial template and update validator tool
  • Loading branch information
tbirdso authored Mar 26, 2024
2 parents 728bf7a + 027b6e4 commit f0580fc
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 3 deletions.
36 changes: 36 additions & 0 deletions tutorials/template/README.md.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# My HoloHub Tutorial

Provide a splash image highlighting your tutorial.

## Overview

Provide a one-sentence summary of your tutorial's purpose and operations.

## Description

Provide a detailed summary of your project. Include any necessary background
for the average HoloHub user to understand the general purpose of your project.
Include any diagrams that are helpful for understanding functionality.

## Data

Give an overview of any datasets that will be used in your project.

## Requirements

List any platform requirements that a user must have before trying to build and run
your project. Requirements could include hardware or software.

## Tutorial Instructions

Provide a step-by-step walkthrough of your tutorial and link to any accompanying
tutorial documents. If the tutorial depends on runnable commands, include them
here.

```bash
<my-command> <my-args>
```

## Acknowledgements

Cite any methods or collaborators here.
34 changes: 34 additions & 0 deletions tutorials/template/metadata.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"tutorial": {
"name": "My Tutorial",
"description": "Demonstrates how to use Holoscan in a certain fashion.",
"authors": [
{
"name": "John Doe",
"affiliation": "My Institution"
}
],
"language": "C++",
"version": "0.1.0",
"changelog": {
"0.1.0": "Initial Release"
},
"holoscan_sdk": {
"minimum_required_version": "1.0.3",
"tested_versions": [
"1.0.3"
]
},
"platforms": [
"amd64",
"arm64"
],
"tags": [
"Sensor",
"Processing",
"Tutorial"
],
"ranking": 1,
"dependencies": {}
}
}
17 changes: 14 additions & 3 deletions utilities/metadata_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ def validate_json(json_data, directory):
registry = Registry().with_resource(base_schema["$id"], DRAFT4.create_resource(base_schema))

with open(directory + "/metadata.schema.json", "r") as file:
execute_api_schema = json.load(file)
try:
execute_api_schema = json.load(file)
except json.decoder.JSONDecodeError as err:
return False, err
validator = Draft4Validator(execute_api_schema, registry=registry)

try:
Expand Down Expand Up @@ -74,7 +77,13 @@ def validate_json_directory(directory, ignore_patterns=[], metadata_is_required:
# Check if the metadata is valid
for name in glob.glob(current_wdir + "/" + directory + "/**/metadata.json", recursive=True):
with open(name, "r") as file:
jsonData = json.load(file)
try:
jsonData = json.load(file)
except json.decoder.JSONDecodeError:
print("ERROR:" + name + ": invalid")
exit_code = 1
continue

is_valid, msg = validate_json(jsonData, directory)
if is_valid:
print(name + ": valid")
Expand All @@ -91,6 +100,8 @@ def validate_json_directory(directory, ignore_patterns=[], metadata_is_required:
exit_code_op = validate_json_directory("operators", ignore_patterns=["template"])
exit_code_extensions = validate_json_directory("gxf_extensions", ignore_patterns=["utils"])
exit_code_applications = validate_json_directory("applications", ignore_patterns=["template"])
exit_code_tutorials = validate_json_directory("tutorials", metadata_is_required=False)
exit_code_tutorials = validate_json_directory(
"tutorials", ignore_patterns=["template"], metadata_is_required=False
)

sys.exit(max(exit_code_op, exit_code_extensions, exit_code_applications, exit_code_tutorials))

0 comments on commit f0580fc

Please sign in to comment.