Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit ef105cc

Browse files
authored
Merge pull request #191 from linkernetworks/linker
Merge FactoryAI to Master
2 parents 57f2b3d + 9d47e90 commit ef105cc

File tree

753 files changed

+45125
-3509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

753 files changed

+45125
-3509
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ These samples demonstrate how to quickly get started developing for the Azure In
2727
Solutions.](https://azure.microsoft.com/en-us/solutions/hybrid-cloud-app/)
2828
- Learn more about Azure Stack Hub, see [Azure Stack Hub](https://azure.microsoft.com/en-us/overview/azure-stack/)
2929
- Learn more about Azure Stack Edge, see [Azure Stack Edge](https://azure.microsoft.com/en-us/services/databox/edge/)
30+

azure-pipelines.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Starter pipeline
2+
# Start with a minimal pipeline that you can customize to build and deploy your code.
3+
# Add steps that build, run tests, deploy, and more:
4+
# https://aka.ms/yaml
5+
6+
trigger:
7+
- develop
8+
9+
pool:
10+
vmImage: 'ubuntu-latest'
11+
12+
steps:
13+
- task: Bash@3
14+
inputs:
15+
filePath: './factory-ai-vision/EdgeSolution/azure-pipelines-build.sh'
16+
env:
17+
BUILD_BUILD_NUMBER: $(Build.BuildNumber)
18+
BUILD_SOURCE_BRANCHNAME: $(Build.SourceBranchName)
19+
displayName: 'Generating IoT Edge module tag from Azure Pipelines'
20+
21+
- task: AzureIoTEdge@2
22+
inputs:
23+
action: 'Build module images'
24+
templateFilePath: './factory-ai-vision/EdgeSolution/deployment.cpu.template.json'
25+
defaultPlatform: 'amd64'
26+
displayName: 'Azure IoT Edge - Build module images'
27+
28+
- task: AzureIoTEdge@2
29+
inputs:
30+
action: 'Push module images'
31+
containerregistrytype: 'Azure Container Registry'
32+
azureSubscriptionEndpoint: 'Microsoft Azure Sponsorship(091725d9-aeba-4638-8faf-d0e81a03a93d)'
33+
azureContainerRegistry: '{"loginServer":"factoryairegistry.azurecr.io", "id" : "/subscriptions/091725d9-aeba-4638-8faf-d0e81a03a93d/resourceGroups/customvision/providers/Microsoft.ContainerRegistry/registries/factoryairegistry"}'
34+
templateFilePath: './factory-ai-vision/EdgeSolution/deployment.cpu.template.json'
35+
defaultPlatform: 'amd64'
36+
fillRegistryCredential: 'true'
37+
displayName: 'Azure IoT Edge - Push module images'
38+
condition: ne(variables['Build.Reason'], 'PullRequest')
39+
40+
- task: CopyFiles@2
41+
inputs:
42+
SourceFolder: 'factory-ai-vision/EdgeSolution'
43+
Contents: |
44+
deployment.*.template.json
45+
**/module.json
46+
TargetFolder: '$(Build.ArtifactStagingDirectory)'
47+
condition: ne(variables['Build.Reason'], 'PullRequest')
48+
49+
- task: PublishBuildArtifacts@1
50+
inputs:
51+
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
52+
ArtifactName: 'drop'
53+
publishLocation: 'Container'
54+
displayName: 'Publish Artifact Drop.'
55+
condition: ne(variables['Build.Reason'], 'PullRequest')

factory-ai-vision/.vscode/settings.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
"source.fixAll": false,
55
"source.fixAll.eslint": false
66
},
7-
"eslint.workingDirectories": ["./EdgeSolution/modules/WebModule/ui/src"],
7+
"eslint.workingDirectories": [
8+
"./EdgeSolution/modules/WebModule/ui/src",
9+
"./EdgeSolution/modules/WebModule/ui_v2/src"
10+
],
811
"eslint.enable": true,
912
"eslint.validate": [
1013
"javascript",
@@ -13,5 +16,6 @@
1316
"typescriptreact"
1417
],
1518
"typescript.format.enable": true,
16-
"typescript.validate.enable": true
19+
"typescript.validate.enable": true,
20+
"git.ignoreLimitWarning": true
1721
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Edge Solutions
2+
3+
[![Build Status](https://dev.azure.com/peterwu0590/vision_on_edge_cicd/_apis/build/status/Build%20cpuamd64%20-%20linkernetworks.azure-intelligent-edge-patterns?branchName=develop)](https://dev.azure.com/peterwu0590/vision_on_edge_cicd/_build/latest?definitionId=1&branchName=develop)
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/bin/bash
2+
3+
# =========================================================
4+
# === Setting up ===
5+
# =========================================================
6+
if [ ${#@} -ne 0 ] && [ "${@#"--silent"}" = "" ]; then
7+
echo 'HERE'
8+
stty -echo;
9+
fi;
10+
11+
# Step
12+
STEP=0
13+
function next_step() {
14+
STEP=$((STEP+1))
15+
echo
16+
echo "Step ${STEP}."
17+
}
18+
19+
# =========================================================
20+
# === Real script ===
21+
# =========================================================
22+
echo "Build.BuildNumber : ${BUILD_BUILD_NUMBER}"
23+
echo "Build.SourceBranchName : ${BUILD_SOURCE_BRANCHNAME}"
24+
PIPELINE_MODULE_POSTFIX="${BUILD_SOURCE_BRANCHNAME}-${BUILD_BUILD_NUMBER}"
25+
echo "Pipeline module postfix : ${PIPELINE_MODULE_POSTFIX}"
26+
next_step
27+
28+
## =========================================================
29+
## === Install jq ===
30+
## =========================================================
31+
#sudo apt-get install -y jq
32+
#next_step
33+
34+
35+
# =========================================================
36+
# === Get path of this script ===
37+
# =========================================================
38+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
39+
echo "This script is located at:"
40+
echo " ${DIR}"
41+
next_step
42+
43+
44+
# =========================================================
45+
# === Checking environment file '.env'" ===
46+
# =========================================================
47+
echo "Let Azure pipelines to handle enviroment variables"
48+
next_step
49+
50+
51+
# =========================================================
52+
# === get name of this script ===
53+
# =========================================================
54+
THIS_SCRIPT_NAME="$(basename $0)"
55+
echo "This script's name is:"
56+
echo " ${THIS_SCRIPT_NAME}"
57+
next_step
58+
59+
60+
# =========================================================
61+
# === Get Inference module file ===
62+
# =========================================================
63+
INFERENCE_MODULE_FILE="${DIR}"/modules/InferenceModule/module.json
64+
65+
if [ ! -f ${INFERENCE_MODULE_FILE} ]; then
66+
echo "INFERENCE_MODULE_FILE not found..."
67+
echo " ${INFERENCE_MODULE_FILE}"
68+
echo "exit 1..."
69+
exit 1
70+
else
71+
echo "INFERENCE_MODULE_FILE found"
72+
echo " ${INFERENCE_MODULE_FILE}"
73+
fi
74+
next_step
75+
76+
77+
# =========================================================
78+
# === Get Web module file ===
79+
# =========================================================
80+
WEB_MODULE_FILE="${DIR}"/modules/WebModule/module.json
81+
if [ ! -f ${WEB_MODULE_FILE} ]; then
82+
echo "WEB_MODULE_FILE not found..."
83+
echo " ${WEB_MODULE_FILE}"
84+
echo "exit 1..."
85+
exit 1
86+
else
87+
echo "WEB_MODULE_FILE found"
88+
echo " ${WEB_MODULE_FILE}"
89+
fi
90+
next_step
91+
92+
93+
# =========================================================
94+
# === Add inference module version ===
95+
# =========================================================
96+
echo "Checking inferencemodule change"
97+
INFERENCE_MODULE_VERSION=$(cat "${INFERENCE_MODULE_FILE}" | jq '.image.tag.version' | sed -e 's/^"//' -e 's/"$//')
98+
echo " Inference Module changed"
99+
echo " Updating version"
100+
# Add version number
101+
# 0.3.87 -> 0.3.88
102+
INFERENCE_MODULE_NEW_VERSION="${INFERENCE_MODULE_VERSION}-${PIPELINE_MODULE_POSTFIX}"
103+
echo " Inference Module version: ${INFERENCE_MODULE_VERSION} => ${INFERENCE_MODULE_NEW_VERSION}"
104+
cat "${INFERENCE_MODULE_FILE}" | jq ".image.tag.version= \"${INFERENCE_MODULE_NEW_VERSION}\"" > ${INFERENCE_MODULE_FILE}.tmp
105+
mv ${INFERENCE_MODULE_FILE}.tmp ${INFERENCE_MODULE_FILE}
106+
next_step
107+
108+
109+
# =========================================================
110+
# === Check web module version ===
111+
# =========================================================
112+
echo "Checking webmodule change"
113+
WEB_MODULE_VERSION=$(cat "${WEB_MODULE_FILE}" | jq '.image.tag.version' |sed -e 's/^"//' -e 's/"$//')
114+
echo " Web Module change"
115+
WEB_MODULE_NEW_VERSION="${WEB_MODULE_VERSION}-${PIPELINE_MODULE_POSTFIX}"
116+
echo " Web Module version: ${WEB_MODULE_VERSION} => ${WEB_MODULE_NEW_VERSION}"
117+
cat "${WEB_MODULE_FILE}" | jq ".image.tag.version= \"${WEB_MODULE_NEW_VERSION}\"" > ${WEB_MODULE_FILE}.tmp
118+
mv ${WEB_MODULE_FILE}.tmp ${WEB_MODULE_FILE}
119+
next_step
120+
121+
122+
# =========================================================
123+
# === Commit and let Azure pipelines to handle the rest.===
124+
# =========================================================
125+
echo 'All done...'
Lines changed: 37 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#!/bin/zsh
2+
3+
# =========================================================
4+
# === Setting up ===
5+
# =========================================================
26
if [ ${#@} -ne 0 ] && [ "${@#"--silent"}" = "" ]; then
37
echo 'HERE'
48
stty -echo;
@@ -23,54 +27,42 @@ color_info=${color_green}
2327
color_warning=${yellow}
2428
color_error=${color_red}
2529

26-
# Start ===================================================
30+
31+
# =========================================================
32+
# === Real script ===
33+
# =========================================================
34+
echo "Running"
2735
next_step
2836

37+
38+
# =========================================================
39+
# === Get path of this script ===
2940
# =========================================================
30-
# Where is this script...
3141
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
3242
echo "This script is located at:"
3343
echo " ${DIR}"
3444
next_step
3545

36-
# =========================================================
37-
# checking environment file '.env'"
38-
if [ -f ${DIR}/.env ]; then
39-
echo "Environment file found"
40-
echo " ${DIR}/.env"
41-
echo " Loading environment..."
42-
. ${DIR}/.env
43-
44-
else
45-
echo "env file not found."
46-
echo " ${DIR}/.env"
47-
echo " exit 1..."
48-
exit 1
49-
fi
50-
next_step
5146

5247
# =========================================================
53-
# Check container registry name
54-
if [ -z ${CONTAINER_REGISTRY_NAME} ]; then
55-
echo "CONTAINER_REGISTRY_NAME not found in .env"
56-
echo " ${DIR}/.env"
57-
echo "exit 1..."
58-
exit 1
59-
else
60-
echo "CONTAINER_REGISTRY_NAME found"
61-
echo " ${CONTAINER_REGISTRY_NAME}"
62-
fi
48+
# === Checking environment file '.env'" ===
49+
# =========================================================
50+
echo "Let Azure pipelines to handle enviroment variables"
6351
next_step
6452

53+
54+
# =========================================================
55+
# === get name of this script ===
6556
# =========================================================
66-
# What is this script's name?
6757
THIS_SCRIPT_NAME="$(basename $0)"
6858
echo "This script's name is:"
6959
echo " ${THIS_SCRIPT_NAME}"
7060
next_step
7161

62+
63+
# =========================================================
64+
# === Get Inference module file ===
7265
# =========================================================
73-
# Get module file
7466
INFERENCE_MODULE_FILE="${DIR}"/modules/InferenceModule/module.json
7567

7668
if [ ! -f ${INFERENCE_MODULE_FILE} ]; then
@@ -87,6 +79,9 @@ fi
8779
echo "${color_end}"
8880
next_step
8981

82+
83+
# =========================================================
84+
# === Get Web module file ===
9085
# =========================================================
9186
WEB_MODULE_FILE="${DIR}"/modules/WebModule/module.json
9287
if [ ! -f ${WEB_MODULE_FILE} ]; then
@@ -103,20 +98,27 @@ fi
10398
echo ${color_end}
10499
next_step
105100

101+
102+
# =========================================================
103+
# === Add inference module version ===
106104
# =========================================================
107-
# Check inferencemodule change
108105
echo "Checking inferencemodule change"
109106
INFERENCE_MODULE_VERSION=$(cat "${INFERENCE_MODULE_FILE}" | jq '.image.tag.version' | sed -e 's/^"//' -e 's/"$//')
110107
echo " Inference Module changed"
111108
echo " Updating version"
109+
# Add version number
110+
# 0.3.87 -> 0.3.88
112111
INFERENCE_MODULE_NEW_VERSION=$(echo "${INFERENCE_MODULE_VERSION}" | perl -pe 's/^((\d+\.)*)(\d+)(.*)$/$1.($3+1).$4/e' )
113112
echo " Inference Module version: ${INFERENCE_MODULE_VERSION} => ${INFERENCE_MODULE_NEW_VERSION}"
114113
cat "${INFERENCE_MODULE_FILE}" | jq ".image.tag.version= \"${INFERENCE_MODULE_NEW_VERSION}\"" > ${INFERENCE_MODULE_FILE}.tmp
115114
mv ${INFERENCE_MODULE_FILE}.tmp ${INFERENCE_MODULE_FILE}
116115
git add ${INFERENCE_MODULE_FILE}
117116
next_step
118117

119-
# Check webmodule change
118+
119+
# =========================================================
120+
# === Check web module version ===
121+
# =========================================================
120122
echo "Checking webmodule change"
121123
WEB_MODULE_VERSION=$(cat "${WEB_MODULE_FILE}" | jq '.image.tag.version' |sed -e 's/^"//' -e 's/"$//')
122124
echo " Web Module change"
@@ -127,45 +129,11 @@ mv ${WEB_MODULE_FILE}.tmp ${WEB_MODULE_FILE}
127129
git add ${WEB_MODULE_FILE}
128130
next_step
129131

130-
echo "Checking if Inference Module need to build new container image..."
131-
echo " Yes..."
132-
echo " ${INFERENCE_MODULE_NEW_VERSION}"
133-
echo ' Building new container images'
134-
echo " Build & push Inference Module version: ${INFERENCE_MODULE_NEW_VERSION}"
135-
docker build --rm -f "${DIR}/modules/InferenceModule/Dockerfile.cpuamd64" -t ${CONTAINER_REGISTRY_NAME}/intelligentedge/inferencemodule:${INFERENCE_MODULE_NEW_VERSION}-cpuamd64 "${DIR}/modules/InferenceModule"
136-
docker push ${CONTAINER_REGISTRY_NAME}/intelligentedge/inferencemodule:${INFERENCE_MODULE_NEW_VERSION}-cpuamd64
137-
next_step
138-
139-
echo "Checking if Web Module need to build new container image..."
140-
echo " Yes..."
141-
echo ' Building new container images'
142-
echo " Build & push Web Module version: ${WEB_MODULE_NEW_VERSION}"
143-
docker build --rm -f "${DIR}/modules/WebModule/Dockerfile.amd64" -t ${CONTAINER_REGISTRY_NAME}/intelligentedge/visionwebmodule:${WEB_MODULE_NEW_VERSION}-amd64 "${DIR}/modules/WebModule"
144-
docker push ${CONTAINER_REGISTRY_NAME}/intelligentedge/visionwebmodule:${WEB_MODULE_NEW_VERSION}-amd64
145-
next_step
146-
147-
echo 'Updating deployment file'
148-
DEPLOY_FILE="${DIR}/config/deployment.cpu.amd64.json"
149-
150-
if [ -f "${DEPLOY_FILE}" ]; then
151-
echo ' DEPLOY_FILE found:'
152-
echo " ${DEPLOY_FILE}"
153-
echo " Updating to latest version..."
154-
if [ ! -z ${INFERENCE_MODULE_NEW_VERSION} ]; then
155-
cat ${DEPLOY_FILE} | jq ".modulesContent.\"\$edgeAgent\".\"properties.desired\".modules.InferenceModule.settings.image = \"${CONTAINER_REGISTRY_NAME}/intelligentedge/inferencemodule:${INFERENCE_MODULE_NEW_VERSION}-cpuamd64\"" > ${DEPLOY_FILE}.tmp
156-
mv ${DEPLOY_FILE}.tmp ${DEPLOY_FILE}
157-
fi
158-
if [ ! -z ${WEB_MODULE_NEW_VERSION} ]; then
159-
cat ${DEPLOY_FILE} | jq ".modulesContent.\"\$edgeAgent\".\"properties.desired\".modules.WebModule.settings.image = \"${CONTAINER_REGISTRY_NAME}/intelligentedge/visionwebmodule:${WEB_MODULE_NEW_VERSION}-amd64\"" > ${DEPLOY_FILE}.tmp
160-
mv ${DEPLOY_FILE}.tmp ${DEPLOY_FILE}
161-
fi
162-
else
163-
echo ' DEPLOY_FILE not found'
164-
echo ' You have to update the version of deploy yourself...'
165-
echo ' Skipping'
166-
fi
167-
next_step
168132

133+
# =========================================================
134+
# === Commit and let Azure pipelines to handle the rest.===
135+
# =========================================================
169136
echo 'All done. Commit new version to git'
170137
echo
171138
git commit -m "new version by ${THIS_SCRIPT_NAME}"
139+
git push

0 commit comments

Comments
 (0)