From b025818248533fe77b127ea99b99c121b861bd7e Mon Sep 17 00:00:00 2001 From: Omer Bhatti Date: Wed, 11 Sep 2024 13:05:05 +0500 Subject: [PATCH 1/6] chore: Drop Python 3.8 support --- .github/workflows/ci.yml | 1 - .github/workflows/pypi-publish.yml | 2 +- setup.py | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 27c15a3..7628cba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,6 @@ jobs: strategy: matrix: python-version: - - '3.8' - '3.11' TOX_ENV: - csslint diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index a8e10c3..142b77d 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -15,7 +15,7 @@ jobs: - name: setup python uses: actions/setup-python@v3 with: - python-version: 3.8 + python-version: 3.11 - name: Install pip run: pip install -r requirements/pip.txt diff --git a/setup.py b/setup.py index 423c267..493bc77 100644 --- a/setup.py +++ b/setup.py @@ -154,7 +154,6 @@ def is_requirement(line): 'License :: OSI Approved :: Apache Software License', 'Natural Language :: English', "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.11", ] ) From 40e7b84fdb8cf5e7015a26dd0419dfd531253c94 Mon Sep 17 00:00:00 2001 From: Omer Bhatti Date: Wed, 11 Sep 2024 13:07:21 +0500 Subject: [PATCH 2/6] chore: Updating Python Requirements --- requirements/base.txt | 28 +++++++----------- requirements/ci.txt | 23 ++++++--------- requirements/pip.txt | 8 +++--- requirements/pip_tools.txt | 21 ++++---------- requirements/quality.txt | 59 +++++++++++++++++--------------------- requirements/test.txt | 16 ++++++----- requirements/tox.txt | 22 ++++++-------- 7 files changed, 73 insertions(+), 104 deletions(-) diff --git a/requirements/base.txt b/requirements/base.txt index 941d264..f4e8504 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # make upgrade @@ -8,21 +8,17 @@ appdirs==1.4.4 # via fs asgiref==3.8.1 # via django -backports-zoneinfo==0.2.1 ; python_version < "3.9" - # via - # -c requirements/constraints.txt - # django -django==4.2.11 +django==4.2.16 # via # -c requirements/common_constraints.txt # -r requirements/base.in -edx-codejail==3.3.3 +edx-codejail==3.4.1 # via -r requirements/base.in fs==2.4.16 # via xblock -lxml==5.2.1 +lxml==5.3.0 # via xblock -mako==1.3.2 +mako==1.3.5 # via xblock markupsafe==2.1.5 # via @@ -30,26 +26,24 @@ markupsafe==2.1.5 # xblock python-dateutil==2.9.0.post0 # via xblock -pytz==2024.1 +pytz==2024.2 # via xblock -pyyaml==6.0.1 +pyyaml==6.0.2 # via xblock -simplejson==3.19.2 +simplejson==3.19.3 # via xblock six==1.16.0 # via # edx-codejail # fs # python-dateutil -sqlparse==0.4.4 +sqlparse==0.5.1 # via django -typing-extensions==4.10.0 - # via asgiref web-fragments==2.2.0 # via xblock -webob==1.8.7 +webob==1.8.8 # via xblock -xblock==3.1.0 +xblock==5.1.0 # via -r requirements/base.in # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/ci.txt b/requirements/ci.txt index a076b8b..4be09bc 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -1,10 +1,10 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # make upgrade # -cachetools==5.3.3 +cachetools==5.5.0 # via # -r requirements/tox.txt # tox @@ -20,37 +20,32 @@ distlib==0.3.8 # via # -r requirements/tox.txt # virtualenv -filelock==3.13.3 +filelock==3.16.0 # via # -r requirements/tox.txt # tox # virtualenv -packaging==24.0 +packaging==24.1 # via # -r requirements/tox.txt # pyproject-api # tox -platformdirs==4.2.0 +platformdirs==4.3.2 # via # -r requirements/tox.txt # tox # virtualenv -pluggy==1.4.0 +pluggy==1.5.0 # via # -r requirements/tox.txt # tox -pyproject-api==1.6.1 +pyproject-api==1.7.1 # via # -r requirements/tox.txt # tox -tomli==2.0.1 - # via - # -r requirements/tox.txt - # pyproject-api - # tox -tox==4.14.2 +tox==4.18.1 # via -r requirements/tox.txt -virtualenv==20.25.1 +virtualenv==20.26.4 # via # -r requirements/tox.txt # tox diff --git a/requirements/pip.txt b/requirements/pip.txt index cf44902..f313a9c 100644 --- a/requirements/pip.txt +++ b/requirements/pip.txt @@ -1,14 +1,14 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # make upgrade # -wheel==0.43.0 +wheel==0.44.0 # via -r requirements/pip.in # The following packages are considered to be unsafe in a requirements file: -pip==24.0 +pip==24.2 # via -r requirements/pip.in -setuptools==69.2.0 +setuptools==74.1.2 # via -r requirements/pip.in diff --git a/requirements/pip_tools.txt b/requirements/pip_tools.txt index 4e1105e..77d81ad 100644 --- a/requirements/pip_tools.txt +++ b/requirements/pip_tools.txt @@ -1,34 +1,23 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # make upgrade # -build==1.2.1 +build==1.2.2 # via pip-tools click==8.1.7 # via pip-tools -importlib-metadata==6.11.0 - # via - # -c requirements/common_constraints.txt - # build -packaging==24.0 +packaging==24.1 # via build pip-tools==7.4.1 # via -r requirements/pip_tools.in -pyproject-hooks==1.0.0 - # via - # build - # pip-tools -tomli==2.0.1 +pyproject-hooks==1.1.0 # via # build # pip-tools - # pyproject-hooks -wheel==0.43.0 +wheel==0.44.0 # via pip-tools -zipp==3.18.1 - # via importlib-metadata # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/requirements/quality.txt b/requirements/quality.txt index 0127273..41cc0dd 100644 --- a/requirements/quality.txt +++ b/requirements/quality.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # make upgrade @@ -12,24 +12,23 @@ asgiref==3.8.1 # via # -r requirements/base.txt # django -astroid==3.1.0 +astroid==3.2.4 # via pylint -backports-zoneinfo==0.2.1 ; python_version < "3.9" - # via - # -c requirements/constraints.txt - # -r requirements/base.txt - # django -coverage==7.4.4 +coverage==7.6.1 # via -r requirements/test.txt dill==0.3.8 # via pylint -django==4.2.11 +django==4.2.16 # via # -c requirements/common_constraints.txt # -r requirements/base.txt -edx-codejail==3.3.3 +dnspython==2.6.1 + # via + # -r requirements/test.txt + # pymongo +edx-codejail==3.4.1 # via -r requirements/base.txt -edx-opaque-keys==2.5.1 +edx-opaque-keys==2.11.0 # via -r requirements/test.txt fs==2.4.16 # via @@ -37,11 +36,11 @@ fs==2.4.16 # xblock isort==5.13.2 # via pylint -lxml==5.2.1 +lxml==5.3.0 # via # -r requirements/base.txt # xblock -mako==1.3.2 +mako==1.3.5 # via # -r requirements/base.txt # xblock @@ -52,17 +51,17 @@ markupsafe==2.1.5 # xblock mccabe==0.7.0 # via pylint -pbr==6.0.0 +pbr==6.1.0 # via # -r requirements/test.txt # stevedore -platformdirs==4.2.0 +platformdirs==4.3.2 # via pylint -pycodestyle==2.11.1 +pycodestyle==2.12.1 # via -r requirements/quality.in -pylint==3.1.0 +pylint==3.2.7 # via -r requirements/quality.in -pymongo==3.13.0 +pymongo==4.8.0 # via # -r requirements/test.txt # edx-opaque-keys @@ -70,15 +69,15 @@ python-dateutil==2.9.0.post0 # via # -r requirements/base.txt # xblock -pytz==2024.1 +pytz==2024.2 # via # -r requirements/base.txt # xblock -pyyaml==6.0.1 +pyyaml==6.0.2 # via # -r requirements/base.txt # xblock -simplejson==3.19.2 +simplejson==3.19.3 # via # -r requirements/base.txt # xblock @@ -88,35 +87,29 @@ six==1.16.0 # edx-codejail # fs # python-dateutil -sqlparse==0.4.4 +sqlparse==0.5.1 # via # -r requirements/base.txt # django -stevedore==5.2.0 +stevedore==5.3.0 # via # -r requirements/test.txt # edx-opaque-keys -tomli==2.0.1 - # via pylint -tomlkit==0.12.4 +tomlkit==0.13.2 # via pylint -typing-extensions==4.10.0 +typing-extensions==4.12.2 # via - # -r requirements/base.txt # -r requirements/test.txt - # asgiref - # astroid # edx-opaque-keys - # pylint web-fragments==2.2.0 # via # -r requirements/base.txt # xblock -webob==1.8.7 +webob==1.8.8 # via # -r requirements/base.txt # xblock -xblock==3.1.0 +xblock==5.1.0 # via -r requirements/base.txt # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/test.txt b/requirements/test.txt index fa00c97..9427165 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,18 +1,20 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # make upgrade # -coverage==7.4.4 +coverage==7.6.1 # via -r requirements/test.in -edx-opaque-keys==2.5.1 +dnspython==2.6.1 + # via pymongo +edx-opaque-keys==2.11.0 # via -r requirements/test.in -pbr==6.0.0 +pbr==6.1.0 # via stevedore -pymongo==3.13.0 +pymongo==4.8.0 # via edx-opaque-keys -stevedore==5.2.0 +stevedore==5.3.0 # via edx-opaque-keys -typing-extensions==4.10.0 +typing-extensions==4.12.2 # via edx-opaque-keys diff --git a/requirements/tox.txt b/requirements/tox.txt index cc5293d..c6769e2 100644 --- a/requirements/tox.txt +++ b/requirements/tox.txt @@ -1,10 +1,10 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.11 # by the following command: # # make upgrade # -cachetools==5.3.3 +cachetools==5.5.0 # via tox chardet==5.2.0 # via tox @@ -12,27 +12,23 @@ colorama==0.4.6 # via tox distlib==0.3.8 # via virtualenv -filelock==3.13.3 +filelock==3.16.0 # via # tox # virtualenv -packaging==24.0 +packaging==24.1 # via # pyproject-api # tox -platformdirs==4.2.0 +platformdirs==4.3.2 # via # tox # virtualenv -pluggy==1.4.0 +pluggy==1.5.0 # via tox -pyproject-api==1.6.1 +pyproject-api==1.7.1 # via tox -tomli==2.0.1 - # via - # pyproject-api - # tox -tox==4.14.2 +tox==4.18.1 # via -r requirements/tox.in -virtualenv==20.25.1 +virtualenv==20.26.4 # via tox From 108612748c0eb6c3943f9b568bc4e9108d6cdf4a Mon Sep 17 00:00:00 2001 From: Omer Bhatti Date: Wed, 11 Sep 2024 16:10:24 +0500 Subject: [PATCH 3/6] chore: Shift from pkg_resources to importlib.resources --- sql_grader/mixins/scenario.py | 8 +++++--- sql_grader/problem.py | 17 ++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/sql_grader/mixins/scenario.py b/sql_grader/mixins/scenario.py index e110f6a..d6966d5 100644 --- a/sql_grader/mixins/scenario.py +++ b/sql_grader/mixins/scenario.py @@ -2,7 +2,8 @@ Mixin workbench behavior into XBlocks """ from glob import glob -import pkg_resources +import importlib.resources +import importlib def _read_file(file_path): @@ -62,7 +63,8 @@ def workbench_scenarios(cls): """ module = cls.__module__ module = module.split('.', maxsplit=1)[0] - directory = pkg_resources.resource_filename(module, 'scenarios') - files = _find_files(directory) + module_ref = importlib.import_module(module) + files = importlib.resources.files(module_ref).joinpath('scenarios') + files = _find_files(files) scenarios = _read_files(files) return scenarios diff --git a/sql_grader/problem.py b/sql_grader/problem.py index e4b0b08..afa1cb0 100644 --- a/sql_grader/problem.py +++ b/sql_grader/problem.py @@ -4,9 +4,16 @@ import os import sqlite3 -import pkg_resources +try: + from xblock.utils.resources import ResourceLoader +except ModuleNotFoundError: + # For backward compatibility with releases older than Quince. + from xblockutils.resources import ResourceLoader +import importlib.resources +loader = ResourceLoader(__name__) + class SqlProblem: """ Handle modeling and processing of SQL problems aside from XBlock logic @@ -178,10 +185,7 @@ def all_datasets(): """ Lookup the names of all avaiable datasets (.sql files) """ - dataset_directory = pkg_resources.resource_filename( - 'sql_grader', - 'datasets' - ) + dataset_directory = importlib.resources.files('sql_grader') / 'datasets' for _, _, files in os.walk(dataset_directory): for fname in files: if fname.endswith('.sql'): @@ -193,8 +197,7 @@ def resource_string(path): """ Handy helper for getting resources from our kit """ - data = pkg_resources.resource_string(__name__, path) - return data.decode('utf8') + return loader.load_unicode(path) def create_database(database_name): From 9648beaa30af633b4591e974f6fc34e9e82f198e Mon Sep 17 00:00:00 2001 From: Omer Bhatti Date: Wed, 25 Sep 2024 10:25:33 +0500 Subject: [PATCH 4/6] fix: added support for py12, removed 3.8 from tox and fixed loading scenarios --- setup.py | 1 + sql_grader/mixins/scenario.py | 59 ++++------------------------------- tox.ini | 4 +-- 3 files changed, 9 insertions(+), 55 deletions(-) diff --git a/setup.py b/setup.py index 493bc77..873b485 100644 --- a/setup.py +++ b/setup.py @@ -155,5 +155,6 @@ def is_requirement(line): 'Natural Language :: English', "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] ) diff --git a/sql_grader/mixins/scenario.py b/sql_grader/mixins/scenario.py index d6966d5..cfb13ff 100644 --- a/sql_grader/mixins/scenario.py +++ b/sql_grader/mixins/scenario.py @@ -1,54 +1,13 @@ """ Mixin workbench behavior into XBlocks """ -from glob import glob -import importlib.resources -import importlib +try: + from xblock.utils.resources import ResourceLoader +except ModuleNotFoundError: + from xblockutils.resources import ResourceLoader -def _read_file(file_path): - """ - Read in a file's contents - """ - with open(file_path) as file_input: - file_contents = file_input.read() - return file_contents - - -def _parse_title(file_path): - """ - Parse a title from a file name - """ - title = file_path - title = title.split('/')[-1] - title = '.'.join(title.split('.')[:-1]) - title = ' '.join(title.split('-')) - return title - - -def _read_files(files): - """ - Read the contents of a list of files - """ - file_contents = [ - ( - _parse_title(file_path), - _read_file(file_path), - ) - for file_path in files - ] - return file_contents - - -def _find_files(directory): - """ - Find XML files in the directory - """ - pattern = "{directory}/*.xml".format( - directory=directory, - ) - files = glob(pattern) - return files +loader = ResourceLoader(__name__) class XBlockWorkbenchMixin: @@ -61,10 +20,4 @@ def workbench_scenarios(cls): """ Gather scenarios to be displayed in the workbench """ - module = cls.__module__ - module = module.split('.', maxsplit=1)[0] - module_ref = importlib.import_module(module) - files = importlib.resources.files(module_ref).joinpath('scenarios') - files = _find_files(files) - scenarios = _read_files(files) - return scenarios + return loader.load_scenarios_from_path("../scenarios") diff --git a/tox.ini b/tox.ini index 58ebf1b..7d0926b 100644 --- a/tox.ini +++ b/tox.ini @@ -2,14 +2,14 @@ envlist = csslint eslint - py{38, 311}-django{42}quality + py{311}-django{42}quality [testenv] deps = -rrequirements/test.txt -e git+https://github.com/openedx/codejail.git@3.0.0\#egg=codejail django42: Django>=4.2,<4.3 - + commands = coverage run manage.py test coverage report From a3be8238028860d11c67828954d7285674a09cd8 Mon Sep 17 00:00:00 2001 From: Omer Bhatti Date: Fri, 27 Sep 2024 20:15:53 +0500 Subject: [PATCH 5/6] fix: resolved failing test --- sql_grader/problem.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sql_grader/problem.py b/sql_grader/problem.py index afa1cb0..0367384 100644 --- a/sql_grader/problem.py +++ b/sql_grader/problem.py @@ -14,6 +14,7 @@ loader = ResourceLoader(__name__) + class SqlProblem: """ Handle modeling and processing of SQL problems aside from XBlock logic From 62f331c59637fdebcdecc9dedea536e5edad1e8d Mon Sep 17 00:00:00 2001 From: Omer Bhatti Date: Fri, 27 Sep 2024 20:23:17 +0500 Subject: [PATCH 6/6] chore: bumped the version to 2.0.0 and build using latest python version --- .github/workflows/pypi-publish.yml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index 21fc709..bc05efd 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -15,7 +15,7 @@ jobs: - name: setup python uses: actions/setup-python@v3 with: - python-version: 3.11 + python-version: 3.12 - name: Install pip run: pip install -r requirements/pip.txt diff --git a/setup.py b/setup.py index 123f803..1d9a209 100644 --- a/setup.py +++ b/setup.py @@ -124,7 +124,7 @@ def is_requirement(line): setup( name='xblock-sql-grader', - version='1.0.0', + version='1.1.0', description='SQL Grader XBlock', # TODO: write a better description. license='AGPLv3', long_description=README,