Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Azeirah committed Nov 23, 2024
1 parent bc4df4f commit 63ae3cd
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/remarks.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions deployment/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build-base:
11 changes: 11 additions & 0 deletions deployment/remarks-base/remarks.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM python:3.10-buster

RUN curl -sSL https://install.python-poetry.org | python3 -

RUN ["mkdir", "/app"]
WORKDIR /app

COPY . /app

RUN ["/root/.local/bin/poetry", "install"]
ENTRYPOINT ["/root/.local/bin/poetry", "run", "python", "-m", "remarks"]
6 changes: 6 additions & 0 deletions deployment/remarks-server/remarks-server.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM laauurraaa/remarks-bin:0.3.16

COPY server.py /app/server.py
RUN ["/root/.local/bin/poetry", "run", "pip", "install", "flask"]

ENTRYPOINT ["/root/.local/bin/poetry", "run", "python", "/app/server.py"]
49 changes: 49 additions & 0 deletions deployment/remarks-server/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from flask import Flask, request, jsonify
from remarks import remarks
import os, os.path

default_args = {
"file_name": None,
"ann_type": ["scribbles", "highlights"],
"combined_pdf": True,
"combined_md": True,
"modified_pdf": False,
"md_hl_format": "whole_block",
"md_page_offset": 0,
"md_header_format": "atx",
"per_page_targets": [],
"assume_malformed_pdfs": False,
"avoid_ocr": False,
}

app = Flask("Remarks http server")

@app.post("/process")
def process():
params = request.get_json()

assert 'in_path' in params, "Missing parameter: in_path"
assert 'out_path' in params, "Missing parameter: out_path"

in_path = params['in_path']
out_path = params['out_path']

assert os.path.exists(in_path), f"Path does not exist: {in_path}"
assert os.path.exists(out_path), f"Path does not exist: {out_path}"

print(f"Got a request to process {params['in_path']}")

parent_dir = in_path
for i in range(1):
parent_dir = os.path.dirname(parent_dir)
out_dir = os.path.join(parent_dir, "out")

print(f"Making directory {out_dir}")
os.makedirs(out_dir)

result = remarks.run_remarks(in_path, out_dir, **default_args)

return "OK"


app.run(host="0.0.0.0", port=5000)

0 comments on commit 63ae3cd

Please sign in to comment.