-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fall 2022 Work #53
base: dev
Are you sure you want to change the base?
Fall 2022 Work #53
Conversation
Li-Haowei
commented
Dec 1, 2022
- Delete the file on file retrieval
- Upload files function polished
- Uploaded file structures changed
- Frontend UI changed
- minor changes
This is specific for testing GitHub actions to see tests
Is this deployed somewhere so I can look at it? I know you have the hosting setup on our(spark's) GCP account. Is it deployed there? |
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.
Overall looks good. Nice job working on both the frontend and backend. I know multiple people worked on this PR so make sure everyone individually responds my comments.
@@ -1,51 +1,51 @@ | |||
# Author: Rishab |
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.
Please restore the original version of this file
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.
I commented them out since the github action runs everytime we push and it slow down my testing on my unit test yml. I have reverted it back to older version
README.md
Outdated
- Create different user types, with support for different user permissions | ||
- Motivation: so patients and caretakers can both upload/manage files on behalf of the patient | ||
- Suggested direction | ||
- Currently, the ERD of the system looks as follows: [link](https://excalidraw.com/#json=-LCSG-ShDmak9AprUI9LT,zhR7TQiJovH9fbLHI2MJsA) | ||
- A modification of the database and user flow to follow this general guideline would allow for these features to be built, as this would allow both patients and caretakers to upload/retrieve from the same document within the newly created collections: [link](https://excalidraw.com/#json=21EzZvSgTpRM558zRtxWx,e5qdQqTUEmp2myNCfwgo-g) | ||
- Develop additional audio processing features: | ||
- Background noise reduction | ||
- Improve the clarity of slurred subject voice | ||
- Other features: | ||
- Folder layout in processed files pages | ||
- User is able to delete processed files | ||
- User input in trimming/splitting process | ||
|
||
- User input in trimming/splitting process |
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.
Please expand this section to be more verbose and better explain why the user features are needed etc. Talk about use cases etc
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.
Will do
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.
Done!
@@ -208,7 +206,78 @@ def retrieve_audio(): | |||
print("Generated GET signed URL:") | |||
return url | |||
|
|||
@app.route('/delete_unprocessed_audio', methods=['DELETE']) |
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.
Add documentation on the expected form of the HTTP request. Should provide an example HTTP request.
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.
Done!
if cloud_storage_filename not in list(audio.values()): | ||
new_audios.append(audio) |
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 do you do this? It seems that the user could pass in arbitrary audio file names and they could get appended to the users list of audio. Which would not be valid since they would not actually exist.
It seems you should check if the passed audio is in the list, if it's not then that's an error. Since we must use the database as the single source of truth since it's the only thing that keeps data on what audio belongs to each person.
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.
Audio is an example audio already existing in the user's document (see lines 229-233, these get the user doc, then the audios). So, this line is seeing if the unprocessed audio is part of this given unprocessed/processed audio combination. Then, if it is not it appends it to new_audios which is becomes the new list of audios in the firebase.
|
||
@app.route('/delete_processed_audio', methods=['DELETE']) |
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 function does the same thing as the other one. Please find a way to not duplicate the code. Instead, maybe write an inner function that you pass a parameter of some sort to etc. If you're copying and pasting code you're doing something wrong (: (Normally but not always)
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.
They have some slight differences. We have changed the database a little bit, and yes, there is more elegant way of combining them, but they are essentially deleting different things so we figured it is better having two of them separated to avoid future confusion
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.
Please add a comment in the code on what the slight difference is! The next team will need to know.
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.
Done! Left extensive comments.
#prepPath = '/tmp/' + re.split('.wav|.WAV', (filePath.split('/tmp/')[1]))[0] + 'Edited.WAV' # the original way that append "Edited" each chunk | ||
prepPath = '/tmp/' + re.split('.wav|.WAV', (filePath.split('/tmp/')[1]))[0] + '.WAV' |
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.
What happens if the file does not end in .wav?
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.
It is still .wav, we just remove "Edited" since there are original clip and processed clip stored and displayed separately
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.
My question was more, what happens if the user uploads something that is not a .wav file? Recall that any frontend verification can always be bypassed so the API should not trust any data it receives.
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.
bump @Li-Haowei
client/myModuleResolver.js
Outdated
// my-module-resolve.js | ||
module.exports = (request, options) => { | ||
// Call the defaultResolver, so we leverage its cache, error handling, etc. | ||
return options.defaultResolver(request, { | ||
...options, | ||
// Use packageFilter to process parsed `package.json` before the resolution (see https://www.npmjs.com/package/resolve#resolveid-opts-cb) | ||
packageFilter: pkg => { | ||
if(pkg.name.startsWith('@firebase')) { | ||
return { | ||
...pkg, | ||
// Alter the value of `main` before resolving the package | ||
main: pkg.esm5 || pkg.module, | ||
}; | ||
} | ||
|
||
return pkg; | ||
}, | ||
}); | ||
}; |
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.
Can you add a comment in this file on why this file exists
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.
Yes, just added comments
document.body.appendChild(style); | ||
var frame = document.createElement("div"); | ||
frame.id = "divLoadingFrame"; | ||
frame.classList.add("loading-frame"); | ||
for (var i = 0; i < 10; i++) { | ||
var track = document.createElement("div"); | ||
track.classList.add("loading-track"); | ||
var dot = document.createElement("div"); | ||
dot.classList.add("loading-dot"); | ||
track.style.transform = "rotate(" + String(i * 36) + "deg)"; | ||
track.appendChild(dot); | ||
frame.appendChild(track); | ||
} | ||
document.body.appendChild(frame); | ||
var wait = 0; | ||
var dots = document.getElementsByClassName("loading-dot"); | ||
// There was a warning i is already defined, thus use j for index instead. | ||
for (var j = 0; j < dots.length; j++) { | ||
window.setTimeout(function(dot) { | ||
dot.classList.add("loading-dot-animated"); | ||
}, wait, dots[j]); | ||
wait += 150; | ||
} | ||
}; |
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.
Can you explain why you're manually manipulating the DOM? It's generally never a good idea to manually touch the DOM when using react.
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.
I didn't write this code but someone in my team. But I think it is for the loading animation.
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.
I mean, I know what it's doing but I want to know why it was written. It is very very very bad form to manually manipulate the DOM in react.
@shaolin-x Can you please let me know why it's been coded this way? How are you sure it's safe?
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.
Hi Ian, thanks for the notice. I actually used the existing code from Upload.js where it used this code to show a loading window, so I am not sure why it is originally written this way.
I have been working on using a different approach to show the loading window. Could you also give me some tips for an alternative approach?
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.
You can use a conditional render based on a state variable(`useState) and render something that says loading or some spinner etc.
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.
Loading windows fixed for both Retrieve.js and Upload.js!
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.
I see that there are alot components that are commented out. Please try to clean it abit. If there are some you don't want to delete, maybe leave a comment to let the next team know what it's for.
@@ -35,10 +61,16 @@ function Dashboard() { | |||
// eslint-disable-next-line react-hooks/exhaustive-deps |
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.
please do not disable eslint
The reason why it's giving you the following errors is because there are multiple dependencies used inside useEffect()
, such as db
, setName
, history
and console
. Either decrease the dependencies in useEffect
or declare the dependencies inside the array.
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.
Done!
@@ -6,6 +6,32 @@ import { auth, db, logout } from "../firebase"; | |||
import { Button } from "react-bootstrap"; | |||
import "./Dashboard.css"; | |||
|
|||
import { Card, CardActionArea, CardContent, Grid, Typography, Paper, Container, Box } from "@mui/material" | |||
import { makeStyles } from "@mui/styles"; |
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.
please note in your documentation that @mui/styles
is a legacy library so that the next team will know.
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.
Done!
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.
@danieldelijani Thanks Daniel, appreciate your help!
console.log('Response from delete audio:'); | ||
console.log(response); |
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.
don't forget to delete console.log
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.
Done!
Bump, please respond to our comments team! |
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.
a few more changes
document.body.appendChild(style); | ||
var frame = document.createElement("div"); | ||
frame.id = "divLoadingFrame"; | ||
frame.classList.add("loading-frame"); | ||
for (var i = 0; i < 10; i++) { | ||
var track = document.createElement("div"); | ||
track.classList.add("loading-track"); | ||
var dot = document.createElement("div"); | ||
dot.classList.add("loading-dot"); | ||
track.style.transform = "rotate(" + String(i * 36) + "deg)"; | ||
track.appendChild(dot); | ||
frame.appendChild(track); | ||
} | ||
document.body.appendChild(frame); | ||
var wait = 0; | ||
var dots = document.getElementsByClassName("loading-dot"); | ||
// There was a warning i is already defined, thus use j for index instead. | ||
for (var j = 0; j < dots.length; j++) { | ||
window.setTimeout(function(dot) { | ||
dot.classList.add("loading-dot-animated"); | ||
}, wait, dots[j]); | ||
wait += 150; | ||
} | ||
}; |
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.
I mean, I know what it's doing but I want to know why it was written. It is very very very bad form to manually manipulate the DOM in react.
@shaolin-x Can you please let me know why it's been coded this way? How are you sure it's safe?