oss-slu / esp

MIT License
0 stars 5 forks source link

Retrieve ORCA Data #38

Closed haydenkarl22 closed 6 months ago

haydenkarl22 commented 7 months ago

Fixes issue #36 So far, I replaced the file destination path to make it universal (was made universal on APIusingCMD.py the same way). I'm currently working on the runBackend() method, as I think this is the key to getting the components to speak to each other. Before my modifications, runBackend() was adding the fileName and selectedBrands (selectedBrands can be thought of as the combination of the fields entered in the frontend by the user) to the console logs and attempting to return them, which it was returning them incorrectly. What I have attempted to do is correct the POST element, and add basic error handling. My modifications have not resolved the issue, however, so there is more work to be done.

haydenkarl22 commented 6 months ago

This sprint unfortunately is not finished. I have corrected the JSON connection between the frontend and backend, as can be seen when attempting to generate the output file (the search_term array, section array, etc are properly stored in data_json). However, I ran into an issue that was not expected with our brand interface in dashboard.component.ts. The brands are not being updated anywhere in the code, so that needs to be an issue designed for another sprint. I unfortunately cannot figure out how to fix my BAD REQUEST issue. I have verified that the data being sent to the backend is correct, and I have no clue what is causing this 400 error. I have installed flask-cors and implemented it into the project, as that was an issue that was flagging in my browser's development tools. I'll attach a screenshot below of what I'm seeing. I have connected the frontend to the backend however, I just can't get the ORCA data to convert at this moment.


If you want to attempt to replicate my issue, one needs flask, flask-cors, angular cli installed. You must start the the frontend component by running ng serve in one terminal at the orca_data_converter directory. next, go to the backend/src/ directory and type $env:FLASK_APP = "API.py" into a new terminal. this will set the default flask app to API.py. Next run flask run, which will start your backend. From here, you can send requests from the front end browser to the backend and see the error I'm encountering.

Screenshot 2024-04-08 143748 Screenshot 2024-04-08 143824

SiriChandanaGarimella commented 6 months ago

@haydenkarl22 - Fixed the API issue and the integration of frontend and backend. Please review the code and test it. I felt that there was no need for the brand groups in dashboar.component.ts. If you think that it is needed then please make the changes accordingly. Also, I feel that the format of the API request is not great. I just made it work. So update and change the format. Inputs to be provided for now in the web page to test it:

  1. Upload the input .txt file 2.CARTESIAN COORDINATES (ANGSTROEM)
  2. FIRST 6
  3. [1,2,3]
  4. true
  5. 2000 sample curl to test the API: curl --location 'http://localhost:5000/find-sections' \ --header 'Content-Type: application/json' \ --data '{ "file_path": "/Users/sirichandanagarimella/Documents/OSS/esp/Backend/src/instance/uploads/Styrene-bd2.txt", "search_terms": "[\"CARTESIAN COORDINATES (ANGSTROEM)\"]", "sections": "[1,2,3]", "specifyLines": "FIRST 6", "use_total_lines": "true", "total_lines": "2000" }'
SiriChandanaGarimella commented 6 months ago

@haydenkarl22 - Please remove the print statements from all the files. Also, the changes I made for POST/find-sections are in the app.py file. Please update your changes in the same file. Please make sure that the input for "sections" has to be taken as 1,2. Currently, it works only when it is given as [1,2]. And make the search input case-insensitive. Also, test your changes once all the above points are done, and attach the screenshot of the response to the description.

haydenkarl22 commented 6 months ago

Made the changes asked in regards to moving my changes to app.py, removing the need for brackets for the section numbers, and changed the frontend text fields to make them convert any lowercase text to uppercase text when needed (like for keyterms and specify_lines). unfortunately, I still get bad POST requests when trying to save the output doc. This happened even before I made my changes today. I have typed each field character for character as you did it and still I get no output file. When we meet in person next wednesday, if you could show me it working on your machine that would be great. below are attached screenshots of my POST error. Screenshot 2024-04-14 123409

SiriChandanaGarimella commented 6 months ago

The integration is working fine now and the section input can now be provided as 1,2 instead of [1,2]. Also, the "use total lines" and "Total number of lines for output doc" are now changed to non-mandatory fields. Failing test cases will be tracked as part of the issue #46