Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
ee0dfd7
added illumidesk secret option
Abhi94N Mar 22, 2022
32db3a5
initialization of secrets manager
Abhi94N Mar 25, 2022
070ca4f
updated graderservice to add restart grader functionality
Abhi94N Mar 25, 2022
4554626
updated route to restart grader
Abhi94N Mar 25, 2022
2ad280f
added response code for route
Abhi94N Mar 25, 2022
938df6a
updated formgrader secretsmanager version to a valid one
Abhi94N Mar 25, 2022
b8944e5
graderservice restart grader timeout 10 seconds
Abhi94N Mar 26, 2022
48a6467
grader service sleep changed
Abhi94N Mar 29, 2022
7ac98ac
updated to jupyterhub ltiauthenticator
Abhi94N Mar 29, 2022
abe0606
updated jinja2 and markupsafe version
Abhi94N Mar 29, 2022
47bf382
remove markup package
Abhi94N Mar 29, 2022
089e1c3
set jinja version to 3.0.3
Abhi94N Mar 29, 2022
508d95d
removed markup safe
Abhi94N Mar 29, 2022
28d73e9
updated jinja2 and packages dependent on jinja2
Abhi94N Mar 29, 2022
96390e1
fixed jinja version
Abhi94N Mar 29, 2022
6a7c7a1
update jedi version
Abhi94N Mar 29, 2022
5bfdada
jinja 3.1.1
Abhi94N Mar 29, 2022
0216198
oauthlib 3.1.1
Abhi94N Mar 29, 2022
40f79ca
revert jinja2 to 3.0.3
Abhi94N Mar 29, 2022
980b972
updated flask to version 2.1.0
Abhi94N Mar 29, 2022
cee4464
revert flask version
Abhi94N Mar 29, 2022
e2aceec
flask version 1.1.1
Abhi94N Mar 29, 2022
db33df4
update requirements
Abhi94N Mar 29, 2022
784dd48
update requirements
Abhi94N Mar 29, 2022
5d3a3f4
update test location in makefile
Abhi94N Mar 29, 2022
8a4c151
removed asyncnbgrader test
Abhi94N Apr 1, 2022
972352e
add async_test back
Abhi94N Apr 3, 2022
98d951e
update markup safe
Abhi94N Apr 12, 2022
29cb562
update jinja2 version
Abhi94N Apr 12, 2022
fb09de6
updated flask to version 2.1.0
Abhi94N Apr 12, 2022
0405223
updated jinja2
Abhi94N Apr 12, 2022
e2fb9a7
update jinja2 for async_nbgrader
Abhi94N Apr 12, 2022
92db213
updated jinja2 to semver 2.10>=jinja2<3.1.0
Abhi94N Apr 12, 2022
56d5cbb
updated nbconvert version
Abhi94N Apr 12, 2022
9e6533a
jinja2 version downgrade to 3.1.0
Abhi94N Apr 12, 2022
7ba436a
updated flask to 2.1.0
Abhi94N Apr 12, 2022
13d4ad2
revert nbconvert
Abhi94N Apr 12, 2022
c365961
update werkzeug
Abhi94N Apr 12, 2022
a4691ea
update jinja2 to the latest version
Abhi94N Apr 12, 2022
a533e56
jinja 3.1
Abhi94N Apr 12, 2022
08463b3
nbconvert version 6.4.3
Abhi94N Apr 12, 2022
9da1fb6
reverted requirements txt
Abhi94N Apr 12, 2022
7c53d06
updates ltiauthenticator to use pypi version
Abhi94N Apr 12, 2022
83856ec
matched kubernetes version
Abhi94N Apr 12, 2022
b336d3f
update requirements.txt
Abhi94N Apr 12, 2022
819dbb7
updated graderservice.py
Abhi94N Apr 14, 2022
6390775
update jinja2 version to 3.1.0
Abhi94N Apr 15, 2022
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 src/async_nbgrader/dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ sphinx-autodoc-typehints
nbval
requests-mock
wheel

4 changes: 2 additions & 2 deletions src/formgradernext/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ipywidgets==7.6.5
# via jupyter
jedi==0.18.0
# via ipython
jinja2==3.0.2
jinja2==3.1.0
# via
# nbconvert
# notebook
Expand Down Expand Up @@ -214,4 +214,4 @@ widgetsnbextension==3.5.2
# via ipywidgets

# The following packages are considered to be unsafe in a requirements file:
# setuptools
# setuptools
36 changes: 35 additions & 1 deletion src/graderservice/graderservice/graderservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
from os import path
from pathlib import Path
from secrets import token_hex

from kubernetes import client
from kubernetes import config
from kubernetes.config import ConfigException
from kubernetes.client.rest import ApiException
import time

from .templates import NBGRADER_COURSE_CONFIG_TEMPLATE
from .templates import NBGRADER_HOME_CONFIG_TEMPLATE
Expand Down Expand Up @@ -61,6 +62,7 @@
nbgrader_db_name = os.environ.get("POSTGRES_NBGRADER_DB_NAME")



class GraderServiceLauncher:
def __init__(self, org_name: str, course_id: str):
"""
Expand Down Expand Up @@ -358,3 +360,35 @@ def update_jhub_deployment(self):
name="hub", namespace=NAMESPACE, body=deployment
)
logger.info(f"Jhub patch response:{api_response}")

# Restarts deployment in namespace
def restart_deployment(self, deployment, namespace):
now = datetime.utcnow()
now = str(now.isoformat("T") + "Z")
body = {
'spec': {
'template': {
'metadata': {
'annotations': {
'kubectl.kubernetes.io/restartedAt': now
}
}
}
}
}
deployment_status = f'{deployment} failed to deploy to organization: {namespace}', 404
try:
restart_deployment = self.apps_v1.patch_namespaced_deployment(deployment, namespace, body, pretty='true')
except ApiException as e:
logger.error("Exception when calling AppsV1Api->read_namespaced_deployment_status: %s\n" % e)
except Exception as e:
logger.error(deployment_status, e)
else:
while restart_deployment.status.updated_replicas != restart_deployment.spec.replicas:
logger.info(f'Waiting for status to update for grader{deployment} to organization {namespace}')
time.sleep(5)
deployment_status = f'{deployment} successfully deployed to organization {namespace}', 200
return deployment_status



18 changes: 18 additions & 0 deletions src/graderservice/graderservice/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,24 @@ def assignment_dir_creation(org_name: str, course_id: str, assignment_name: str)
success=True,
message=f"Created new assignment directory: {assignment_dir}",
)
@grader_setup_bp.route(
"/services/<org_name>/<course_id>/restart", methods=["POST"]
)
def restart_grader(org_name: str, course_id: str):
launcher = GraderServiceLauncher(org_name=org_name, course_id=course_id)
try:
restart_deployment_status = launcher.restart_deployment(f'grader-{course_id}',org_name)
except Exception as e:
logger.error(f"Error restarting grader: {e}")

logger.info(restart_deployment_status)
success = True if restart_deployment_status[1]==200 else False
return jsonify(
success=success,
message=f"{restart_deployment_status[0]}"
), restart_deployment_status[1]




@grader_setup_bp.route("/healthcheck")
Expand Down
8 changes: 4 additions & 4 deletions src/graderservice/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ idna==2.10
# via requests
itsdangerous==2.0.0
# via flask
jinja2==3.0.0
jinja2==3.1.0
# via flask
kubernetes==12.0.1
kubernetes==17.17.0
# via graderservice (src/graderservice/setup.py)
markupsafe==2.0.0
# via jinja2
Expand Down Expand Up @@ -70,8 +70,8 @@ urllib3==1.26.5
# requests
websocket-client==0.59.0
# via kubernetes
werkzeug==2.0.0
werkzeug==2.0.2
# via flask

# The following packages are considered to be unsafe in a requirements file:
# setuptools
# setuptools
2 changes: 1 addition & 1 deletion src/graderservice/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"flask==1.1.2",
"flask-sqlalchemy==2.5.1",
"gunicorn==20.0.4",
"kubernetes==12.0.1",
"kubernetes==17.17.0",
], # noqa: E231
package_data={
"": ["*.html"],
Expand Down
6 changes: 3 additions & 3 deletions src/illumidesk/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ipython-genutils==0.2.0 # via nbformat, notebook, qtconsole, traitlets
ipython==7.23.1 # via ipykernel, ipywidgets, jupyter-console
ipywidgets==7.6.3 # via jupyter
jedi==0.18.0 # via ipython
jinja2==3.0.0 # via jupyterhub, jupyterhub-kubespawner, nbconvert, notebook
jinja2==3.1.0 # via jupyterhub, jupyterhub-kubespawner, nbconvert, notebook
josepy==1.4.0 # via illumidesk (setup.py)
jsonschema==3.2.0 # via jupyter-telemetry, nbformat, nbgrader
jupyter-client==6.1.12 # via ipykernel, jupyter-console, nbgrader, notebook, qtconsole
Expand All @@ -37,7 +37,7 @@ jupyter-core==4.7.1 # via jupyter-client, nbconvert, nbformat, nbgrader, n
jupyter-telemetry==0.1.0 # via jupyterhub
jupyter==1.0.0 # via nbgrader
jupyterhub-kubespawner==0.14.1 # via illumidesk (setup.py)
git+git://github.com/jupyterhub/ltiauthenticator.git@71d86a9da2562df4bdcc9f374af834a172ac52d5 # via illumidesk (setup.py)
jupyterhub-ltiauthenticator==1.3.0 # via illumidesk (setup.py)
jupyterhub==1.4.1 # via jupyterhub-kubespawner, jupyterhub-ltiauthenticator, oauthenticator
jupyterlab-widgets==1.0.0 # via ipywidgets
jwcrypto==0.8 # via illumidesk (setup.py)
Expand Down Expand Up @@ -104,4 +104,4 @@ websocket-client==0.59.0 # via kubernetes
widgetsnbextension==3.5.1 # via ipywidgets

# The following packages are considered to be unsafe in a requirements file:
# setuptools
# setuptools
2 changes: 1 addition & 1 deletion src/illumidesk/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
install_requires=[
"josepy==1.4.0",
"jupyterhub-kubespawner==0.14.1",
"jupyterhub-ltiauthenticator@git+git://github.com/jupyterhub/ltiauthenticator.git@71d86a9da2562df4bdcc9f374af834a172ac52d5",
"jupyterhub-ltiauthenticator==1.3.0",
"jwcrypto==0.8",
"nbgrader==0.6.2",
"oauthlib==3.1",
Expand Down