Skip to content

Commit 19c7b85

Browse files
committed
4.3.45 release
1 parent 446daa9 commit 19c7b85

25 files changed

+1459
-0
lines changed

resources/appliance-changelog.md

+20
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
The following sections detail updates to the AWS Panorama Appliance software, including changes to the operation system, AWS Panorama libraries, and the application SDK.
44

5+
# 4.3.45
6+
7+
**Release date**: 2022-03-24
8+
9+
**Type**: Required
10+
11+
## GPU access
12+
13+
You can access the graphics processor (GPU) on the device to use GPU-accelerated libraries, or run machine learning models in your application code. To turn on GPU access, you add GPU access as a requirement to the package configuration after building your application code container.
14+
15+
For more information, see [Using the GPU](https://docs.aws.amazon.com/panorama/latest/dev/applications-gpuaccess.html).
16+
17+
## Inbound ports
18+
19+
You can monitor or debug applications locally by running an HTTP server or other listener alongside your application code. To serve external traffic, you map ports on the device to ports on your application container.
20+
21+
A new sample application, [debug-server](https://github.com/awsdocs/aws-panorama-developer-guide/tree/main/sample-apps/debug-server), demonstrates how to use inbound ports to serve HTTP traffic. It uses multithreading to run application code, an HTTP server, and an HTTP client simultaneously. After running for a few minutes, the application sends an HTTP request to the device over the local network that signals it to restart the application code.
22+
23+
For more information, see [Serving inbound traffic](https://docs.aws.amazon.com/panorama/latest/dev/applications-gpuaccess.html).
24+
525
# 4.3.35
626

727
**Release date**: 2022-02-22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
python3 -m py_compile packages/*-DEBUG_SERVER-1.0/application.py
4+
echo "Compilation successful"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
TEMPLATE_NAME=${PWD##*/}
4+
STACK_NAME=panorama-$TEMPLATE_NAME
5+
aws cloudformation deploy --template-file $TEMPLATE_NAME.yml --stack-name $STACK_NAME --capabilities CAPABILITY_NAMED_IAM
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
# download sample model
4+
MODEL_ASSET=fd1aef48acc3350a5c2673adacffab06af54c3f14da6fe4a8be24cac687a386e.tar.gz
5+
if [ ! -f "assets/${MODEL_ASSET}" ]; then
6+
curl -L https://github.com/awsdocs/aws-panorama-developer-guide/releases/download/v1.0-ga/${MODEL_ASSET} -o assets/${MODEL_ASSET}
7+
fi
8+
# rename directories
9+
panorama-cli import-application
10+
ACCOUNT_ID=$(ls packages | grep -Eo '[0-9]{12}' | head -1)
11+
ACCOUNT_EX=123456789012
12+
sed -i "s/${ACCOUNT_EX}/${ACCOUNT_ID}/ig" graphs/my-app/*.json
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
ACCOUNT_ID=$(aws sts get-caller-identity --output text --query 'Account')
4+
panorama-cli build-container --container-asset-name code_asset --package-path packages/${ACCOUNT_ID}-DEBUG_SERVER-1.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
panorama-cli package-application

sample-apps/debug-server/5-deploy.sh

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
if [[ $# -eq 3 ]] ; then
4+
NAME=$1
5+
GRAPH_PATH=$2
6+
OVERRIDE_PATH=$3
7+
else
8+
NAME=${PWD##*/}
9+
GRAPH_PATH="graphs/my-app/graph.json"
10+
OVERRIDE_PATH="graphs/my-app/override.json"
11+
fi
12+
# device id
13+
if [ -f "device-id.txt" ]; then
14+
DEVICE_ID=$(cat device-id.txt)
15+
echo "Deploying to device ${DEVICE_ID}"
16+
else
17+
echo "Getting devices..."
18+
DEVICES=$(aws panorama list-devices)
19+
DEVICE_NAMES=($((echo ${DEVICES} | jq -r '.Devices |=sort_by(.LastUpdatedTime) | [.Devices[].Name] | @sh') | tr -d \'\"))
20+
DEVICE_IDS=($((echo ${DEVICES} | jq -r '.Devices |=sort_by(.LastUpdatedTime) | [.Devices[].DeviceId] | @sh') | tr -d \'\"))
21+
for (( c=0; c<${#DEVICE_NAMES[@]}; c++ ))
22+
do
23+
echo "${c}: ${DEVICE_IDS[${c}]} ${DEVICE_NAMES[${c}]}"
24+
done
25+
echo "Choose a device"
26+
read D_INDEX
27+
echo "Deploying to device ${DEVICE_IDS[${D_INDEX}]}"
28+
echo -n ${DEVICE_IDS[${D_INDEX}]} > device-id.txt
29+
fi
30+
# existing application instance id
31+
if [ -f "application-id.txt" ]; then
32+
EXISTING_APPLICATION=$(cat application-id.txt)
33+
REPLACE_ARG="--application-instance-id-to-replace=${EXISTING_APPLICATION}"
34+
echo "Replacing application instance ${EXISTING_APPLICATION}"
35+
fi
36+
# application manifest
37+
GRAPH=$(cat ${GRAPH_PATH} | tr -d '\n' | tr -d '[:blank:]')
38+
MANIFEST="$(jq --arg value "${GRAPH}" '.PayloadData="\($value)"' <<< {})"
39+
##echo "MANIFEST: ${MANIFEST}"
40+
# manifest override
41+
OVERRIDE=$(cat ${OVERRIDE_PATH} | tr -d '\n' | tr -d '[:blank:]')
42+
MANIFEST_OVERRIDE="$(jq --arg value "${OVERRIDE}" '.PayloadData="\($value)"' <<< {})"
43+
##echo "MANIFEST_OVERRIDE: ${MANIFEST_OVERRIDE}"
44+
# application role
45+
STACK_NAME=panorama-${NAME}
46+
ROLE_ARN=$(aws cloudformation describe-stacks --stack-name panorama-${PWD##*/} --query 'Stacks[0].Outputs[?OutputKey==`roleArn`].OutputValue' --output text)
47+
if [[ -z "${ROLE_ARN}" ]]; then
48+
echo "Application role is not available. Run 1-create-role.sh to create."
49+
while true; do
50+
read -p "Continue without AWS SDK functionality? (y/n)" response
51+
case $response in
52+
[Yy]* ) break;;
53+
[Nn]* ) exit 1;;
54+
* ) echo "Response must start with y or n.";;
55+
esac
56+
done
57+
else
58+
ROLE_ARG="--runtime-role-arn=${ROLE_ARN}"
59+
fi
60+
APPLICATION_ID=$(aws panorama create-application-instance ${REPLACE_ARG} --manifest-payload="${MANIFEST}" --default-runtime-context-device=${DEVICE_ID} --name=${NAME} --description="command-line deploy" --tags client=sample --manifest-overrides-payload="${MANIFEST_OVERRIDE}" ${ROLE_ARG} --output text)
61+
echo "New application instance ${APPLICATION_ID}"
62+
echo -n $APPLICATION_ID > application-id.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
if [ -f "application-id.txt" ]; then
4+
APPLICATION_ID=$(cat application-id.txt)
5+
fi
6+
if [ -f "device-id.txt" ]; then
7+
DEVICE_ID=$(cat device-id.txt)
8+
fi
9+
QUERY="ApplicationInstances[?ApplicationInstanceId==\`APPLICATION_ID\`]"
10+
QUERY=${QUERY/APPLICATION_ID/$APPLICATION_ID}
11+
MONITOR_CMD="aws panorama list-application-instances --device-id ${DEVICE_ID} --query ${QUERY}"
12+
MONITOR_CMD=${MONITOR_CMD/QUERY/$QUERY}
13+
while true; do
14+
$MONITOR_CMD
15+
sleep 60
16+
done
17+
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
TEMPLATE=${PWD##*/}
4+
STACK_NAME=panorama-$TEMPLATE
5+
while true; do
6+
read -p "Delete stack $STACK_NAME? (y/n)" response
7+
case $response in
8+
[Yy]* ) aws cloudformation delete-stack --stack-name $STACK_NAME; break;;
9+
[Nn]* ) break;;
10+
* ) echo "Response must start with y or n.";;
11+
esac
12+
done

sample-apps/debug-server/README.md

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Debug server
2+
3+
The project source includes Python code and supporting resources:
4+
5+
- `debug-server.yml` - A template that creates an IAM role for the application.
6+
- `01-create-role.sh`, etc. - Shell scripts that use the AWS CLI to deploy and manage the application.
7+
8+
Use the following instructions to deploy the sample application.
9+
10+
**Warning** This sample application opens port 8080 on your device to incoming traffic. Review your [network configuration](https://docs.aws.amazon.com/panorama/latest/dev/appliance-network.html) and ensure that only the device and other approved clients can send traffic to this port.
11+
12+
# Requirements
13+
14+
This project uses the following software.
15+
16+
- The Bash shell. For Linux and macOS, this is included by default. In Windows 10, you can install the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to get a Windows-integrated version of Ubuntu and Bash.
17+
- [The AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html) v1.17 or newer.
18+
- [jq](https://stedolan.github.io/jq/) to parse JSON responses from AWS services.
19+
- [Python 3](https://www.python.org/downloads/)
20+
- [The AWS Panorama application CLI](https://github.com/aws/aws-panorama-cli)
21+
22+
You can use `pip` to install the application CLI:
23+
24+
$ pip install --upgrade panoramacli
25+
26+
# Setup
27+
28+
Download or clone this repository.
29+
30+
$ git clone https://github.com/awsdocs/aws-panorama-developer-guide.git
31+
$ cd aws-panorama-developer-guide/sample-apps/debug-server
32+
33+
To create a role that grants the application permission to upload metrics, run `1-create-role.sh`.
34+
35+
debug-server$ ./1-create-role.sh
36+
Waiting for changeset to be created..
37+
Waiting for stack create/update to complete
38+
Successfully created/updated stack - panorama-debug-server
39+
40+
This script uses AWS CloudFormation to create AWS resources, which are defined in the template [debug-server.yml](debug-server.yml). If the CloudFormation stack that contains the resources already exists, the script updates it with any changes to the template or function code.
41+
42+
# Import application
43+
44+
To import the application, run `2-import-app.sh`.
45+
46+
debug-server$ ./2-import-app.sh
47+
% Total % Received % Xferd Average Speed Time Time Time Current
48+
Dload Upload Total Spent Left Speed
49+
100 4566k 100 4566k 0 0 3673k 0 0:00:01 0:00:01 --:--:-- 3673k
50+
Sucessfully imported application
51+
52+
This script uses the application CLI to update source paths with your account ID, and downloads the sample model archive.
53+
54+
Next, open the `graphs/my-app/override.json` and replace the placeholder values with your camera and device information.
55+
56+
{
57+
"nodeGraphOverrides": {
58+
"nodes": [
59+
{
60+
"name": "camera_node_override",
61+
"interface": "012345678901::exterior-north.exterior-north"
62+
},
63+
{
64+
"name": "region_override",
65+
"interface": "string",
66+
"value": "us-west-2"
67+
},
68+
{
69+
"name": "device_ip_override",
70+
"interface": "string",
71+
"value": "192.168.99.100"
72+
},
73+
74+
You can find your device's IP address in the AWS Panorama console or with the `aws panorama describe-device` command.
75+
76+
$ aws panorama describe-device --device-id device-6272wtqu56awmshv3gxzowewea --query 'CurrentNetworkingStatus'
77+
78+
# Build and deploy
79+
80+
Run the following scripts to build the application, upload it to Amazon S3, and deploy it to a device.
81+
82+
./3-build-container.sh
83+
./4-package-app.sh
84+
./5-deploy.sh
85+
86+
The first time you deploy, the `5-deploy.sh` script prompts you to choose a device. It stores the device ID and application instance ID in local files for subsequent deployments.
87+
88+
# Cleanup
89+
90+
To clean up project resources, run `9-delete-role.sh`.
91+
92+
debug-server$ ./9-delete-role.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"mlModelDescriptor": {
3+
"envelopeVersion": "2021-01-01",
4+
"framework": "PYTORCH",
5+
"frameworkVersion": "1.8",
6+
"precisionMode": "FP16",
7+
"inputs": [
8+
{
9+
"name": "data",
10+
"shape": [
11+
1,
12+
3,
13+
224,
14+
224
15+
]
16+
}
17+
]
18+
}
19+
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Description: Resources for an AWS Panorama application.
3+
Resources:
4+
runtimeRole:
5+
Type: AWS::IAM::Role
6+
Properties:
7+
AssumeRolePolicyDocument:
8+
Version: "2012-10-17"
9+
Statement:
10+
-
11+
Effect: Allow
12+
Principal:
13+
Service:
14+
- panorama.amazonaws.com
15+
Action:
16+
- sts:AssumeRole
17+
Policies:
18+
- PolicyName: cloudwatch-putmetrics
19+
PolicyDocument:
20+
Version: 2012-10-17
21+
Statement:
22+
- Effect: Allow
23+
Action: 'cloudwatch:PutMetricData'
24+
Resource: '*'
25+
Path: /service-role/
26+
Outputs:
27+
roleName:
28+
Description: The application runtime role's name
29+
Value: !Ref runtimeRole
30+
roleArn:
31+
Description: The application runtime role's ARN
32+
Value: !GetAtt runtimeRole.Arn

0 commit comments

Comments
 (0)