Skip to content

Commit

Permalink
Fix async issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Gregory Bell committed Oct 2, 2023
1 parent a0d5164 commit 041aafa
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
6 changes: 5 additions & 1 deletion Grade/gradesheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ async def convertBartikToGradesheet(_azure: AzureAD, _bartik: Bartik, _students:
continue


missing: bool = False
score: float = 0

try:
score = _bartik.getScoreForAssignment(studentEmail, _assignment)
except Exception:
missing = True
print(f"Missing")

bartikGradesheet = pd.concat([bartikGradesheet, pd.DataFrame(
Expand All @@ -51,9 +53,11 @@ async def convertBartikToGradesheet(_azure: AzureAD, _bartik: Bartik, _students:
}, index=[0]
)], ignore_index=True)

print("Done")
if not missing:
print("Done")


_bartik.closeSession()
return bartikGradesheet


Expand Down
5 changes: 2 additions & 3 deletions UI/bartikGrading.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
from UI import uiHelpers
from Canvas import Canvas
from Grade import gradesheets, score, post
import asyncio
import pandas as pd


def bartikGrading(canvas, azure, bartik, **kwargs) -> bool:
async def bartikGrading(canvas, azure, bartik, **kwargs) -> bool:
uiHelpers.setupAssignments(canvas)

bartikAssignmentsToGrade: dict[int, pd.DataFrame] = {}
Expand All @@ -16,7 +15,7 @@ def bartikGrading(canvas, azure, bartik, **kwargs) -> bool:
print("=" * 4, f"Now grading {row['name']}", "=" * 4)
studioNumber: str = uiHelpers.getUserInput("studio number")

bartikAssignmentsToGrade[row['id']] = asyncio.run(gradesheets.convertBartikToGradesheet(azure, bartik, canvas.getStudents(), studioNumber))
bartikAssignmentsToGrade[row['id']] = await gradesheets.convertBartikToGradesheet(azure, bartik, canvas.getStudents(), studioNumber)


print("\nGrades have been generated. Would you like to continue?")
Expand Down
2 changes: 1 addition & 1 deletion UI/exitGrading.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from sys import exit


def exitGrading(**kwargs):
async def exitGrading(**kwargs):
exit(0)
2 changes: 1 addition & 1 deletion UI/passFail.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd


def passFail(**kwargs) -> bool:
async def passFail(**kwargs) -> bool:
uiHelpers.setupAssignments(kwargs['canvas'])

passFailAssignmentsToGrade: dict[int, pd.DataFrame] = uiHelpers.setupPassFailAssignments(kwargs['canvas'])
Expand Down
2 changes: 1 addition & 1 deletion UI/standardGrading.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd


def standardGrading(**kwargs):
async def standardGrading(**kwargs):
statusAssignments: pd.DataFrame = kwargs['canvas'].getStatusAssignments()
kwargs['canvas'].updateStatusAssignmentScores()
statusAssignmentScores: pd.DataFrame = kwargs['canvas'].getStatusAssignmentScores()
Expand Down
7 changes: 4 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from Canvas import Canvas
import config
from UI.ui import mainMenu
import asyncio

def main():
async def main():
# TODO May want to rework this config loading!
loadedConfig = config.loadConfig()
# TODO Should this be moved to after the action is taken?
Expand All @@ -31,7 +32,7 @@ def main():
bartik = Bartik(loadedConfig["bartik_url"], loadedConfig["bartik_username"], loadedConfig["bartik_password"], loadedConfig['bartik_course'])

operation = mainMenu()
if not operation(canvas=canvas, azure=azure, bartik=bartik, latePenalty=loadedConfig['late_penalties']):
if not await operation(canvas=canvas, azure=azure, bartik=bartik, latePenalty=loadedConfig['late_penalties']):
print("Grading failed.")


Expand All @@ -42,4 +43,4 @@ def main():

if getattr(sys, 'frozen', False):
os.chdir(os.path.dirname(sys.executable))
main()
asyncio.run(main())

0 comments on commit 041aafa

Please sign in to comment.