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

Massive file structure refactor; adding skeleton of FastAPI app #21

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

samuel-schwartz
Copy link
Collaborator

Copy link
Collaborator

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

Copy link
Collaborator

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.

Copy link
Collaborator

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

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.

Copy link
Collaborator

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".

Comment on lines -14 to -17
## 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)
Copy link
Collaborator

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

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

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

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).

Comment on lines +6 to +8
This can be done by running the following command:

python3 main.py
Copy link
Collaborator

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.

Copy link
Collaborator

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())
Copy link
Collaborator

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()`

@gpavlov2016
Copy link
Collaborator

I recommend adding some basic documentation for the API, example:

/harvest

Input Parameters:

  • repository name (str): Name of the repository to be registered.
  • submitter (str): Name or identifier of the person submitting the repository.

Output Parameters:

  • status (enum): Represents the status of the process. Possible values:
    • in progress
    • finished

Description:
Registers a code repository or a paper for ingestion (bottling).

Processing Steps:

  1. Step 1: (Add step details here)
  2. Step 2: (Add step details here)
  3. ... (Continue listing any additional steps)

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.

3 participants