-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Serval app initial commit * Update app to use Serval creds. * Add footnote about IETF tags, link to swagger for more on language codes * Serval App working MVP compatible with streamlit deployment method * Also now capable of handling paratext projects and multiple files as well as no target file(s). * Make fields configurable and move delete to end of updates * Formatting, gitignore, and poetry
- Loading branch information
Showing
11 changed files
with
5,894 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,3 +42,5 @@ lib/ | |
.vs | ||
appsettings.user.json | ||
artifacts | ||
|
||
.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[flake8] | ||
max-line-length = 120 | ||
per-file-ignores = serval_app.py:F821,W605 | ||
exclude = | ||
serval_client_module.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
### Running the Serval APP | ||
Before running the app, verify that both `SERVAL_APP_EMAIL_PASSWORD` and `SERVAL_APP_PASSCODE` are appropriately populated. | ||
Then, run: | ||
``` | ||
streamlit run serval_app.py | ||
``` | ||
|
||
### Regenerating the Python Client | ||
When the Serval API is updated, download the "swagger.json" from the swagger endpoint and use the tool [swagger-to](https://pypi.org/project/swagger-to/) to generate a new `serval_client_module.py` using the following command in this directory: | ||
``` | ||
swagger_to_py_client.py --swagger_path path/to/swagger.json --outpath serval_client_module.py | ||
``` | ||
Note: You may need to delete the authorization-related elements of the "swagger.json" before generating. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import enum | ||
|
||
from sqlalchemy import Column, Enum, MetaData, String, create_engine | ||
from sqlalchemy.orm import declarative_base | ||
|
||
|
||
class State(enum.Enum): | ||
Pending = 0 | ||
Active = 1 | ||
Completed = 2 | ||
Faulted = 3 | ||
|
||
|
||
metadata = MetaData() | ||
Base = declarative_base(metadata=metadata) | ||
|
||
|
||
class Build(Base): | ||
__tablename__ = "builds" | ||
|
||
__mapper_args__ = {"confirm_deleted_rows": False} | ||
|
||
build_id = Column("build_id", String, primary_key=True) | ||
engine_id = Column("engine_id", String, primary_key=True) | ||
name = Column("name", String) | ||
email = Column("email", String, nullable=False) | ||
state = Column("state", Enum(State), nullable=False) | ||
corpus_id = Column("corpus_id", String, nullable=False) | ||
client_id = Column("client_id", String, nullable=False) | ||
source_files = Column("source_files", String) | ||
target_files = Column("target_files", String) | ||
|
||
def __str__(self): | ||
return f"Build name: {self.name}\nBuild id: {self.build_id}\nClient ID: {self.client_id}\nSource files: \ | ||
{self.source_files}\nTarget files: {self.target_files}" | ||
|
||
def __repr__(self): | ||
return self.__str__() | ||
|
||
|
||
def create_db_if_not_exists(): | ||
engine = create_engine("sqlite:///builds.db") | ||
metadata.create_all(bind=engine) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[tool.poetry] | ||
name = "servalapp" | ||
version = "0.1.0" | ||
description = "" | ||
authors = ["Eli Lowry <[email protected]>"] | ||
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = ">=3.8.1,<3.9.7 || >3.9.7,<4.0" | ||
streamlit = "^1.27.2" | ||
requests = "^2.31.0" | ||
SQLAlchemy = "^2.0.22" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
black = "^23.10.1" | ||
flake8 = "^6.1.0" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" |
Oops, something went wrong.