calpoly-csai / api

Official API for the NIMBUS Voice Assistant accessible via HTTP REST protocol.
https://nimbus.api.calpolycsai.com/
GNU General Public License v3.0
9 stars 4 forks source link

Create NimbusDatabase Entity for OfficeHour data #116

Closed mfekadu closed 4 years ago

mfekadu commented 4 years ago

Objective

Enhance the NimbusDatabase’s ability to answer questions like

"What is Dr. John Smith's office hours for this quarter?"

Or even

"When is Dr. John Smith available this quarter?"

The Computer Science department office will provide us with an excel file containing the latest office hours for each professor upon email as early as the 2nd week of each academic quarter.

Key Result

Details

Useful comment with similar code: https://github.com/calpoly-csai/api/pull/53#issuecomment-590121657

what the data looks like

7FE0FD97-60F7-443E-9C1E-5FB79824424D

good points of contact

Jason-Ku commented 4 years ago

The "good points of contact" section is a really great inclusion!

chidiewenike commented 4 years ago

@mfekadu Does this Entity read in a CSV and populate the database as well? Is that what you meant by "make sure that the save_entity function properly saves a new OfficeHour"?

mfekadu commented 4 years ago

@chidiewenike

The latter. save_entity has the job of actually persisting the data in the database.

A separate function to loop over a CSV and call the relevant functions (e.g. insert_entity) may be necessary.

The end goal is we can do the following POST requests

mfekadu commented 4 years ago

@chidiewenike @cameron-toy

Could excalibur be a good manual+automated tool to help us streamline getting new data from PDFs (curricula, office hours if mistakenly provided as PDF, etc)?

Here's a relevant article on table extraction from PDFs

chidiewenike commented 4 years ago

@mfekadu I added the csv to the DB manually and I created a barebones office hours entity class. Is there a way to test it with our DB to ensure that it pulls the information correctly?

mfekadu commented 4 years ago

Awesome, thanks @chidiewenike ! Have you created a pull request yet? Sooner is better than later.

There is an example of a database test here:

@Jason-Ku knows all about it. Jason, do you have any advice for Chidi?

Jason-Ku commented 4 years ago

Yeah! If you want to try and save your data to a test database you could add some code in the database_wrapper.py main method to manually run save_entity. There aren't any unittests to make sure that are you Entity was made correctly yet, (I'll probably work on that tomorrow)

cameron-toy commented 4 years ago

@mfekadu I tried excalibur in the past for a different project and didn't have much luck with it, but success is probably dependent on how the table is represented in the PDF. It's worth a try.

chidiewenike commented 4 years ago

@mfekadu Where should the abstracted save_office_hours function reside? The functions for the other "save_entity" functions reside within the db instantiation of the NimbusMySQLAlchemy class. Example here: https://github.com/calpoly-csai/api/blob/7e24774fccc6f835c59c4b6d3414b79c1ba1fd0b/flask_api.py#L120-L130 At line 129, db.save_course(course) is called for each course. Since this is now universally handled by the insert_entity function, should the code I have for processing the csv be abstracted in another function?

mfekadu commented 4 years ago

@chidiewenike

Feel free to just directly call the insert_entity function because it will work and will be simple/direct.

However, you do bring up a good point that abstracting out a save_office_hours function would offer better readability of the code.

The choice is yours 😄

chidiewenike commented 4 years ago

@mfekadu Where should I store the abstracted out function? Keep it in flask_api.py or database_wrapper.py like the others?