Skip to content

Commit

Permalink
Merge pull request #76 from catenax-ng/fix/75-provisioning-agent-char…
Browse files Browse the repository at this point in the history
…t-entrypoint

fix: problems with busybox default shell on linux/amd64.
  • Loading branch information
carslen authored Feb 7, 2024
2 parents b4ee7fe + 11649ff commit 6ee2691
Show file tree
Hide file tree
Showing 7 changed files with 253 additions and 106 deletions.
4 changes: 2 additions & 2 deletions provisioning/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--
* Copyright (c) 2022,2023 Contributors to the Eclipse Foundation
* Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -278,7 +278,7 @@ Eclipse Tractus-X product(s) installed within the image:

**Used base image**

- [eclipse-temurin:11-jre-alpine](https://github.com/adoptium/containers)
- [eclipse-temurin:21-jre-alpine](https://github.com/adoptium/containers)
- Official Eclipse Temurin DockerHub page: https://hub.docker.com/_/eclipse-temurin
- Eclipse Temurin Project: https://projects.eclipse.org/projects/adoptium.temurin
- Additional information about the Eclipse Temurin images: https://github.com/docker-library/repo-info/tree/master/repos/eclipse-temurin
Expand Down
33 changes: 33 additions & 0 deletions provisioning/resources/cx-ontology.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

@prefix cx: <https://w3id.org/catenax/ontology#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix json: <https://json-schema.org/draft/2020-12/schema#> .

json:Object a rdfs:Datatype.

cx:CxOntology a owl:Ontology ;
dc:creator "Catena-X Knowledge Agents Team" ;
dc:date "2022-11-29"^^xsd:date ;
dc:description "Catena-X Ontology for the Autmotive Industry." ;
dc:title "Catena-X Ontology" .
34 changes: 34 additions & 0 deletions provisioning/resources/cx-ontology.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0"?>

<!--
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
-->

<rdf:RDF xmlns="https://w3id.org/catenax/ontology/#"
xml:base="https://w3id.org/catenax/ontology/"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:json="https://json-schema.org/draft/2020-12/schema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="https://w3id.org/catenax/ontology/"/>
<rdf:Description rdf:about="https://json-schema.org/draft/2020-12/schema#Object">
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Datatype"/>
</rdf:Description>
</rdf:RDF>
202 changes: 102 additions & 100 deletions provisioning/resources/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#!/bin/sh

# Copyright (c) 2022,2023 Contributors to the Eclipse Foundation
# Copyright (c) 2022, 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
Expand All @@ -21,106 +21,108 @@
# Entry script for provisioning agent/ontop with the ability to start multiple endpoints in lazy mode and disable CORS
#

# Reinterpret the environment vars as arrays
ONTOP_PORT=( ${ONTOP_PORT[*]} )
ONTOP_ONTOLOGY_FILE=( ${ONTOP_ONTOLOGY_FILE[*]} )
ONTOP_MAPPING_FILE=( ${ONTOP_MAPPING_FILE[*]} )
ONTOP_PROPERTIES_FILE=( ${ONTOP_PROPERTIES_FILE[*]} )
ONTOP_PORTAL_FILE=( ${ONTOP_PORTAL_FILE[*]} )
ONTOP_DEV_MODE=( ${ONTOP_DEV_MODE[*]} )
JAVA_TOOL_OPTIONS_ARRAY=( ${JAVA_TOOL_OPTIONS[*]} )

ENDPOINT_LENGTH=${#ONTOP_PORT[@]}
if [[ ${ENDPOINT_LENGTH} -gt 0 ]]; then
echo "Found ${ENDPOINT_LENGTH} endpoints to provision.";
else
echo "Incorrect port specification: ${ONTOP_PORT[*]}";
exit 1;
fi
CORS=""
LAZY="--lazy"
ENDPOINT_LENGTH=0
ONTOP_TOOL_OPTIONS=$JAVA_TOOL_OPTIONS
JAVA_TOOL_OPTIONS=""

((ENDPOINT_LENGTH--))
for ENDPOINT in $ONTOP_PORT ; do # NOTE: do not double-quote $services here.
ENDPOINT_LENGTH=$((ENDPOINT_LENGTH+1))
done

# for matching the definitions
NUMBER='^[0-9]+$'
TOML='^.*toml$'
ONTOLOGY='^.*(ttl|xml)$'
MAPPING='^.*(obda)$'
PROPERTIES='^.*(properties)$'
CORS="--cors-allowed-origins=${ONTOP_CORS_ALLOWED_ORIGINS}"
LAZY="--lazy"
if [ "$ONTOP_CORS_ALLOWED_ORIGINS" != "" ]; then
CORS="--cors-allowed-origins=${ONTOP_CORS_ALLOWED_ORIGINS}"
fi

# Loop over the endpoints driven by the ports
for ENDPOINT_NUMBER in "${!ONTOP_PORT[@]}"
do
# check port number
if [[ "${ONTOP_PORT[${ENDPOINT_NUMBER}]}" =~ ${NUMBER} ]]; then
echo "Providing endpoint ${ENDPOINT_NUMBER} on port ${ONTOP_PORT[${ENDPOINT_NUMBER}]}";
PORT="--port=${ONTOP_PORT[${ENDPOINT_NUMBER}]}";

# check ontology
if [[ "${ONTOP_ONTOLOGY_FILE[${ENDPOINT_NUMBER}]}" =~ ${ONTOLOGY} ]]; then
echo "Providing endpoint ${ENDPOINT_NUMBER} on ontology ${ONTOP_ONTOLOGY_FILE[${ENDPOINT_NUMBER}]}";
ONTOLOGY_FILE="--ontology=${ONTOP_ONTOLOGY_FILE[${ENDPOINT_NUMBER}]}";

# check mapping
if [[ "${ONTOP_MAPPING_FILE[${ENDPOINT_NUMBER}]}" =~ ${MAPPING} ]]; then

echo "Providing endpoint ${ENDPOINT_NUMBER} on mapping ${ONTOP_MAPPING_FILE[${ENDPOINT_NUMBER}]}";
MAPPING_FILE="--mapping=${ONTOP_MAPPING_FILE[${ENDPOINT_NUMBER}]}";

# check properties
if [[ "${ONTOP_PROPERTIES_FILE[${ENDPOINT_NUMBER}]}" =~ ${PROPERTIES} ]]; then

echo "Providing endpoint ${ENDPOINT_NUMBER} on properties ${ONTOP_PROPERTIES_FILE[${ENDPOINT_NUMBER}]}";
PROPERTIES_FILE="--properties=${ONTOP_PROPERTIES_FILE[${ENDPOINT_NUMBER}]}";

# check developer mode
if [ "${ONTOP_DEV_MODE[${ENDPOINT_NUMBER}]}" == "true" ]; then
echo "Providing endpoint ${ENDPOINT_NUMBER} in developer mode";
DEV_MODE="--dev"
else
DEV_MODE=""
fi

# check portal activation
if [[ "${ONTOP_PORTAL_FILE[${ENDPOINT_NUMBER}]}" =~ ${TOML} ]]; then
echo "Providing endpoint ${ENDPOINT_NUMBER} on portal ${ONTOP_PORTAL_FILE[${ENDPOINT_NUMBER}]}";
PORTAL_FILE="--portal=${ONTOP_PORTAL_FILE[${ENDPOINT_NUMBER}]}"
else
PORTAL_FILE=""
fi

JAVA_TOOL_OPTIONS=${JAVA_TOOL_OPTIONS_ARRAY[${ENDPOINT_NUMBER}]};

echo "Arguments: ${ONTOLOGY_FILE} ${MAPPING_FILE} ${PROPERTIES_FILE} ${PORTAL_FILE} ${DEV_MODE} ${PORT} ${CORS} ${JAVA_TOOL_OPTIONS}";

if [[ "${ENDPOINT_NUMBER}" == "${ENDPOINT_LENGTH}" ]]; then
echo "Invoking last process";
java -cp ./lib/*:./jdbc/* -Dlogback.configurationFile="/opt/ontop/log/logback.xml" -Dlogging.config="/opt/ontop/log/logback.xml" \
it.unibz.inf.ontop.cli.Ontop endpoint ${ONTOLOGY_FILE} ${MAPPING_FILE} \
${PROPERTIES_FILE} ${PORTAL_FILE} ${DEV_MODE} ${PORT} ${CORS} ${LAZY};
else
echo "Invoking intermediate process";
java -cp ./lib/*:./jdbc/* -Dlogback.configurationFile="/opt/ontop/log/logback.xml" -Dlogging.config="/opt/ontop/log/logback.xml" \
it.unibz.inf.ontop.cli.Ontop endpoint ${ONTOLOGY_FILE} ${MAPPING_FILE} \
${PROPERTIES_FILE} ${PORTAL_FILE} ${DEV_MODE} ${PORT} ${CORS} ${LAZY}&
fi

else
# Incorrect properties
echo "Cannot provide endpoint ${ENDPOINT_NUMBER} as incorrect properties given: ${ONTOP_PROPERTIES_FILE[${ENDPOINT_NUMBER}]}";
fi
else
# Incorrect mapping
echo "Cannot provide endpoint ${ENDPOINT_NUMBER} as incorrect mapping given: ${ONTOP_MAPPING_FILE[${ENDPOINT_NUMBER}]}";
fi
else
# Incorrect ontology
echo "Cannot provide endpoint ${ENDPOINT_NUMBER} as incorrect ontology given: ${ONTOP_ONTOLOGY_FILE[${ENDPOINT_NUMBER}]}";
fi
else
# Incorrect port number
echo "Cannot provide endpoint ${ENDPOINT_NUMBER} as incorrect port number given: ${ONTOP_PORT[${ENDPOINT_NUMBER}]}";
echo "Found $ENDPOINT_LENGTH endpoints to provide under $CORS $LAZY."

ENDPOINT_INDEX=0
for ENDPOINT in $ONTOP_PORT ; do # NOTE: do not double-quote $services here.
ENDPOINT_INDEX=$((ENDPOINT_INDEX+1))

ONTOLOGY="/opt/ontop/ontology.ttl"
ONTOLOGY_INDEX=0
for ONTOLOGY_FILE in $ONTOP_ONTOLOGY_FILE ; do
ONTOLOGY_INDEX=$((ONTOLOGY_INDEX+1))

if [ $ENDPOINT_INDEX -ge $ONTOLOGY_INDEX ]; then
ONTOLOGY=$ONTOLOGY_FILE
fi
done

MAPPING="/opt/ontop/input/mapping.obda"
MAPPING_INDEX=0
for MAPPING_FILE in $ONTOP_MAPPING_FILE ; do
MAPPING_INDEX=$((MAPPING_INDEX+1))

if [ $ENDPOINT_INDEX -ge $MAPPING_INDEX ]; then
MAPPING=$MAPPING_FILE
fi
done

PROPERTIES="/opt/ontop/input/settings.properties"
PROPERTIES_INDEX=0
for PROPERTIES_FILE in $ONTOP_PROPERTIES_FILE ; do
PROPERTIES_INDEX=$((PROPERTIES_INDEX+1))

if [ $ENDPOINT_INDEX -ge $PROPERTIES_INDEX ]; then
PROPERTIES=$PROPERTIES_FILE
fi
done

DEV="false"
DEV_INDEX=0
for DEV_MODE in $ONTOP_DEV_MODE ; do
DEV_INDEX=$((DEV_INDEX+1))

if [ $ENDPOINT_INDEX -ge $DEV_INDEX ]; then
DEV=$DEV_MODE
fi
done

TOOL=""
TOOL_INDEX=0
for TOOL_OPTIONS in $ONTOP_TOOL_OPTIONS ; do
TOOL_INDEX=$((TOOL_INDEX+1))

if [ $ENDPOINT_INDEX -ge $TOOL_INDEX ]; then
TOOL=$TOOL_OPTIONS
fi
done

PORTAL="/opt/ontop/portal.toml"
PORTAL_INDEX=0
for PORTAL_FILE in $ONTOP_PORTAL_FILES ; do
PORTAL_INDEX=$((PORTAL_INDEX+1))

if [ $ENDPOINT_INDEX -ge $PORTAL_INDEX ]; then
PORTAL=$PORTAL_FILE
fi
done

echo "Providing endpoint $ENDPOINT_INDEX on port $ENDPOINT with ontology $ONTOLOGY mapping $MAPPING properties $PROPERTIES portal $PORTAL dev mode $DEV and tool options $TOOL"

ENDPOINT="--port=$ENDPOINT"
ONTOLOGY="--ontology=$ONTOLOGY"
MAPPING="--mapping=$MAPPING"
PROPERTIES="--properties=$PROPERTIES"
if [ "$DEV" == "true" ]; then
DEV="--dev"
else
DEV=""
fi
PORTAL="--portal=$PORTAL"

if [ $ENDPOINT_INDEX -eq $ENDPOINT_LENGTH ]; then
echo "Invoking last process";
java $TOOL -cp ./lib/*:./jdbc/* -Dlogback.configurationFile="/opt/ontop/log/logback.xml" -Dlogging.config="/opt/ontop/log/logback.xml" \
it.unibz.inf.ontop.cli.Ontop endpoint ${ONTOLOGY} ${MAPPING} \
${PROPERTIES} ${PORTAL} ${DEV} ${ENDPOINT} ${CORS} ${LAZY};
else
echo "Invoking intermediate process";
java $TOOL -cp ./lib/*:./jdbc/* -Dlogback.configurationFile="/opt/ontop/log/logback.xml" -Dlogging.config="/opt/ontop/log/logback.xml" \
it.unibz.inf.ontop.cli.Ontop endpoint ${ONTOLOGY_FILE} ${MAPPING_FILE} \
${PROPERTIES} ${PORTAL} ${DEV} ${ENDPOINT} ${CORS} ${LAZY}&
fi
done

55 changes: 55 additions & 0 deletions provisioning/resources/portal.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

title="Catena-X Agent Provisioning Demo"

[[tabGroups]]

name="Example Queries"

[[tabGroups.tabs]]

name="Diagnosis Skill"
query="""
PREFIX cx: <https://w3id.org/catenax/ontology#>
PREFIX cx-diag: <https://w3id.org/catenax/ontology/diagnosis#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?reason ?code ?description ?version ?partend ?partcat ?partclass WHERE {
# Select Business Partner
?Oem cx:BPNL "BPNL00000003COJN".
# Search for Trouble Codes of the Business Partner
# related to a cause in the "Kabelbaum"
?Dtc rdf:type cx-diag:DTC.
?Dtc cx:provisionedBy ?Oem.
?Dtc cx-diag:PossibleCauses ?reason.
FILTER contains(?reason,"Kabelbaum").
?Dtc cx-diag:Code ?code.
?Dtc cx-diag:Description ?description.
?Dtc cx-diag:Version ?version.
# Navigate to the affected parts
# and show only parts with a classification "Powertrain"
?Dtc cx-diag:affects ?Part.
?Part cx-diag:Category ?partcat.
?Part cx-diag:EnDenomination ?partend.
?Part cx-diag:Classification ?partclass.
FILTER contains(?partclass,'Powertrain').
} LIMIT 40
"""
20 changes: 20 additions & 0 deletions provisioning/resources/settings.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# SPDX-License-Identifier: Apache-2.0

# Setup In-Memory Database with the trouble codes
jdbc.url=jdbc:h2:file:/opt/ontop/database/db;INIT=RUNSCRIPT FROM '/opt/ontop/data/dtc.sql'
jdbc.driver=org.h2.Driver
Loading

0 comments on commit 6ee2691

Please sign in to comment.