Skip to content

Commit

Permalink
Merge pull request #125 from edina/26_python_3.11
Browse files Browse the repository at this point in the history
Update to python 3.11
  • Loading branch information
alasdair-macleod authored May 17, 2023
2 parents 26515f9 + c7603f9 commit 83190f1
Show file tree
Hide file tree
Showing 44 changed files with 81 additions and 120 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/linted.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
# Technically covered by pre-commit - but here as a "double-check" catcher.

name: Linted

Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, "3.10"]
python-version: [3.8, 3.9, "3.10", "3.11"]
steps:
- uses: actions/checkout@master
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
# - name: Install alembic
# run: |
# python -m pip install alembic
- name: Install nbexchange
run: |
python -m pip install .[test]
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@

repos:
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.3.0
hooks:
- id: black
language_version: python3
- repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,22 @@ Github does a pretty good job testing nbexchange and Pull Requests, but it may m

## Developing nbexchange

Whilst nbexchange can run under python>3.7, the developers of the system currently run under 3.11.

We suggest you set up an appropriate virtual environment.

To setup nbexchange for development, run:

```bash
pip install .[test]
```

or
```bash
pip install .[test]
```
if zsh or similar

When writing code, please don't rely on _code is its own documentation_ - particularly if you're doing anything remotely complicated.
A simple comment at the top is useful for future developers to know _why_ the code is doing something.

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.10
FROM python:3.11.0

ARG COMMIT=""
LABEL commit=${COMMIT}
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Following the lead of other Jupyter services, it is a `tornado` application.

## Compatibility

This version is compatible with `nbgrader` >= 0.6.2
This version installs `nbgrader` 0.8.2 (which makes it compatible with JupyterLab too)

# Documentation

Expand Down Expand Up @@ -106,7 +106,7 @@ Installing nbexchange will also install nbgrader.
nbexchange is not released to Pypy or anaconda, however you can install direct from GitHub - eg:

```
pip install https://github.com/edina/nbexchange/archive/v1.2.9.tar.gz
pip install https://github.com/edina/nbexchange/archive/v1.3.0.tar.gz
jupyter nbextension install --sys-prefix --py nbgrader
jupyter nbextension enable --sys-prefix validate_assignment/main --section=tree
Expand All @@ -116,6 +116,7 @@ jupyter serverextension enable --sys-prefix nbgrader.server_extensions.assignmen
....
```

Note that the jupyter *lab* extensions are installed and enabled automatically - you may wish to switch *off* `formgrader` and `create_assignment` for non-teachers: YMMV

# Configuration

Expand All @@ -137,7 +138,7 @@ class MyUserHandler(BaseUserHandler):

def get_current_user(self, request):
return {
"name": "myname",
"name": "username",
"full_name": "Joe Bloggs",
"course_id": "cool_course_id",
"course_title": "cool course",
Expand Down
3 changes: 0 additions & 3 deletions nbexchange/alembic/versions/20190402_add_collected_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ class OldAssignmentActions(Enum):


def upgrade():

with op.batch_alter_table("action") as batch_op:

batch_op.alter_column(
"action",
"action",
Expand All @@ -45,7 +43,6 @@ def upgrade():


def downgrade():

with op.batch_alter_table("action") as batch_op:
batch_op.alter_column(
"action",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ class OldAssignmentActions(Enum):


def upgrade():

connection = op.get_bind()

if connection.dialect.name == "postgresql":

# This commit is required because postgres can't alter type during a transaction
# Alembic runs these by default in a transaction so will fail without it
# https://stackoverflow.com/questions/14845203/altering-an-enum-field-using-alembic
Expand All @@ -49,9 +47,7 @@ def upgrade():
op.execute("ALTER TYPE assignmentactions ADD VALUE IF NOT EXISTS 'feedback_fetched'")

else:

with op.batch_alter_table("action") as batch_op:

batch_op.alter_column(
"action",
"action",
Expand All @@ -61,7 +57,6 @@ def upgrade():


def downgrade():

connection = op.get_bind()

if connection.dialect.name == "postgresql":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class AssignmentActions(Enum):


def upgrade():

# Users.
# Need to be separated by some kind of organisational ID
op.create_table(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


def upgrade():

with op.batch_alter_table("assignment") as batch_op:
batch_op.alter_column(
"assignment_code",
Expand All @@ -27,7 +26,6 @@ def upgrade():


def downgrade():

with op.batch_alter_table("assignment") as batch_op:
batch_op.alter_column(
"assignment_code",
Expand Down
4 changes: 0 additions & 4 deletions nbexchange/handlers/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class Assignments(BaseHandler):

@authenticated
def get(self):

models = []

[course_code] = self.get_params(["course_id"])
Expand Down Expand Up @@ -135,7 +134,6 @@ class Assignment(BaseHandler):

@authenticated
def get(self): # def get(self, course_code, assignment_code=None):

[course_code, assignment_code] = self.get_params(["course_id", "assignment_id"])

if not (course_code and assignment_code):
Expand Down Expand Up @@ -228,7 +226,6 @@ def get(self): # def get(self, course_code, assignment_code=None):
# This is releasing an **assignment**, not a student submission
@authenticated
def post(self):

# Do a content-length check, before we go any further
if "Content-Length" in self.request.headers and int(self.request.headers["Content-Length"]) > int(
self.max_buffer_size
Expand Down Expand Up @@ -376,7 +373,6 @@ def post(self):
# This is unreleasing an assignment
@authenticated
def delete(self):

[course_code, assignment_code, purge] = self.get_params(["course_id", "assignment_id", "purge"])

self.log.debug(
Expand Down
2 changes: 0 additions & 2 deletions nbexchange/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def get_current_user(self):

@property
def nbex_user(self):

hub_user = self.get_current_user()
hub_username = hub_user.get("name")

Expand Down Expand Up @@ -128,7 +127,6 @@ def param_decode(self, value):
return value

def get_params(self, param_list):

return_params = []

for param in param_list:
Expand Down
2 changes: 0 additions & 2 deletions nbexchange/handlers/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class Collections(BaseHandler):

@authenticated
def get(self):

models = []

[course_code, assignment_code, user_id] = self.get_params(["course_id", "assignment_id", "user_id"])
Expand Down Expand Up @@ -132,7 +131,6 @@ class Collection(BaseHandler):

@authenticated
def get(self):

[course_code, assignment_code, path] = self.get_params(["course_id", "assignment_id", "path"])

if not (course_code and assignment_code and path):
Expand Down
9 changes: 6 additions & 3 deletions nbexchange/handlers/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class FeedbackHandler(BaseHandler):
# Fetch feedback
@authenticated
def get(self):

[course_id, assignment_id] = self.get_params(["course_id", "assignment_id"])

if not assignment_id or not course_id:
Expand All @@ -53,7 +52,6 @@ def get(self):
this_user = self.nbex_user

with scoped_session() as session:

course = Course.find_by_code(db=session, code=course_id, org_id=this_user["org_id"], log=self.log)
if not course:
note = f"Course {course_id} not found"
Expand Down Expand Up @@ -95,6 +93,9 @@ def get(self):
feedbacks.append(f)

# Add action
self.log.info(
f"Adding action {AssignmentActions.feedback_fetched.value} by user {this_user['id']} against assignment {assignment.id}" # noqa: E501
)
action = Action(
user_id=this_user["id"],
assignment_id=assignment.id,
Expand Down Expand Up @@ -148,7 +149,6 @@ def post(self):
return

with scoped_session() as session:

# Start building feedback object

course = Course.find_by_code(db=session, code=course_id, org_id=this_user["org_id"], log=self.log)
Expand Down Expand Up @@ -263,6 +263,9 @@ def post(self):
session.add(feedback)

# Add action
self.log.info(
f"Adding action {AssignmentActions.feedback_released.value} by user {this_user['id']}, for student {student.id}, against assignment {assignment.id}" # noqa: E501
)
action = Action(
user_id=this_user["id"],
assignment_id=notebook.assignment.id,
Expand Down
1 change: 0 additions & 1 deletion nbexchange/handlers/submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def get(self):
# This is a student submitting an assignment, not an instructor "release"
@authenticated
def post(self):

if "Content-Length" in self.request.headers and int(self.request.headers["Content-Length"]) > int(
self.max_buffer_size
):
Expand Down
1 change: 0 additions & 1 deletion nbexchange/models/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class Feedback(Base):

__tablename__ = "feedback_2"

#: Unique id of the feedback (automatically incremented)
Expand Down
1 change: 0 additions & 1 deletion nbexchange/models/notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Notebook(Base):

__tablename__ = "notebook"
__table_args__ = (UniqueConstraint("name", "assignment_id"),)

Expand Down
1 change: 0 additions & 1 deletion nbexchange/plugin/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def do_collect(self):
)

for submission in submissions:

student_id = submission["student_id"]
full_name = submission.get("full_name") or ""
if " " in full_name:
Expand Down
2 changes: 0 additions & 2 deletions nbexchange/plugin/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class Exchange(abc.Exchange):

path_includes_course = Bool(
False,
help="""
Expand Down Expand Up @@ -47,7 +46,6 @@ def fail(self, msg):
raise ExchangeError(msg)

def api_request(self, path, method="GET", *args, **kwargs):

jwt_token = os.environ.get("NAAS_JWT")

cookies = dict()
Expand Down
2 changes: 0 additions & 2 deletions nbexchange/plugin/fetch_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class ExchangeFetchFeedback(abc.ExchangeFetchFeedback, Exchange):

# where the downloaded files are placed
def init_src(self):
if self.coursedir.course_id == "":
Expand Down Expand Up @@ -57,7 +56,6 @@ def download(self):
self.fail(content.get("note", "could not get feedback"))

def copy_files(self):

self.log.debug(f"Destination: {self.dest_path}")
self.download()
self.log.debug(f"Fetched as: {self.coursedir.notebook_id}")
Loading

0 comments on commit 83190f1

Please sign in to comment.