Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect notbook_id returned by assignment list #24 #25

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 1 addition & 3 deletions ngshare_exchange/course_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import argparse
from urllib.parse import quote


# https://www.geeksforgeeks.org/print-colors-python-terminal/
def prRed(skk, exit=True):
print('\033[91m {}\033[00m'.format(skk))
Expand Down Expand Up @@ -83,7 +84,6 @@ def check_status_code(response):


def check_message(response):

response = response.json()
if not response['success']:
prRed(response['message'])
Expand Down Expand Up @@ -460,12 +460,10 @@ def parse_args(argv):


def main(argv=None):

argv = argv or sys.argv[1:]
args = parse_args(argv)
args.func(args)


if __name__ == '__main__':

sys.exit(main())
4 changes: 1 addition & 3 deletions ngshare_exchange/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@


class Exchange(ABCExchange):

username = (
os.environ['JUPYTERHUB_USER']
if 'JUPYTERHUB_USER' in os.environ
Expand All @@ -38,7 +37,6 @@ class Exchange(ABCExchange):

@property
def ngshare_url(self):

if self._ngshare_url:
return self._ngshare_url
if 'PROXY_PUBLIC_SERVICE_HOST' in os.environ:
Expand Down Expand Up @@ -189,7 +187,7 @@ def decode_dir(self, src_dir, dest_dir, ignore=None, noclobber=False):

def encode_dir(self, src_dir, ignore=None):
encoded_files = []
for (subdir, dirs, files) in os.walk(src_dir):
for subdir, dirs, files in os.walk(src_dir):
for file_name in files:
file_path = subdir + os.sep + file_name
data_bytes = open(file_path, 'rb').read()
Expand Down
7 changes: 1 addition & 6 deletions ngshare_exchange/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def nb_key(nb):

info['notebooks'] = []
for notebook in notebooks:
if self.cached:
if self.cached or info['status'] == 'fetched':
nb_info = {
'notebook_id': os.path.splitext(
os.path.split(notebook)[1]
Expand All @@ -392,11 +392,6 @@ def nb_key(nb):
}
elif self.inbound:
nb_info = {'notebook_id': notebook['notebook_id']}
elif info['status'] == 'fetched':
nb_info = {
'notebook_id': notebook,
'path': os.path.abspath(notebook),
}
else:
nb_info = {'notebook_id': notebook}
if info['status'] != 'submitted':
Expand Down
2 changes: 0 additions & 2 deletions ngshare_exchange/release_assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class ExchangeReleaseAssignment(Exchange, ABCExchangeReleaseAssignment):

force = Bool(
False, help='Force overwrite existing files in the exchange.'
).tag(config=True)
Expand Down Expand Up @@ -44,7 +43,6 @@ def init_src(self):
self.coursedir.assignment_id,
)
if os.path.isdir(source):

# Looks like the instructor forgot to assign
self.fail(
'Assignment found in "{}" but not "{}", run `nbgrader generate_assignment` first.'.format(
Expand Down
4 changes: 0 additions & 4 deletions ngshare_exchange/tests/test_fetch_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class TestExchangeFetchFeedback(TestExchange):

timestamp = 'some_timestamp'

def _mock_bad_feedback(self):
Expand Down Expand Up @@ -70,7 +69,6 @@ def _new_fetch_feedback(
assignment_id=TestExchange.assignment_id,
student_id=TestExchange.student_id,
):

retvalue = self._new_exchange_object(
ExchangeFetchFeedback, course_id, assignment_id, student_id
)
Expand Down Expand Up @@ -122,7 +120,6 @@ def test_no_course_id(self):
assert issubclass(type(e), ExchangeError)

def test_fetch(self):

# set chache folder

submission_name = '{}+{}+{}'.format(
Expand Down Expand Up @@ -150,7 +147,6 @@ def test_fetch(self):
assert actual_file.read() == reference_file.read()

def test_fetch_path_includes_course(self):

# set chache folder

submission_name = '{}+{}+{}'.format(
Expand Down
Loading
Loading