Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Template descriptions (#24)
Browse files Browse the repository at this point in the history
* Template component descriptions

* Add component descriptions directory with template descriptions

* Install descriptions directory in CMakeLists.txt

* Update script to rename template descriptions

* Revise base URI of schema files

* Update README

* Fix typo in example description
  • Loading branch information
eeberhard committed Nov 28, 2022
1 parent 7f3a878 commit c098270
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 13 deletions.
7 changes: 4 additions & 3 deletions schema/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,10 @@ To set up validation for the component description schema, follow the steps give
[Configure a custom JSON schema](https://www.jetbrains.com/help/clion/json.html#6768673a).

For step 3, give the Schema a useful name (such as "Component Description") and choose JSON Schema version 7.
In the "Schema file or URL field", specify the path to the `component.schema.json` file.
For example, if the local copy of the Component SDK repository is saved to `/home/user/component-sdk`,
then specify the Schema file path as `/home/user/component-sdk/schema/schema/component.schema.json`.
In the "Schema file or URL field", enter the following URL:
```
https://raw.githubusercontent.com/aica-technology/component-sdk/main/schema/schema/component.schema.json
```

For step 4, either manually specify files and directories to be validated, or use the file path pattern
`component_descriptions/*.json` to detect all component description in compatible packages.
Expand Down
2 changes: 1 addition & 1 deletion schema/examples/foo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"details": "A longer description of the example component"
},
"registration": "foo_package::Foo",
"inherits": "modulo_componentss::Component",
"inherits": "modulo_components::Component",
"inputs": [
{
"display_name": "Input 1",
Expand Down
2 changes: 1 addition & 1 deletion schema/schema/component.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://github.com/aica-technology/component-sdk/schema/schema/component.schema.json",
"id": "https://raw.githubusercontent.com/aica-technology/component-sdk/main/schema/schema/component.schema.json",
"title": "Dynamic Component Description",
"description": "A full description of a dynamic component in the AICA application framework.",
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion schema/schema/encoded_state_type.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://github.com/aica-technology/component-sdk/schema/schema/encoded_state_type.schema.json",
"id": "https://raw.githubusercontent.com/aica-technology/component-sdk/main/schema/schema/encoded_state_type.schema.json",
"title": "Encoded State Type",
"description": "The state type of an encoded value from a collection of supported types, as defined in clproto.",
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion schema/schema/parameter.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://github.com/aica-technology/component-sdk/schema/schema/parameter.schema.json",
"id": "https://raw.githubusercontent.com/aica-technology/component-sdk/main/schema/schema/parameter.schema.json",
"title": "Component Parameter",
"description": "A dynamic component parameter that is publicly configurable.",
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion schema/schema/parameter_type.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://github.com/aica-technology/component-sdk/schema/schema/parameter_type.schema.json",
"id": "https://raw.githubusercontent.com/aica-technology/component-sdk/main/schema/schema/parameter_type.schema.json",
"title": "Parameter Type",
"description": "The value type of a parameter from a collection of supported types.",
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion schema/schema/predicate.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://github.com/aica-technology/component-sdk/schema/schema/predicate.schema.json",
"id": "https://raw.githubusercontent.com/aica-technology/component-sdk/main/schema/schema/predicate.schema.json",
"title": "Component Predicate",
"description": "A predicate signal parameter of a dynamic component.",
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion schema/schema/service.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://github.com/aica-technology/component-sdk/schema/schema/service.schema.json",
"id": "https://raw.githubusercontent.com/aica-technology/component-sdk/main/schema/schema/service.schema.json",
"title": "Component Service",
"description": "A service endpoint of a dynamic component.",
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion schema/schema/signal.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://github.com/aica-technology/component-sdk/schema/schema/signal.schema.json",
"id": "https://raw.githubusercontent.com/aica-technology/component-sdk/main/schema/schema/signal.schema.json",
"title": "Component Signal",
"description": "A signal associated with a dynamic component that can be an input or an output.",
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion schema/schema/signal_collection.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://github.com/aica-technology/component-sdk/schema/schema/input_signal_collection.schema.json",
"id": "https://raw.githubusercontent.com/aica-technology/component-sdk/main/schema/schema/input_signal_collection.schema.json",
"title": "Input Signal Collection",
"description": "A dynamic collection of input signals that can have zero or more topics of the same type.",
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion schema/schema/signal_type.schema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"id": "https://github.com/aica-technology/component-sdk/schema/schema/signal_type.schema.json",
"id": "https://raw.githubusercontent.com/aica-technology/component-sdk/main/schema/schema/signal_type.schema.json",
"title": "Signal Type",
"description": "Supported signal value types as simple atomic types or encoded state types.",
"anyOf": [
Expand Down
17 changes: 17 additions & 0 deletions scripts/create_component_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ cp -r "${TEMPLATE_DIR}" "${COMPONENT_PKG_DIR}"
mv "${COMPONENT_PKG_DIR}"/template_component_package "${COMPONENT_PKG_DIR}"/"${COMPONENT_PKG_NAME}"
mv "${COMPONENT_PKG_DIR}"/include/template_component_package "${COMPONENT_PKG_DIR}"/include/"${COMPONENT_PKG_NAME}"

# rename the template component descriptions
DESCRIPTION_DIR="${COMPONENT_PKG_DIR}"/component_descriptions
mv "${DESCRIPTION_DIR}"/template_component_package_cpp_component.json "${DESCRIPTION_DIR}"/"${COMPONENT_PKG_NAME}"_cpp_component.json
mv "${DESCRIPTION_DIR}"/template_component_package_cpp_lifecycle_component.json "${DESCRIPTION_DIR}"/"${COMPONENT_PKG_NAME}"_cpp_lifecycle_component.json
mv "${DESCRIPTION_DIR}"/template_component_package_py_component.json "${DESCRIPTION_DIR}"/"${COMPONENT_PKG_NAME}"_py_component.json
mv "${DESCRIPTION_DIR}"/template_component_package_py_lifecycle_component.json "${DESCRIPTION_DIR}"/"${COMPONENT_PKG_NAME}"_py_lifecycle_component.json

# sed template_component_package in files
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${COMPONENT_PKG_DIR}"/README.md
Expand All @@ -94,6 +101,11 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${COMPONENT_PKG_DIR}"/"${COMPONENT_PKG_NAME}"/py_lifecycle_component.py
sed -i '' "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${COMPONENT_PKG_DIR}"/test/python_tests/test_py_lifecycle_component.py

sed -i '' "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${DESCRIPTION_DIR}"/"${COMPONENT_PKG_NAME}"_cpp_component.json
sed -i '' "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${DESCRIPTION_DIR}"/"${COMPONENT_PKG_NAME}"_cpp_lifecycle_component.json
sed -i '' "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${DESCRIPTION_DIR}"/"${COMPONENT_PKG_NAME}"_py_component.json
sed -i '' "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${DESCRIPTION_DIR}"/"${COMPONENT_PKG_NAME}"_py_lifecycle_component.json

sed -i '' "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${COMPONENT_PKG_DIR}"/Dockerfile
sed -i '' "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${COMPONENT_PKG_DIR}"/build-server.sh
else
Expand All @@ -116,6 +128,11 @@ else
sed -i "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${COMPONENT_PKG_DIR}"/"${COMPONENT_PKG_NAME}"/py_lifecycle_component.py
sed -i "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${COMPONENT_PKG_DIR}"/test/python_tests/test_py_lifecycle_component.py

sed -i "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${DESCRIPTION_DIR}"/"${COMPONENT_PKG_NAME}"_cpp_component.json
sed -i "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${DESCRIPTION_DIR}"/"${COMPONENT_PKG_NAME}"_cpp_lifecycle_component.json
sed -i "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${DESCRIPTION_DIR}"/"${COMPONENT_PKG_NAME}"_py_component.json
sed -i "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${DESCRIPTION_DIR}"/"${COMPONENT_PKG_NAME}"_py_lifecycle_component.json

sed -i "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${COMPONENT_PKG_DIR}"/Dockerfile
sed -i "s/template_component_package/${COMPONENT_PKG_NAME}/g" "${COMPONENT_PKG_DIR}"/build-server.sh
fi
Expand Down
3 changes: 3 additions & 0 deletions source/template_component_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ install(TARGETS ${COMPONENTS}
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)

install(DIRECTORY ./component_descriptions
DESTINATION .)

# install Python modules
ament_python_install_package(${PROJECT_NAME} SCRIPTS_DESTINATION lib/${PROJECT_NAME})

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Component Descriptions

Each registered component should have a corresponding json description file in this directory,
formatted according to the component description schema.

More info: https://github.com/aica-technology/component-sdk/tree/main/schema
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Template CPP Component",
"description": {
"brief": "Brief description of the component",
"details": "Detailed description of the component."
},
"registration": "template_component_package::CPPComponent",
"inherits": "modulo_components::Component"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Template CPP Lifecycle Component",
"description": {
"brief": "Brief description of the component",
"details": "Detailed description of the component."
},
"registration": "template_component_package::CPPLifecycleComponent",
"inherits": "modulo_components::LifecycleComponent"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Template Python Component",
"description": {
"brief": "Brief description of the component",
"details": "Detailed description of the component."
},
"registration": "template_component_package::PyComponent",
"inherits": "modulo_components::Component"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Template Python Lifecycle Component",
"description": {
"brief": "Brief description of the component",
"details": "Detailed description of the component."
},
"registration": "template_component_package::PyLifecycleComponent",
"inherits": "modulo_components::LifecycleComponent"
}

0 comments on commit c098270

Please sign in to comment.