-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change of description #24
base: main
Are you sure you want to change the base?
Conversation
Hi, thanks for opening, we'll take a look to review the code.
Thanks. |
|
||
Simple Python applications for demonstrating the features of [Amazon CodeGuru Profiler](https://aws.amazon.com/codeguru/) using the Python agent that is open-sourced at [aws/amazon-codeguru-profiler-python-agent](https://github.com/aws/amazon-codeguru-profiler-python-agent). | ||
![CodeGuru Profiler Console Screenshot](resources/CodeGuruProfilerPythonScreenshot.png) | ||
|
||
Check the individual folders for each specific demo application. | ||
## How it works | ||
|
||
![CodeGuru Profiler Console Screenshot for sample-demo-app](sample-demo-app/resources/CodeGuruProfilerPythonScreenshot.png) | ||
The application does some basic image processing, with some CPU-heavy | ||
operations alongside some IO-heavy operations. | ||
|
||
![CodeGuru Profiler Console Screenshot for sample-demo-django-app - cpu](sample-demo-django-app/resources/CodeGuruProfilerPythonScreenshotDemoDjangoCPU.png) | ||
It consists chiefly of two components which run in parallel, the task publisher | ||
and the image processor. | ||
|
||
![CodeGuru Profiler Console Screenshot for sample-demo-django-app - latency](sample-demo-django-app/resources/CodeGuruProfilerPythonScreenshotDemoDjangoLatency.png) | ||
CodeGuru Profiler Python agent runs inside the application, in the same way any real application | ||
would use it. It collects and reports profiling data about the application, ready to | ||
be viewed in the AWS console. | ||
|
||
![CodeGuru Profiler Console Screenshot for sample-demo-flask-app](sample-demo-flask-app/resources/CodeGuruProfilerPythonScreenshotDemoFlask.png) | ||
##### [`TaskPublisher`](aws_python_sample_application/task_publisher.py) | ||
|
||
## License | ||
Checks the S3 bucket for available images, and submits the name of some of these images | ||
to the SQS queue. | ||
|
||
This code is licensed under the Apache-2.0 License. See the [LICENSE](LICENSE) file. | ||
##### [`ImageProcessor`](aws_python_sample_application/image_processor.py) | ||
|
||
Polls SQS for names of images to process. Processing an image involves downloading | ||
it from S3, applying some image transforms (e.g. converting to monochrome), and | ||
uploading the result back to S3. | ||
|
||
## Setup | ||
|
||
Here is the summary of the steps that follow. | ||
|
||
1. Make sure you have installed the latest version of [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html). | ||
Use an IAM entity for the AWS CLI that has permissions to access CodeGuru Profiler, S3 and SQS to create all the required components for the demo application to run. | ||
2. Create a profiling group in CodeGuru Profiler, named `PythonDemoApplication`. | ||
3. Create a S3 bucket, e.g. `s3://python-demo-application-test-bucket`. Note, the bucket name must be unique across all of Amazon S3. | ||
See [here](https://docs.aws.amazon.com/cli/latest/reference/s3/mb.html) for more details. | ||
4. Create an SQS queue, e.g. `DemoApplicationQueue`. See [here](https://docs.aws.amazon.com/cli/latest/reference/sqs/create-queue.html) | ||
for more details. | ||
5. Create virtual environment with venv, e.g. `python3 -m venv ./venv`. | ||
6. Activate the virtual environment, e.g. `source venv/bin/activate`. | ||
7. Install dependency `boto3` and `skimage` through pip3 that are used for the demo application. | ||
8. Install the Python agent `codeguru_profiler_agent` through pip3. | ||
|
||
Here are the commands to run on your machine. | ||
|
||
```bash | ||
aws configure # Set up your AWS credentials and region as usual. | ||
``` | ||
|
||
```bash | ||
aws codeguruprofiler create-profiling-group --profiling-group-name PythonDemoApplication | ||
|
||
# It is required to set the DEMO_APP_BUCKET_NAME and DEMO_APP_SQS_URL environment applications for later running the demo application. | ||
|
||
# Make sure you update `YOUR-BUCKET-NAME-REPLACE-ME`with a bucket name that is unique across all of Amazon S3. | ||
export DEMO_APP_BUCKET_NAME=YOUR-BUCKET-NAME-REPLACE-ME | ||
aws s3 mb s3://${DEMO_APP_BUCKET_NAME} | ||
|
||
# Make sure you update `YOUR-AWS-REGION-REPLACE-ME` and `YOUR-ACCOUNT-ID-REPLACE-ME`. | ||
aws sqs create-queue --queue-name DemoApplicationQueue | ||
export DEMO_APP_SQS_URL=https://sqs.${YOUR-AWS-REGION-REPLACE-ME}.amazonaws.com/YOUR-ACCOUNT-ID-REPLACE-ME/DemoApplicationQueue | ||
``` | ||
|
||
```bash | ||
python3 -m venv ./venv | ||
source venv/bin/activate | ||
|
||
pip3 install boto3 scikit-image | ||
pip3 install codeguru_profiler_agent | ||
``` | ||
|
||
For Python 3.9, installing `scikit-image` may cause failures; this is a known issue, discussed in https://github.com/scikit-image/scikit-image/issues/5060. | ||
|
||
## How to run | ||
|
||
The main entry point of this application is in the ``aws_python_sample_application/main.py`` in the ``SampleDemoApp`` class. | ||
|
||
```bash | ||
# Run the demo application with the CodeGuru Profiler Python Agent. | ||
python3 -m codeguru_profiler_agent -p PythonDemoApplication aws_python_sample_application/main.py | ||
``` | ||
|
||
Let it run for at least 15 to 20 minutes to get plenty of data shown for the PythonDemoApplication profiling group. | ||
|
||
**Note**: When running the demo application for the first time, it is expected to see the error message such as | ||
`No messages exists in SQS queue at the moment, retry later.` and | ||
`Failed to list images in demo-application-test-bucket-1092734-YOUR-BUCKET-REPLACE-ME under input-images/` | ||
printing to the terminal. Our demo application would handle the upload of the image and the publish of SQS message | ||
after a few seconds. | ||
|
||
## How to see the results | ||
|
||
Go to the [AWS CodeGuru Profiler console](https://console.aws.amazon.com/codeguru/profiler) to check the results. Choose the region you picked and your profiling group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you move this here? This was intentionally moved inside each folder as this repository contains multiple sample applications.
serviceAccountName: codeguru-profiler | ||
containers: | ||
- name: codeguru-python-app-deployment | ||
image: 338918620411.dkr.ecr.eu-west-1.amazonaws.com/codeguru-python-app-deployment:latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is your personal account, it shouldn't be here.
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.