From 524068774c4dbb60a24c7a1033b49f491a32838b Mon Sep 17 00:00:00 2001 From: Oliver Giles Date: Thu, 25 Jan 2024 17:14:21 +0000 Subject: [PATCH 1/8] change output message --- nbresult/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/nbresult/__init__.py b/nbresult/__init__.py index e0a51d6..3fd7069 100644 --- a/nbresult/__init__.py +++ b/nbresult/__init__.py @@ -69,10 +69,7 @@ def check(self): tests_directory = f'{tests_directory}/{self.subdir}' result = f""" {result}\n -💯 You can commit your code:\n -\033[1;32mgit\033[39m add {tests_directory}/{self.name}.pickle\n -\033[32mgit\033[39m commit -m \033[33m'Completed {self.name} step'\033[39m\n -\033[32mgit\033[39m push origin master +💯 You can submit your code through the JupyterLab git GUI! """ return result From 2205cbc108449d807ab42ceceeed6b5a77d04e01 Mon Sep 17 00:00:00 2001 From: Oliver Giles Date: Thu, 22 Feb 2024 18:06:30 +0000 Subject: [PATCH 2/8] Update __init__.py --- nbresult/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nbresult/__init__.py b/nbresult/__init__.py index 3fd7069..fb9d5cb 100644 --- a/nbresult/__init__.py +++ b/nbresult/__init__.py @@ -68,9 +68,9 @@ def check(self): if self.subdir: tests_directory = f'{tests_directory}/{self.subdir}' result = f""" -{result}\n -💯 You can submit your code through the JupyterLab git GUI! -""" + {result}\n + :100: You can now submit your code through the JupyterLab git GUI. Submit by adding, committing and pushing the folder {tests_directory} (including all of its contents)! + """ return result From 4c2ce0293c56c36946c82bc4a69932b450cb4d5a Mon Sep 17 00:00:00 2001 From: Edward Schults Date: Thu, 3 Oct 2024 09:56:02 +0200 Subject: [PATCH 3/8] adapt post check message to context --- nbresult/__init__.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/nbresult/__init__.py b/nbresult/__init__.py index fb9d5cb..f433c28 100644 --- a/nbresult/__init__.py +++ b/nbresult/__init__.py @@ -67,10 +67,21 @@ def check(self): tests_directory = 'tests' if self.subdir: tests_directory = f'{tests_directory}/{self.subdir}' - result = f""" - {result}\n - :100: You can now submit your code through the JupyterLab git GUI. Submit by adding, committing and pushing the folder {tests_directory} (including all of its contents)! - """ + + nbresult_post_check_message = os.getenv('NBRESULT_POST_CHECK_MESSAGE') + if nbresult_post_check_message == 'JUPTERLAB': + result = f""" +{result}\n +:100: You can now submit your code through the JupyterLab git GUI. Submit by adding, committing and pushing the folder {tests_directory} (including all of its contents)! +""" + else: + result = f""" +{result}\n +💯 You can commit your code:\n +\033[1;32mgit\033[39m add {tests_directory}/{self.name}.pickle\n +\033[32mgit\033[39m commit -m \033[33m'Completed {self.name} step'\033[39m\n +\033[32mgit\033[39m push origin master +""" return result From f8e95a326934fe48fc9efab15c52256ac34aced3 Mon Sep 17 00:00:00 2001 From: Edward Schults Date: Thu, 3 Oct 2024 09:56:13 +0200 Subject: [PATCH 4/8] bump to 0.1.1 --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 9454ce2..2c321fe 100644 --- a/setup.py +++ b/setup.py @@ -5,8 +5,8 @@ long_description = fh.read() setup(name='nbresult', - version='0.0.9', - description='Extract results from Jupyter notebooks', + version='0.1.1', + description='Adapt post check message to context.', license="MIT", long_description=long_description, long_description_content_type="text/markdown", From 9eaf81b409f40011de73e1aac9c43412243a62af Mon Sep 17 00:00:00 2001 From: Edward Schults Date: Thu, 3 Oct 2024 09:58:09 +0200 Subject: [PATCH 5/8] fix typo --- nbresult/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nbresult/__init__.py b/nbresult/__init__.py index f433c28..57b35ad 100644 --- a/nbresult/__init__.py +++ b/nbresult/__init__.py @@ -69,7 +69,7 @@ def check(self): tests_directory = f'{tests_directory}/{self.subdir}' nbresult_post_check_message = os.getenv('NBRESULT_POST_CHECK_MESSAGE') - if nbresult_post_check_message == 'JUPTERLAB': + if nbresult_post_check_message == 'JUPYTERLAB': result = f""" {result}\n :100: You can now submit your code through the JupyterLab git GUI. Submit by adding, committing and pushing the folder {tests_directory} (including all of its contents)! From 3476ec3bbbfa03e65d53222711e80a533b235927 Mon Sep 17 00:00:00 2001 From: Edward Schults Date: Thu, 3 Oct 2024 11:34:40 +0200 Subject: [PATCH 6/8] add tests --- tests/test_challenge_result.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/test_challenge_result.py b/tests/test_challenge_result.py index e74441f..0c67f86 100644 --- a/tests/test_challenge_result.py +++ b/tests/test_challenge_result.py @@ -109,3 +109,34 @@ def test_subdir_is_in_the_file_path_to_add(self): result.write() output = result.check() self.assertIn(f'add tests/{subdir}/unicity.pickle', output) + + def test_post_check_message_when_env_not_set(self): + cwd = os.getcwd() + challenge_dir = os.path.join(os.path.dirname(__file__), 'fixtures', 'package_challenge', 'toto') + subdir = 'first_tests' + tests_dir = os.path.join(challenge_dir, 'tests', subdir) + os.chdir(challenge_dir) + result = ChallengeResult('unicity', subdir=subdir, dummy=42) + result.write() + output = result.check() + # Manual tear down + os.chdir(cwd) + os.remove(os.path.join(tests_dir, 'unicity.pickle')) + + self.assertIn(f'You can commit your code', output) + + def test_post_check_message_when_env_set_to_jupyterlab(self): + cwd = os.getcwd() + challenge_dir = os.path.join(os.path.dirname(__file__), 'fixtures', 'package_challenge', 'toto') + subdir = 'first_tests' + tests_dir = os.path.join(challenge_dir, 'tests', subdir) + os.chdir(challenge_dir) + result = ChallengeResult('unicity', subdir=subdir, dummy=42) + result.write() + os.environ['NBRESULT_POST_CHECK_MESSAGE'] = 'JUPYTERLAB' + output = result.check() + # Manual tear down + os.chdir(cwd) + os.remove(os.path.join(tests_dir, 'unicity.pickle')) + os.environ['NBRESULT_POST_CHECK_MESSAGE'] = '' + self.assertIn(f'You can now submit your code through the JupyterLab', output) From e8b0df6e931763b1e6cdf70a140842ac03bac714 Mon Sep 17 00:00:00 2001 From: Edward Schults Date: Thu, 3 Oct 2024 11:42:30 +0200 Subject: [PATCH 7/8] adjust message to be more relevant in the JupyterHub context --- nbresult/__init__.py | 2 +- tests/test_challenge_result.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nbresult/__init__.py b/nbresult/__init__.py index 32d8ac9..9272de9 100644 --- a/nbresult/__init__.py +++ b/nbresult/__init__.py @@ -72,7 +72,7 @@ def check(self): if nbresult_post_check_message == 'JUPYTERLAB': result = f""" {result}\n -:100: You can now submit your code through the JupyterLab git GUI. Submit by adding, committing and pushing the folder {tests_directory} (including all of its contents)! +:100: You can now save your changes and move on to the next challenge. """ else: result = f""" diff --git a/tests/test_challenge_result.py b/tests/test_challenge_result.py index 0c67f86..11600b2 100644 --- a/tests/test_challenge_result.py +++ b/tests/test_challenge_result.py @@ -139,4 +139,4 @@ def test_post_check_message_when_env_set_to_jupyterlab(self): os.chdir(cwd) os.remove(os.path.join(tests_dir, 'unicity.pickle')) os.environ['NBRESULT_POST_CHECK_MESSAGE'] = '' - self.assertIn(f'You can now submit your code through the JupyterLab', output) + self.assertIn(f'You can now save your changes and move on to the next challenge', output) From f3d70669e3e1ab90adb0c958b0321bbd68056795 Mon Sep 17 00:00:00 2001 From: Edward Schults Date: Thu, 3 Oct 2024 13:15:28 +0200 Subject: [PATCH 8/8] restore package description --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 2c321fe..5a68c32 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup(name='nbresult', version='0.1.1', - description='Adapt post check message to context.', + description='Extract results from Jupyter notebooks', license="MIT", long_description=long_description, long_description_content_type="text/markdown",