Skip to content

Commit

Permalink
Automated push for workflow: [Lint/#&]
Browse files Browse the repository at this point in the history
  • Loading branch information
Minion3665 committed Aug 15, 2022
1 parent a564adf commit 45a9d20
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
20 changes: 10 additions & 10 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from app.main import app

pretty_errors.configure(
separator_character = '*',
filename_display = pretty_errors.FILENAME_EXTENDED,
line_number_first = True,
display_link = True,
lines_before = 5,
lines_after = 2,
line_color = pretty_errors.RED + '> ' + pretty_errors.default_config.line_color,
code_color = ' ' + pretty_errors.default_config.line_color,
truncate_code = True,
display_locals = True
separator_character='*',
filename_display=pretty_errors.FILENAME_EXTENDED,
line_number_first=True,
display_link=True,
lines_before=5,
lines_after=2,
line_color=pretty_errors.RED + '> ' + pretty_errors.default_config.line_color,
code_color=' ' + pretty_errors.default_config.line_color,
truncate_code=True,
display_locals=True
)
pretty_errors.blacklist('c:/python')
2 changes: 1 addition & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pydantic import BaseSettings
from pathlib import Path


class Settings(BaseSettings):

output_file_path: Path = Path("logs.txt")
Expand All @@ -25,4 +26,3 @@ class Settings(BaseSettings):
config = Settings()
if config.on_brain is True:
config.robot_env["PYTHONPATH"] = config.robot_path

4 changes: 3 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
app.include_router(routers.runner_router)
app.include_router(routers.upload_router)


@app.get("/")
def root():
return "Root of shepherd-2"


@app.on_event("shutdown")
def shutdown_event():
"""Make sure that we kill any running usercode
Expand All @@ -27,4 +29,4 @@ def shutdown_event():


if __name__ == '__main__':
uvicorn.run(app, port=8080, host='0.0.0.0')
uvicorn.run(app, port=8080, host='0.0.0.0')
1 change: 0 additions & 1 deletion app/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,3 @@ def upload_file(file: UploadFile):
"filename": file.filename,
"filesize": len(file)
}

3 changes: 2 additions & 1 deletion app/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _enter_ready_state(self) -> None:

def _enter_running_state(self) -> None:
"""Send start signal to usercode"""
pass # TODO:
pass # TODO:

def _enter_stopped_state(self) -> None:
"""Reap the users code"""
Expand Down Expand Up @@ -135,4 +135,5 @@ def _run_watchdog(self) -> None:
self.next_state = States.STOPPED
self.new_state_event.set()


runner = Runner()
3 changes: 3 additions & 0 deletions test/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

client = TestClient(app)


@pytest.mark.timeout(STATE_TRANS_TIMEOUT)
def test_inital_state():
"""The server is ready to run code within STATE_TRANS_TIMEOUT seconds of starting"""
while (response := client.get("/state")).json() != "Ready":
pass
assert response.status_code == 200


@pytest.mark.timeout(STATE_TRANS_TIMEOUT)
def test_start():
"""Code can be started"""
Expand All @@ -22,6 +24,7 @@ def test_start():
pass
assert response.status_code == 200


@pytest.mark.timeout(STATE_TRANS_TIMEOUT)
def test_stop():
"""Code can be stopped within STATE_TRANS_TIMEOUT seconds of it commanding to be stopped"""
Expand Down

0 comments on commit 45a9d20

Please sign in to comment.