Skip to content

Commit

Permalink
add logs, fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam-D-Lewis committed Apr 21, 2023
1 parent b5816b5 commit 4b3bd87
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ dmypy.json

# Pyre type checker
.pyre/

# vscode
.vscode/
35 changes: 35 additions & 0 deletions nebari_workflow_controller/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import logging.config

LOGGING_CONFIG = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"standard": {"format": "%(asctime)s [%(levelname)s] %(name)s: %(message)s"},
},
"handlers": {
"default": {
"level": "INFO",
"formatter": "standard",
"class": "logging.StreamHandler",
"stream": "ext://sys.stdout", # Default is stderr
},
},
"loggers": {
"": { # root logger
"handlers": ["default"],
"level": "WARNING",
"propagate": False,
},
"nebari_workflow_controller": {
"handlers": ["default"],
"level": "INFO",
"propagate": False,
},
"__main__": { # if __name__ == '__main__'
"handlers": ["default"],
"level": "DEBUG",
"propagate": False,
},
},
}
logging.config.dictConfig(LOGGING_CONFIG)
1 change: 1 addition & 0 deletions nebari_workflow_controller/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


def main():
logger.info("Starting nebari_workflow_controller")
uvicorn.run(
"nebari_workflow_controller.app:app",
host="0.0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion nebari_workflow_controller/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def base_return_response(allowed, apiVersion, request_uid, message=None):
},
}
if not allowed:
response["status"] = {"message": message}
response["response"]["status"] = {"message": message}
return response


Expand Down
2 changes: 2 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ def test_admission_controller(mocker, request_file, allowed):
response = admission_controller(request)
print(response)
assert response["response"]["allowed"] == allowed
if not allowed:
assert response["response"]["status"]["message"]

0 comments on commit 4b3bd87

Please sign in to comment.