-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Massive file structure refactor; adding skeleton of FastAPI app #21
base: main
Are you sure you want to change the base?
Conversation
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.
Nice job! I left a few comments for your consideration. Alongside the comments at the file level I also wondered more broadly:
- Would it be possible to write a simple test (maybe using this
fastapi
tutorial as a reference point) which implements the server somehow to make sure it runs before it reaches "production"? Tests are commonly used to make sure an application can run bug-free before users reach it. - I noticed there were many environment files removed which could be important to other parts of the project (such as the front-end, or otherwise). As a double check: did these files present a challenge for the implementation you're suggesting with these changes? If not, I recommend re-including them to help make sure we don't lose capabilities which were already developed (and which could be important for this
fastapi
implementation).
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.
Consider retaining this file to help spell out the license associated with this project. Without this file the project effectively becomes completely private meaning others may not use it without explicit permission.
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.
Consider retaining this file to help spell out how contributions may be made to the project. Without it we risk misunderstandings when it comes to development procedures.
@@ -0,0 +1,11 @@ | |||
from fastapi import APIRouter |
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.
Consider adding a docstring to the top of this file to help describe what it does. This comment applies to other Python modules within this PR which do not contain this pattern as well. It's common practice to provide a docstring at the top of a module to help describe what it does and to build context surrounding the other modules within a project.
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 comment applies to the directory in which this file is found. Consider organizing the source under this directory with a naming convention that follows package_name
or src/package_name
or app
(where "package" in this sense can be understood to mean "a collection of Python modules"). These are common conventions used in many software projects to help indicate where the source code may be found. Since we also have a front-end to organize it might make sense to take the form: src/moss/backend
and src/moss/frontend
or something of this nature. As it stands without additional context one might understand the file organization to mean: "we're building a package called hex".
## Goal | ||
Here is an earlier iteration built using Kumu. We want to build something similar but better. | ||
- [kumu instance](https://embed.kumu.io/6cbeee6faebd8cc57590da7b83c4d457#default) | ||
- [demo video](https://www.youtube.com/watch?v=jZyLSRCba_M) |
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.
Consider somehow saving this information as it may still be useful in the immediate future as we migrate and change capability. I'm not 100% sure about this so it could be that this comment should be dismissed.
@@ -0,0 +1,6 @@ | |||
def get_db_connection(use_async=True): | |||
TEMP_DB_LOC = "dev.db" |
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.
Consider giving this file an extension of .sqlite
to explicitly observe that it is a SQLite database (and not some other database).
@@ -0,0 +1,6 @@ | |||
def get_db_connection(use_async=True): | |||
TEMP_DB_LOC = "dev.db" | |||
ASYNC_TEMP_DATABASE_URL = f"sqlite+aiosqlite:///./{TEMP_DB_LOC}" |
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 wasn't sure if the SQLite additions here were truly temporary or if they'd become the basis for later work. If it's more realistic that his might remain, consider assessing the performance constraints of SQLite in context with the size of the data involved for the project. I'd recommend DuckDB as one possible alternative with many similarities to SQLite and nice OLAP features which could compliment the project well.
@@ -0,0 +1,103 @@ | |||
from fastapi import APIRouter, Depends, HTTPException |
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.
Consider ensuring that fastapi
is a part of the environment as a dependency which is declared somewhere (for example, in the pyproject.toml
file).
This can be done by running the following command: | ||
|
||
python3 main.py |
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.
Consider adding this information to the readme or other documentation to help inform developers on how to run this. This could help someone who doesn't know which file to look at in order to start the app.
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.
Consider keeping this file which looks to be part of mkdocs (likely used to help build documentation materials).
return db_transaction | ||
""" | ||
harvest = harvest.model_dump() | ||
harvest["id"] = int(100*random()) |
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.
Consider using UUID:
`import uuid
myuuid = uuid.uuid4()`
I recommend adding some basic documentation for the API, example:
|
Based on ideas here: https://docs.google.com/presentation/d/1jE0-VBikgAd-E6XSRTEkt_RxI190uVlsWg11fB6YgXw/edit?usp=sharing