Skip to content

Commit

Permalink
fixer upper
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebou12 committed Jul 23, 2023
1 parent 1c09964 commit 4db5446
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
5 changes: 0 additions & 5 deletions D2/run_d2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@
import asyncio
import os

current_directory = os.getcwd()
print(f"Current directory: {current_directory}")

# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

async def run_go_script(input_data: str):
try:
print("Running go script")
# Use asyncio's subprocess support to run the Go script
process = await asyncio.create_subprocess_exec(
'./D2/main', 'encode', input_data,
stdout=asyncio.subprocess.PIPE,
Expand Down
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ class DiagramRequest(BaseModel):
lang: str
type: str
code: str
theme: str = None
theme: str = ""

@validator('lang')
def validate_lang(cls, v):
valid_langs = ["plantuml", "mermaid", "mermaidjs" "d2lang", "D2", "d2", "terrastruct", "graphviz"]
valid_langs = ["plantuml", "mermaid", "mermaidjs", "d2lang", "D2", "d2", "terrastruct", "graphviz"]
if v not in valid_langs:
raise ValidationError(f"Invalid diagram language: {v}")
return v
Expand Down
6 changes: 5 additions & 1 deletion test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def test_generate_d2_diagram_endpoint():
"type": "class",
"code": "class Test{}"
})
assert response.json() == {"error": "An error occurred while generating the diagram."}
assert response.status_code == 200
assert "url" in response.json()

Expand Down Expand Up @@ -130,4 +131,7 @@ async def test_run_go_script():
test_input = "test input"

# Call the function with the test input
await run_go_script(test_input)
url, content, playground = await run_go_script(test_input)
assert url is not None
assert content is not None
assert playground is not None

1 comment on commit 4db5446

@vercel
Copy link

@vercel vercel bot commented on 4db5446 Jul 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.