Skip to content
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

Open
wants to merge 118 commits into
base: dev
Choose a base branch
from
Open

Fall 2022 Work #53

wants to merge 118 commits into from

Conversation

Li-Haowei
Copy link
Collaborator

  1. Delete the file on file retrieval
  2. Upload files function polished
  3. Uploaded file structures changed
  4. Frontend UI changed
  5. minor changes

@IanSaucy
Copy link
Member

IanSaucy commented Dec 5, 2022

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?

Copy link
Member

@IanSaucy IanSaucy left a 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.

.github/workflows/firebase-hosting-merge.yml Outdated Show resolved Hide resolved
@@ -1,51 +1,51 @@
# Author: Rishab
Copy link
Member

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

Copy link
Collaborator Author

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
Comment on lines 107 to 115
- 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
Copy link
Member

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

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'])
Copy link
Member

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Comment on lines +234 to +235
if cloud_storage_filename not in list(audio.values()):
new_audios.append(audio)
Copy link
Member

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.

Copy link

@danieldelijani danieldelijani Dec 12, 2022

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'])
Copy link
Member

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)

Copy link
Collaborator Author

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

Copy link
Member

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Left extensive comments.

Comment on lines +24 to +25
#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'
Copy link
Member

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?

Copy link
Collaborator Author

@Li-Haowei Li-Haowei Dec 12, 2022

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

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump @Li-Haowei

Comment on lines 1 to 19
// 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;
},
});
};
Copy link
Member

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, just added comments

Comment on lines 89 to 112
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;
}
};
Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Member

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?

Copy link
Collaborator

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?

Copy link
Member

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.

Copy link
Collaborator

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!

@IanSaucy IanSaucy changed the title So far what we have done Fall 2022 Work Dec 5, 2022
Copy link
Collaborator

@toucham toucham left a 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.

backend/app.py Show resolved Hide resolved
@@ -35,10 +61,16 @@ function Dashboard() {
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Collaborator

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.

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";
Copy link
Collaborator

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.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Collaborator

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!

Comment on lines 172 to 173
console.log('Response from delete audio:');
console.log(response);
Copy link
Collaborator

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@IanSaucy
Copy link
Member

IanSaucy commented Dec 8, 2022

Bump, please respond to our comments team!

Copy link
Member

@IanSaucy IanSaucy left a 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

Comment on lines 89 to 112
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;
}
};
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants