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

markdown to html benchmark #312

Merged
merged 6 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions benchmarks/markdown_to_html/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.caribou/deployment-packages/
Empty file.
44 changes: 44 additions & 0 deletions benchmarks/markdown_to_html/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from typing import Any
import markdown
import base64
import boto3
import json
from tempfile import TemporaryDirectory
from caribou.deployment.client import CaribouWorkflow

s3_bucket_name = "caribou-markdown-to-html"
s3_bucket_region_name = "us-east-1"

workflow = CaribouWorkflow(name="markdown_to_html", version="0.0.1")

@workflow.serverless_function(
name="markdown_to_html",
entry_point=True,
)
def markdown_to_html(event: dict[str, Any]) -> dict[str, Any]:

if isinstance(event, str):
event = json.loads(event)

if "filename" in event:
filename = event["filename"]
else:
raise ValueError("No filename provided")

s3 = boto3.client("s3", region_name=s3_bucket_region_name)

with TemporaryDirectory() as tmp_dir:
s3.download_file(s3_bucket_name, filename, f"{tmp_dir}/{filename}")

with open(f"{tmp_dir}/{filename}", "r") as f:
markdown_text = f.read()

decoded_text = base64.b64decode(markdown_text).decode()
html_text = markdown.markdown(decoded_text)

with open(f"{tmp_dir}/{filename}.html", "w") as f:
f.write(html_text)

s3.upload_file(f"{tmp_dir}/{filename}.html", s3_bucket_name, f"output/{filename}.html")

return {"status": 200}
6 changes: 6 additions & 0 deletions benchmarks/markdown_to_html/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
markdown
boto3==1.35.3

pyyaml==6.0.2

vGsteiger marked this conversation as resolved.
Show resolved Hide resolved
pytz==2024.1
Empty file.
Empty file.