The contents of this PR creates a GitHub action to deploy a Sagemaker Instance that includes ML model content.
(User Story, Total time to complete the Sprint, and Acceptance Criteria can be found on the connected Issue #128)
Time Spent on Issue:
Task Breakdown Description
Approx. Time
Research and Investigate Sagemaker Actions
4 hrs
Modify a working sentiment analysis model to test
3 hrs
Python dependencies requirements.txt file
0.5 hrs
Create makeSgmkrInstance.bash file
3 hrs
Create sgmkr-instance-deploy.yml file
4 hrs
Create the UI ClearButton.js with layout
0.5 hrs
PR documentation
1 hr
Added Files/Folder Locations
File: makeSgmkrInstance.bash
Location: .github/scripts
File: sgmkr-instance-deploy.yml
Location: .github/workflows
Folder: sentiment-analysis
Files in Folder:
floop_data_15k.json (temporary and for testing purposes only)
requirements.txt
sentiment-analysis-sample.py (This is a temporary file as the ML model for sentiment analysis hasn't been updated by the backend team yet)
Location of sentiment-analysis folder: backend/
File: ClearButton.js
Location: frontend/floop_feedback/components
Testing Gallery
Create a testing branch.
IMPORTANT: Make sure the sentiment-analysis folder in the backend folder (with the three files) is present shown below or you will get an error when the github action runs.
In the sgmkr-instance-deploy.yml file, change line 7 to your testing branch (under the development branch)
Push your test branch
Once pushed, go to the class repo and click Actions you should have a sm_deploy running. This could take about 2-3 minutes total to complete.
While still in GitHub Action screen, Expand the Instance Name, you will see a URL that includes the name of the Instance you will have created in SageMaker. (I highlighted it in yellow)
It will consist of the first four letters of your GitHub user name, some random text, the date, and the word "instance" at the end.
While still in the GitHub Action screen, Expand the Display Sentiment Analysis . It should run the results of the sentiment-analysis-sample.py as it is included in the action. Again NOTE: This is a temporary result file until the ML model is updated by the backend team.
Now you can go to AWS SageMaker, find Notebook then Notebook instance on the left side panel and it should list all Notebook Instances. Locate yours based on the name the GitHub Action created for you. NOTE the status of the notebook. It should be either InService or still may be in Pending.
Once your Notebook is InService you can open your Instance up in Jupyter to locate your preferred files which are based on what is currently in the repo. NOTE that the sentiment-analysis folder WILL NOT be present. The files in the instance are only what's based CURRENTLY in the repo. Only once this branch gets merged into the repo will the files appear on the instance.
-MAKE SURE TO STOP THEN DELETE YOUR INSTANCE ONCE TESTED:)
You can test the sample data I provided (sentiment-analysis-sample.py) locally on Jupyter or another IDE (until this PR is merged) though may not be required for this PR unless you are running errors. Make sure you have the floop_data_15k.json file as well as the requirements.txt. The Requirements are a list of needed imports to run the sample analysis locally so make sure you have them installed on your local Jupyter notebook other packages might be needed if you receive errors when running it they will tell you the needed imports to install.
(The Github Action will automatically import these requirements as shown below)
Required Imports: (Again others maybe needed depending what you already have installed
As long as you have all necessary imports on your local, The sample should run successful and you should have the results similar to what the GitHub Action displayed this time with a pie chart.
Note it will also generate a results.csv file but again this isn't the final model.
Included in this PR is an additional UI function: A Clear button. If you want to test that add you test branch to S3-deploy.yml file like you did above to the sgmkr-instance-deploy.yml file.
Push the branch.
Go to GitHub actions this time S3-deploy and scroll to the 10th run job to find your http: link. Double click or copy paste in a new window and you will see the additional Clear button included.
Future Troubleshooting
For the Floop Team: in the makeSgmkrInstance.bash file, Line 25, the default-code-repository will need to be changed to the repo where the analysis files are located in order for them to appear in the Notebook Instance.
Future Analysis: There doesn't seem to be too much out there in resources to properly create a SageMaker instance through GitHub Actions to deploy just certain files. Future research beyond this class Sprint may be required to perfect it.
Documentation:
Closes #128
(User Story, Total time to complete the Sprint, and Acceptance Criteria can be found on the connected Issue #128)
Time Spent on Issue:
requirements.txt
filemakeSgmkrInstance.bash
filesgmkr-instance-deploy.yml
fileClearButton.js
with layoutAdded Files/Folder Locations
File: makeSgmkrInstance.bash
File: sgmkr-instance-deploy.yml
Folder: sentiment-analysis
File: ClearButton.js
Testing Gallery
Create a testing branch.
IMPORTANT: Make sure the
sentiment-analysis
folder in thebackend
folder (with the three files) is present shown below or you will get an error when the github action runs.In the
sgmkr-instance-deploy.yml
file, change line 7 to your testing branch (under the development branch)Push your test branch
Once pushed, go to the class repo and click Actions you should have a sm_deploy running. This could take about 2-3 minutes total to complete.
While still in GitHub Action screen, Expand the
Instance Name
, you will see a URL that includes the name of the Instance you will have created in SageMaker. (I highlighted it in yellow) It will consist of the first four letters of your GitHub user name, some random text, the date, and the word "instance" at the end.While still in the GitHub Action screen, Expand the
Display Sentiment Analysis
. It should run the results of thesentiment-analysis-sample.py
as it is included in the action. Again NOTE: This is a temporary result file until the ML model is updated by the backend team.Now you can go to AWS SageMaker, find Notebook then Notebook instance on the left side panel and it should list all Notebook Instances. Locate yours based on the name the GitHub Action created for you. NOTE the status of the notebook. It should be either
InService
or still may be inPending
.Once your Notebook is
InService
you can open your Instance up in Jupyter to locate your preferred files which are based on what is currently in the repo. NOTE that the sentiment-analysis folder WILL NOT be present. The files in the instance are only what's based CURRENTLY in the repo. Only once this branch gets merged into the repo will the files appear on the instance.-MAKE SURE TO STOP THEN DELETE YOUR INSTANCE ONCE TESTED:)
You can test the sample data I provided (sentiment-analysis-sample.py) locally on Jupyter or another IDE (until this PR is merged) though may not be required for this PR unless you are running errors. Make sure you have the
floop_data_15k.json
file as well as therequirements.txt
. The Requirements are a list of needed imports to run the sample analysis locally so make sure you have them installed on your local Jupyter notebook other packages might be needed if you receive errors when running it they will tell you the needed imports to install.(The Github Action will automatically import these requirements as shown below)
Required Imports: (Again others maybe needed depending what you already have installed
As long as you have all necessary imports on your local, The sample should run successful and you should have the results similar to what the GitHub Action displayed this time with a pie chart.
Note it will also generate a
results.csv
file but again this isn't the final model.Included in this PR is an additional UI function: A
Clear
button. If you want to test that add you test branch toS3-deploy.yml
file like you did above to thesgmkr-instance-deploy.yml
file.Push the branch.
Go to GitHub actions this time S3-deploy and scroll to the 10th run job to find your http: link. Double click or copy paste in a new window and you will see the additional Clear button included.
Future Troubleshooting
makeSgmkrInstance.bash
file, Line 25, the default-code-repository will need to be changed to the repo where the analysis files are located in order for them to appear in the Notebook Instance.