From a7b3c28a6a3e979f0e713c6ed04c4a201ac42605 Mon Sep 17 00:00:00 2001 From: Jeremy Bowman Date: Mon, 23 Oct 2023 14:47:15 -0400 Subject: [PATCH 1/3] fix: Make the Dockerfile work and update requirements --- Dockerfile | 77 ++++++++++++++++++++-------- Makefile | 36 ++++++++----- docker-compose.yml | 6 ++- requirements/base.in | 5 +- requirements/base.txt | 31 +++++++++-- requirements/ci.txt | 6 +-- requirements/common_constraints.txt | 28 ++++++++++ requirements/constraints.txt | 4 +- requirements/dev.txt | 62 ++++++++++++++++++---- requirements/django.txt | 2 +- requirements/doc.txt | 79 ++++++++++++++++++++++------- requirements/pip-tools.txt | 2 +- requirements/pip.txt | 2 +- requirements/production.txt | 51 +++++++++++++++++-- requirements/quality.txt | 62 ++++++++++++++++++---- requirements/test.txt | 54 +++++++++++++++++--- requirements/validation.txt | 74 +++++++++++++++++++++++---- 17 files changed, 467 insertions(+), 114 deletions(-) create mode 100644 requirements/common_constraints.txt diff --git a/Dockerfile b/Dockerfile index e3a2804..aa28e58 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,39 +1,54 @@ -FROM ubuntu:focal as app -MAINTAINER sre@edx.org - +FROM ubuntu:focal as base # Packages installed: # language-pack-en locales; ubuntu locale support so that system utilities have a consistent # language and time zone. -# python; ubuntu doesnt ship with python, so this is the python we will use to run the application - -# python3-pip; install pip to install application requirements.txt files +# python3.9; version of python compatible with Anki # libmysqlclient-dev; to install header files needed to use native C implementation for # MySQL-python for performance gains. # libssl-dev; # mysqlclient wont install without this. -# python3-dev; to install header files for python extensions; much wheel-building depends on this +# make; needed to build the gevent wheel (unclear why a binary wheel isn't being found and used) -# gcc; for compiling python extensions distributed with python packages like mysql-client +# python3.9-dev; to install header files for python extensions; much wheel-building depends on this -# If you add a package here please include a comment above describing what it is used for -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -qy install --no-install-recommends \ - language-pack-en locales \ - python3.8 python3-dev python3-pip \ - # The mysqlclient Python package has install-time dependencies - libmysqlclient-dev libssl-dev pkg-config \ - gcc +# python3.9-venv; install Python 3.9 version of venv for creating a virtualenv with pip + +# gcc; for compiling python extensions distributed with python packages like mysql-client +# unzip; for extracting the downloaded watchman binary release -RUN pip install --upgrade pip setuptools -# delete apt package lists because we do not need them inflating our image -RUN rm -rf /var/lib/apt/lists/* +# wget; for fetching a local copy of common_constraints.txt to edit until the Django 4.2 upgrade is complete -RUN ln -s /usr/bin/python3 /usr/bin/python +# If you add a package here please include a comment above describing what it is used for +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get -qy install --no-install-recommends software-properties-common && \ + apt-add-repository -y ppa:deadsnakes/ppa && \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get -qy install --no-install-recommends \ + language-pack-en \ + locales \ + make \ + python3.9 \ + python3.9-dev \ + python3.9-venv \ + # The mysqlclient Python package has install-time dependencies + libmysqlclient-dev \ + libssl-dev \ + pkg-config \ + gcc \ + unzip \ + wget && \ + rm -rf /var/lib/apt/lists/* + +# Create Python env +ENV VIRTUAL_ENV=/edx/app/venvs/flashcards +RUN python3.9 -m venv $VIRTUAL_ENV +ENV PATH="$VIRTUAL_ENV/bin:$PATH" RUN locale-gen en_US.UTF-8 ENV LANG en_US.UTF-8 @@ -48,10 +63,13 @@ WORKDIR /edx/app/flashcards # Copy the requirements explicitly even though we copy everything below # this prevents the image cache from busting unless the dependencies have changed. +COPY requirements/pip.txt /edx/app/flashcards/requirements/pip.txt COPY requirements/production.txt /edx/app/flashcards/requirements/production.txt # Dependencies are installed as root so they cannot be modified by the application user. -RUN pip install -r requirements/production.txt + +RUN pip install --no-cache-dir -r requirements/pip.txt +RUN pip install --no-cache-dir -r requirements/production.txt RUN mkdir -p /edx/var/log @@ -65,3 +83,22 @@ CMD gunicorn --workers=2 --name flashcards -c /edx/app/flashcards/flashcards/doc # This line is after the requirements so that changes to the code will not # bust the image cache COPY . /edx/app/flashcards + +# We don't switch back to the app user for devstack because we need devstack users to be +# able to update requirements and generally run things as root. +FROM base as dev +USER root +ENV DJANGO_SETTINGS_MODULE flashcards.settings.devstack + +# Install watchman +RUN wget https://github.com/facebook/watchman/releases/download/v2023.10.23.00/watchman-v2023.10.23.00-linux.zip +RUN unzip watchman-v2023.10.23.00-linux.zip +RUN mkdir -p /usr/local/{bin,lib} /usr/local/var/run/watchman +RUN cp watchman-v2023.10.23.00-linux/bin/* /usr/local/bin +RUN cp watchman-v2023.10.23.00-linux/lib/* /usr/local/lib +RUN chmod 755 /usr/local/bin/watchman +RUN chmod 2777 /usr/local/var/run/watchman + +RUN pip install --no-cache-dir -r /edx/app/flashcards/requirements/dev.txt + +CMD while true; do python ./manage.py runserver 0.0.0.0:8491; sleep 2; done diff --git a/Makefile b/Makefile index fc3d1a5..ed28a6b 100644 --- a/Makefile +++ b/Makefile @@ -44,7 +44,7 @@ dev_requirements: clean_tox piptools ## sync to requirements for local developme validation_requirements: piptools ## sync to requirements for testing & code quality checking pip-sync -q requirements/validation.txt -doc_requirements: piptools +doc_requirements: piptools ## install requirements for documentation builds pip-sync -q requirements/doc.txt production-requirements: piptools ## install requirements for production @@ -59,8 +59,7 @@ shell: ## run Django shell test: clean ## run tests and generate coverage report pytest -# To be run from CI context -coverage: clean +coverage: clean ## To be run from CI context pytest --cov-report html $(BROWSER)htmlcov/index.html @@ -76,7 +75,7 @@ style: ## run Python style checker lint: ## run Python code linting pylint --rcfile=pylintrc flashcards *.py -quality: +quality: ## run all quality checks tox -e quality pii_check: ## check for PII annotations on all Django models @@ -97,8 +96,17 @@ html_coverage: ## generate and view HTML coverage report # Define PIP_COMPILE_OPTS=-v to get more information during make upgrade. PIP_COMPILE = pip-compile --upgrade $(PIP_COMPILE_OPTS) +COMMON_CONSTRAINTS_TXT=requirements/common_constraints.txt +.PHONY: $(COMMON_CONSTRAINTS_TXT) +$(COMMON_CONSTRAINTS_TXT): + wget -O "$(@)" https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt || touch "$(@)" + echo "$(COMMON_CONSTRAINTS_TEMP_COMMENT)" | cat - $(@) > temp && mv temp $(@) + + upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade -upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in +upgrade: $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in + sed 's/Django<4.0//g' requirements/common_constraints.txt > requirements/common_constraints.tmp + mv requirements/common_constraints.tmp requirements/common_constraints.txt pip install -qr requirements/pip-tools.txt # Make sure to compile files after any other files they include! $(PIP_COMPILE) --allow-unsafe -o requirements/pip.txt requirements/pip.in @@ -125,7 +133,7 @@ extract_translations: ## extract strings to be translated, outputting .mo files dummy_translations: ## generate dummy translation (.po) files cd flashcards && i18n_tool dummy -compile_translations: # compile translation files, outputting .po files for each supported language +compile_translations: ## compile translation files, outputting .po files for each supported language python manage.py compilemessages fake_translations: extract_translations dummy_translations compile_translations ## generate and compile dummy translation files @@ -143,7 +151,7 @@ open-devstack: ## open a shell on the server started by start-devstack docker exec -it flashcards /edx/app/flashcards/devstack.sh open pkg-devstack: ## build the flashcards image from the latest configuration and code - docker build -t flashcards:latest -f docker/build/flashcards/Dockerfile git://github.com/openedx/configuration + docker build -t flashcards:latest -f docker/build/flashcards/Dockerfile detect_changed_source_translations: ## check if translation files are up-to-date cd flashcards && i18n_tool changed @@ -154,28 +162,28 @@ docker_build: docker build . -f Dockerfile -t openedx/flashcards # devstack-themed shortcuts -dev.up: # Starts all containers +dev.up: ## Starts all containers docker-compose up -d dev.up.build: docker-compose up -d --build -dev.down: # Kills containers and all of their data that isn't in volumes +dev.down: ## Kills containers and all of their data that isn't in volumes docker-compose down -dev.stop: # Stops containers so they can be restarted +dev.stop: ## Stops containers so they can be restarted docker-compose stop -app-shell: # Run the app shell as root +app-shell: ## Run the app shell as root docker exec -u 0 -it flashcards.app bash -db-shell: # Run the app shell as root, enter the app's database +db-shell: ## Run the app shell as root, enter the app's database docker exec -u 0 -it flashcards.db mysql -u root flashcards -%-logs: # View the logs of the specified service container +%-logs: ## View the logs of the specified service container docker-compose logs -f --tail=500 $* -%-restart: # Restart the specified service container +%-restart: ## Restart the specified service container docker-compose restart $* %-attach: diff --git a/docker-compose.yml b/docker-compose.yml index dd78c28..a45a1e4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,9 @@ version: "2.1" services: db: - image: mysql:8.0 + # Oracle-packaged version includes a `linux/arm64/v8` version, needed for + # machines with Apple Silicon CPUs (Mac M1, M2) + image: mysql:8.0.33-oracle container_name: flashcards.db environment: # See how these environment variables being used at https://github.com/mysql/mysql-docker/blob/mysql-server/8.0/docker-entrypoint.sh @@ -27,7 +29,7 @@ services: environment: DJANGO_SETTINGS_MODULE: flashcards.settings.devstack ports: - - "8491:8491" # TODO: change this to your port + - "8491:8491" networks: - devstack_default stdin_open: true diff --git a/requirements/base.in b/requirements/base.in index 7a746a5..198bd4b 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -1,7 +1,8 @@ # Core requirements for using this application -c constraints.txt -Django # Web application framework +anki # library/application for flashcards with spaced repetition +Django # Web application framework django-cors-headers django-extensions django-rest-swagger @@ -13,5 +14,5 @@ edx-django-release-util edx-drf-extensions edx-rest-api-client mysqlclient -openai +openai # OpenAI library used to generate flash card candidates from course content pytz diff --git a/requirements/base.txt b/requirements/base.txt index fa49b50..4801772 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.9 # by the following command: # # make upgrade @@ -8,12 +8,16 @@ aiohttp==3.8.6 # via openai aiosignal==1.3.1 # via aiohttp +anki==2.1.66 + # via -r requirements/base.in asgiref==3.7.2 # via django async-timeout==4.0.3 # via aiohttp attrs==23.1.0 # via aiohttp +beautifulsoup4==4.12.2 + # via anki certifi==2023.7.22 # via requests cffi==1.16.0 @@ -36,13 +40,16 @@ cryptography==41.0.4 # via # pyjwt # social-auth-core +decorator==5.1.1 + # via anki defusedxml==0.8.0rc2 # via # python3-openid # social-auth-core -django==3.2.22 +distro==1.8.0 + # via anki +django==4.2.6 # via - # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt # -r requirements/base.in # django-cors-headers # django-crum @@ -99,10 +106,14 @@ idna==3.4 # via # requests # yarl +importlib-metadata==6.8.0 + # via markdown itypes==1.2.0 # via coreapi jinja2==3.1.2 # via coreschema +markdown==3.5 + # via anki markupsafe==2.1.3 # via jinja2 multidict==6.0.4 @@ -121,8 +132,12 @@ openai==0.28.1 # via -r requirements/base.in openapi-codec==1.3.2 # via django-rest-swagger +orjson==3.9.9 + # via anki pbr==5.11.1 # via stevedore +protobuf==4.24.4 + # via anki psutil==5.9.6 # via edx-django-utils pycparser==2.21 @@ -139,17 +154,19 @@ pymongo==3.13.0 # via edx-opaque-keys pynacl==1.5.0 # via edx-django-utils +pysocks==1.7.1 + # via requests python3-openid==3.2.0 # via social-auth-core pytz==2023.3.post1 # via # -r requirements/base.in - # django # djangorestframework pyyaml==6.0.1 # via edx-django-release-util -requests==2.31.0 +requests[socks]==2.31.0 # via + # anki # coreapi # edx-drf-extensions # edx-rest-api-client @@ -175,6 +192,8 @@ social-auth-core==4.4.2 # via # edx-auth-backends # social-auth-app-django +soupsieve==2.5 + # via beautifulsoup4 sqlparse==0.4.4 # via django stevedore==5.1.0 @@ -193,3 +212,5 @@ urllib3==2.0.7 # via requests yarl==1.9.2 # via aiohttp +zipp==3.17.0 + # via importlib-metadata diff --git a/requirements/ci.txt b/requirements/ci.txt index 8115a7d..c9d9631 100644 --- a/requirements/ci.txt +++ b/requirements/ci.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.9 # by the following command: # # make upgrade @@ -24,10 +24,10 @@ tomli==2.0.1 # via tox tox==3.28.0 # via - # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # -c requirements/common_constraints.txt # -r requirements/ci.in # tox-battery tox-battery==0.6.2 # via -r requirements/ci.in -virtualenv==20.24.5 +virtualenv==20.24.6 # via tox diff --git a/requirements/common_constraints.txt b/requirements/common_constraints.txt new file mode 100644 index 0000000..e236582 --- /dev/null +++ b/requirements/common_constraints.txt @@ -0,0 +1,28 @@ + +# A central location for most common version constraints +# (across edx repos) for pip-installation. +# +# Similar to other constraint files this file doesn't install any packages. +# It specifies version constraints that will be applied if a package is needed. +# When pinning something here, please provide an explanation of why it is a good +# idea to pin this package across all edx repos, Ideally, link to other information +# that will help people in the future to remove the pin when possible. +# Writing an issue against the offending project and linking to it here is good. +# +# Note: Changes to this file will automatically be used by other repos, referencing +# this file from Github directly. It does not require packaging in edx-lint. + + +# using LTS django version + + +# elasticsearch>=7.14.0 includes breaking changes in it which caused issues in discovery upgrade process. +# elastic search changelog: https://www.elastic.co/guide/en/enterprise-search/master/release-notes-7.14.0.html +elasticsearch<7.14.0 + +# django-simple-history>3.0.0 adds indexing and causes a lot of migrations to be affected +django-simple-history==3.0.0 + +# tox>4.0.0 isn't yet compatible with many tox plugins, causing CI failures in almost all repos. +# Details can be found in this discussion: https://github.com/tox-dev/tox/discussions/1810 +tox<4.0.0 diff --git a/requirements/constraints.txt b/requirements/constraints.txt index 2ebd6ea..a51cb08 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -9,6 +9,4 @@ # linking to it here is good. # Common constraints for edx repos --c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt - - +-c common_constraints.txt diff --git a/requirements/dev.txt b/requirements/dev.txt index 51becec..420c4fa 100644 --- a/requirements/dev.txt +++ b/requirements/dev.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.9 # by the following command: # # make upgrade @@ -12,6 +12,8 @@ aiosignal==1.3.1 # via # -r requirements/validation.txt # aiohttp +anki==2.1.66 + # via -r requirements/validation.txt asgiref==3.7.2 # via # -r requirements/validation.txt @@ -29,6 +31,10 @@ attrs==23.1.0 # via # -r requirements/validation.txt # aiohttp +beautifulsoup4==4.12.2 + # via + # -r requirements/validation.txt + # anki build==1.0.3 # via # -r requirements/pip-tools.txt @@ -84,7 +90,12 @@ cryptography==41.0.4 # via # -r requirements/validation.txt # pyjwt + # secretstorage # social-auth-core +decorator==5.1.1 + # via + # -r requirements/validation.txt + # anki defusedxml==0.8.0rc2 # via # -r requirements/validation.txt @@ -100,7 +111,11 @@ distlib==0.3.7 # via # -r requirements/validation.txt # virtualenv -django==3.2.22 +distro==1.8.0 + # via + # -r requirements/validation.txt + # anki +django==4.2.6 # via # -r requirements/validation.txt # django-cors-headers @@ -195,11 +210,8 @@ importlib-metadata==6.8.0 # -r requirements/validation.txt # build # keyring + # markdown # twine -importlib-resources==6.1.0 - # via - # -r requirements/validation.txt - # keyring iniconfig==2.0.0 # via # -r requirements/validation.txt @@ -216,6 +228,11 @@ jaraco-classes==3.3.0 # via # -r requirements/validation.txt # keyring +jeepney==0.8.0 + # via + # -r requirements/validation.txt + # keyring + # secretstorage jinja2==3.1.2 # via # -r requirements/validation.txt @@ -228,6 +245,10 @@ keyring==24.2.0 # twine lxml==4.9.3 # via edx-i18n-tools +markdown==3.5 + # via + # -r requirements/validation.txt + # anki markdown-it-py==3.0.0 # via # -r requirements/validation.txt @@ -274,6 +295,10 @@ openapi-codec==1.3.2 # via # -r requirements/validation.txt # django-rest-swagger +orjson==3.9.9 + # via + # -r requirements/validation.txt + # anki packaging==23.2 # via # -r requirements/pip-tools.txt @@ -306,6 +331,10 @@ pluggy==1.3.0 # tox polib==1.2.0 # via edx-i18n-tools +protobuf==4.24.4 + # via + # -r requirements/validation.txt + # anki psutil==5.9.6 # via # -r requirements/validation.txt @@ -369,6 +398,10 @@ pyproject-hooks==1.0.0 # via # -r requirements/pip-tools.txt # build +pysocks==1.7.1 + # via + # -r requirements/validation.txt + # requests pytest==7.4.2 # via # -r requirements/validation.txt @@ -389,7 +422,6 @@ python3-openid==3.2.0 pytz==2023.3.post1 # via # -r requirements/validation.txt - # django # djangorestframework pyyaml==6.0.1 # via @@ -401,13 +433,15 @@ readme-renderer==42.0 # via # -r requirements/validation.txt # twine -requests==2.31.0 +requests[socks]==2.31.0 # via # -r requirements/validation.txt + # anki # coreapi # edx-drf-extensions # edx-rest-api-client # openai + # requests # requests-oauthlib # requests-toolbelt # slumber @@ -429,6 +463,10 @@ rich==13.6.0 # via # -r requirements/validation.txt # twine +secretstorage==3.3.3 + # via + # -r requirements/validation.txt + # keyring semantic-version==2.10.0 # via # -r requirements/validation.txt @@ -461,6 +499,10 @@ social-auth-core==4.4.2 # -r requirements/validation.txt # edx-auth-backends # social-auth-app-django +soupsieve==2.5 + # via + # -r requirements/validation.txt + # beautifulsoup4 sqlparse==0.4.4 # via # -r requirements/validation.txt @@ -506,7 +548,6 @@ typing-extensions==4.8.0 # astroid # edx-opaque-keys # pylint - # rich uritemplate==4.1.1 # via # -r requirements/validation.txt @@ -516,7 +557,7 @@ urllib3==2.0.7 # -r requirements/validation.txt # requests # twine -virtualenv==20.24.5 +virtualenv==20.24.6 # via # -r requirements/validation.txt # tox @@ -533,7 +574,6 @@ zipp==3.17.0 # -r requirements/pip-tools.txt # -r requirements/validation.txt # importlib-metadata - # importlib-resources # The following packages are considered to be unsafe in a requirements file: # pip diff --git a/requirements/django.txt b/requirements/django.txt index 5a28da3..7ac6d4f 100644 --- a/requirements/django.txt +++ b/requirements/django.txt @@ -1 +1 @@ -django==3.2.22 +django==4.2.6 diff --git a/requirements/doc.txt b/requirements/doc.txt index f7668ed..82c43df 100644 --- a/requirements/doc.txt +++ b/requirements/doc.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.9 # by the following command: # # make upgrade @@ -16,6 +16,8 @@ aiosignal==1.3.1 # aiohttp alabaster==0.7.13 # via sphinx +anki==2.1.66 + # via -r requirements/test.txt asgiref==3.7.2 # via # -r requirements/test.txt @@ -38,7 +40,10 @@ babel==2.13.0 # pydata-sphinx-theme # sphinx beautifulsoup4==4.12.2 - # via pydata-sphinx-theme + # via + # -r requirements/test.txt + # anki + # pydata-sphinx-theme build==1.0.3 # via -r requirements/doc.in certifi==2023.7.22 @@ -88,7 +93,12 @@ cryptography==41.0.4 # via # -r requirements/test.txt # pyjwt + # secretstorage # social-auth-core +decorator==5.1.1 + # via + # -r requirements/test.txt + # anki defusedxml==0.8.0rc2 # via # -r requirements/test.txt @@ -102,9 +112,12 @@ distlib==0.3.7 # via # -r requirements/test.txt # virtualenv -django==3.2.22 +distro==1.8.0 + # via + # -r requirements/test.txt + # anki +django==4.2.6 # via - # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt # -r requirements/test.txt # django-cors-headers # django-crum @@ -195,12 +208,12 @@ imagesize==1.4.1 # via sphinx importlib-metadata==6.8.0 # via + # -r requirements/test.txt # build # keyring + # markdown # sphinx # twine -importlib-resources==6.1.0 - # via keyring iniconfig==2.0.0 # via # -r requirements/test.txt @@ -215,6 +228,10 @@ itypes==1.2.0 # coreapi jaraco-classes==3.3.0 # via keyring +jeepney==0.8.0 + # via + # keyring + # secretstorage jinja2==3.1.2 # via # -r requirements/test.txt @@ -223,6 +240,10 @@ jinja2==3.1.2 # sphinx keyring==24.2.0 # via twine +markdown==3.5 + # via + # -r requirements/test.txt + # anki markdown-it-py==3.0.0 # via rich markupsafe==2.1.3 @@ -261,6 +282,10 @@ openapi-codec==1.3.2 # via # -r requirements/test.txt # django-rest-swagger +orjson==3.9.9 + # via + # -r requirements/test.txt + # anki packaging==23.2 # via # -r requirements/test.txt @@ -285,6 +310,10 @@ pluggy==1.3.0 # -r requirements/test.txt # pytest # tox +protobuf==4.24.4 + # via + # -r requirements/test.txt + # anki psutil==5.9.6 # via # -r requirements/test.txt @@ -346,6 +375,10 @@ pynacl==1.5.0 # edx-django-utils pyproject-hooks==1.0.0 # via build +pysocks==1.7.1 + # via + # -r requirements/test.txt + # requests pytest==7.4.2 # via # -r requirements/test.txt @@ -366,8 +399,6 @@ python3-openid==3.2.0 pytz==2023.3.post1 # via # -r requirements/test.txt - # babel - # django # djangorestframework pyyaml==6.0.1 # via @@ -376,13 +407,15 @@ pyyaml==6.0.1 # edx-django-release-util readme-renderer==42.0 # via twine -requests==2.31.0 +requests[socks]==2.31.0 # via # -r requirements/test.txt + # anki # coreapi # edx-drf-extensions # edx-rest-api-client # openai + # requests # requests-oauthlib # requests-toolbelt # slumber @@ -401,6 +434,8 @@ rfc3986==2.0.0 # via twine rich==13.6.0 # via twine +secretstorage==3.3.3 + # via keyring semantic-version==2.10.0 # via # -r requirements/test.txt @@ -432,25 +467,32 @@ social-auth-core==4.4.2 # edx-auth-backends # social-auth-app-django soupsieve==2.5 - # via beautifulsoup4 + # via + # -r requirements/test.txt + # beautifulsoup4 sphinx==6.2.1 # via # -r requirements/doc.in # pydata-sphinx-theme # sphinx-book-theme + # sphinxcontrib-applehelp + # sphinxcontrib-devhelp + # sphinxcontrib-htmlhelp + # sphinxcontrib-qthelp + # sphinxcontrib-serializinghtml sphinx-book-theme==1.0.1 # via -r requirements/doc.in -sphinxcontrib-applehelp==1.0.4 +sphinxcontrib-applehelp==1.0.7 # via sphinx -sphinxcontrib-devhelp==1.0.2 +sphinxcontrib-devhelp==1.0.5 # via sphinx -sphinxcontrib-htmlhelp==2.0.1 +sphinxcontrib-htmlhelp==2.0.4 # via sphinx sphinxcontrib-jsmath==1.0.1 # via sphinx -sphinxcontrib-qthelp==1.0.3 +sphinxcontrib-qthelp==1.0.6 # via sphinx -sphinxcontrib-serializinghtml==1.1.5 +sphinxcontrib-serializinghtml==1.1.9 # via sphinx sqlparse==0.4.4 # via @@ -483,7 +525,7 @@ tomlkit==0.12.1 # pylint tox==3.28.0 # via - # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # -c requirements/common_constraints.txt # -r requirements/test.txt tqdm==4.66.1 # via @@ -499,7 +541,6 @@ typing-extensions==4.8.0 # edx-opaque-keys # pydata-sphinx-theme # pylint - # rich uritemplate==4.1.1 # via # -r requirements/test.txt @@ -509,7 +550,7 @@ urllib3==2.0.7 # -r requirements/test.txt # requests # twine -virtualenv==20.24.5 +virtualenv==20.24.6 # via # -r requirements/test.txt # tox @@ -519,5 +560,5 @@ yarl==1.9.2 # aiohttp zipp==3.17.0 # via + # -r requirements/test.txt # importlib-metadata - # importlib-resources diff --git a/requirements/pip-tools.txt b/requirements/pip-tools.txt index 50d35f2..df834b0 100644 --- a/requirements/pip-tools.txt +++ b/requirements/pip-tools.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.9 # by the following command: # # make upgrade diff --git a/requirements/pip.txt b/requirements/pip.txt index 0c788d6..242379d 100644 --- a/requirements/pip.txt +++ b/requirements/pip.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.9 # by the following command: # # make upgrade diff --git a/requirements/production.txt b/requirements/production.txt index ed5bff8..3ce8770 100644 --- a/requirements/production.txt +++ b/requirements/production.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.9 # by the following command: # # make upgrade @@ -12,6 +12,8 @@ aiosignal==1.3.1 # via # -r requirements/base.txt # aiohttp +anki==2.1.66 + # via -r requirements/base.txt asgiref==3.7.2 # via # -r requirements/base.txt @@ -24,6 +26,10 @@ attrs==23.1.0 # via # -r requirements/base.txt # aiohttp +beautifulsoup4==4.12.2 + # via + # -r requirements/base.txt + # anki certifi==2023.7.22 # via # -r requirements/base.txt @@ -56,12 +62,20 @@ cryptography==41.0.4 # -r requirements/base.txt # pyjwt # social-auth-core +decorator==5.1.1 + # via + # -r requirements/base.txt + # anki defusedxml==0.8.0rc2 # via # -r requirements/base.txt # python3-openid # social-auth-core -django==3.2.22 +distro==1.8.0 + # via + # -r requirements/base.txt + # anki +django==4.2.6 # via # -r requirements/base.txt # django-cors-headers @@ -133,6 +147,10 @@ idna==3.4 # -r requirements/base.txt # requests # yarl +importlib-metadata==6.8.0 + # via + # -r requirements/base.txt + # markdown itypes==1.2.0 # via # -r requirements/base.txt @@ -141,6 +159,10 @@ jinja2==3.1.2 # via # -r requirements/base.txt # coreschema +markdown==3.5 + # via + # -r requirements/base.txt + # anki markupsafe==2.1.3 # via # -r requirements/base.txt @@ -169,12 +191,20 @@ openapi-codec==1.3.2 # via # -r requirements/base.txt # django-rest-swagger +orjson==3.9.9 + # via + # -r requirements/base.txt + # anki packaging==23.2 # via gunicorn pbr==5.11.1 # via # -r requirements/base.txt # stevedore +protobuf==4.24.4 + # via + # -r requirements/base.txt + # anki psutil==5.9.6 # via # -r requirements/base.txt @@ -200,6 +230,10 @@ pynacl==1.5.0 # via # -r requirements/base.txt # edx-django-utils +pysocks==1.7.1 + # via + # -r requirements/base.txt + # requests python-memcached==1.59 # via -r requirements/production.in python3-openid==3.2.0 @@ -209,20 +243,21 @@ python3-openid==3.2.0 pytz==2023.3.post1 # via # -r requirements/base.txt - # django # djangorestframework pyyaml==6.0.1 # via # -r requirements/base.txt # -r requirements/production.in # edx-django-release-util -requests==2.31.0 +requests[socks]==2.31.0 # via # -r requirements/base.txt + # anki # coreapi # edx-drf-extensions # edx-rest-api-client # openai + # requests # requests-oauthlib # slumber # social-auth-core @@ -257,6 +292,10 @@ social-auth-core==4.4.2 # -r requirements/base.txt # edx-auth-backends # social-auth-app-django +soupsieve==2.5 + # via + # -r requirements/base.txt + # beautifulsoup4 sqlparse==0.4.4 # via # -r requirements/base.txt @@ -287,6 +326,10 @@ yarl==1.9.2 # via # -r requirements/base.txt # aiohttp +zipp==3.17.0 + # via + # -r requirements/base.txt + # importlib-metadata zope-event==5.0 # via gevent zope-interface==6.1 diff --git a/requirements/quality.txt b/requirements/quality.txt index 3da3b35..bcb676c 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.9 # by the following command: # # make upgrade @@ -12,6 +12,8 @@ aiosignal==1.3.1 # via # -r requirements/test.txt # aiohttp +anki==2.1.66 + # via -r requirements/test.txt asgiref==3.7.2 # via # -r requirements/test.txt @@ -29,6 +31,10 @@ attrs==23.1.0 # via # -r requirements/test.txt # aiohttp +beautifulsoup4==4.12.2 + # via + # -r requirements/test.txt + # anki certifi==2023.7.22 # via # -r requirements/test.txt @@ -76,7 +82,12 @@ cryptography==41.0.4 # via # -r requirements/test.txt # pyjwt + # secretstorage # social-auth-core +decorator==5.1.1 + # via + # -r requirements/test.txt + # anki defusedxml==0.8.0rc2 # via # -r requirements/test.txt @@ -90,9 +101,12 @@ distlib==0.3.7 # via # -r requirements/test.txt # virtualenv -django==3.2.22 +distro==1.8.0 + # via + # -r requirements/test.txt + # anki +django==4.2.6 # via - # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt # -r requirements/test.txt # django-cors-headers # django-crum @@ -176,10 +190,10 @@ idna==3.4 # yarl importlib-metadata==6.8.0 # via + # -r requirements/test.txt # keyring + # markdown # twine -importlib-resources==6.1.0 - # via keyring iniconfig==2.0.0 # via # -r requirements/test.txt @@ -195,6 +209,10 @@ itypes==1.2.0 # coreapi jaraco-classes==3.3.0 # via keyring +jeepney==0.8.0 + # via + # keyring + # secretstorage jinja2==3.1.2 # via # -r requirements/test.txt @@ -202,6 +220,10 @@ jinja2==3.1.2 # coreschema keyring==24.2.0 # via twine +markdown==3.5 + # via + # -r requirements/test.txt + # anki markdown-it-py==3.0.0 # via rich markupsafe==2.1.3 @@ -240,6 +262,10 @@ openapi-codec==1.3.2 # via # -r requirements/test.txt # django-rest-swagger +orjson==3.9.9 + # via + # -r requirements/test.txt + # anki packaging==23.2 # via # -r requirements/test.txt @@ -261,6 +287,10 @@ pluggy==1.3.0 # -r requirements/test.txt # pytest # tox +protobuf==4.24.4 + # via + # -r requirements/test.txt + # anki psutil==5.9.6 # via # -r requirements/test.txt @@ -318,6 +348,10 @@ pynacl==1.5.0 # via # -r requirements/test.txt # edx-django-utils +pysocks==1.7.1 + # via + # -r requirements/test.txt + # requests pytest==7.4.2 # via # -r requirements/test.txt @@ -338,7 +372,6 @@ python3-openid==3.2.0 pytz==2023.3.post1 # via # -r requirements/test.txt - # django # djangorestframework pyyaml==6.0.1 # via @@ -347,13 +380,15 @@ pyyaml==6.0.1 # edx-django-release-util readme-renderer==42.0 # via twine -requests==2.31.0 +requests[socks]==2.31.0 # via # -r requirements/test.txt + # anki # coreapi # edx-drf-extensions # edx-rest-api-client # openai + # requests # requests-oauthlib # requests-toolbelt # slumber @@ -369,6 +404,8 @@ rfc3986==2.0.0 # via twine rich==13.6.0 # via twine +secretstorage==3.3.3 + # via keyring semantic-version==2.10.0 # via # -r requirements/test.txt @@ -399,6 +436,10 @@ social-auth-core==4.4.2 # -r requirements/test.txt # edx-auth-backends # social-auth-app-django +soupsieve==2.5 + # via + # -r requirements/test.txt + # beautifulsoup4 sqlparse==0.4.4 # via # -r requirements/test.txt @@ -426,7 +467,7 @@ tomlkit==0.12.1 # pylint tox==3.28.0 # via - # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # -c requirements/common_constraints.txt # -r requirements/test.txt tqdm==4.66.1 # via @@ -441,7 +482,6 @@ typing-extensions==4.8.0 # astroid # edx-opaque-keys # pylint - # rich uritemplate==4.1.1 # via # -r requirements/test.txt @@ -451,7 +491,7 @@ urllib3==2.0.7 # -r requirements/test.txt # requests # twine -virtualenv==20.24.5 +virtualenv==20.24.6 # via # -r requirements/test.txt # tox @@ -461,5 +501,5 @@ yarl==1.9.2 # aiohttp zipp==3.17.0 # via + # -r requirements/test.txt # importlib-metadata - # importlib-resources diff --git a/requirements/test.txt b/requirements/test.txt index c295c16..3150a92 100644 --- a/requirements/test.txt +++ b/requirements/test.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.9 # by the following command: # # make upgrade @@ -12,6 +12,8 @@ aiosignal==1.3.1 # via # -r requirements/base.txt # aiohttp +anki==2.1.66 + # via -r requirements/base.txt asgiref==3.7.2 # via # -r requirements/base.txt @@ -28,6 +30,10 @@ attrs==23.1.0 # via # -r requirements/base.txt # aiohttp +beautifulsoup4==4.12.2 + # via + # -r requirements/base.txt + # anki certifi==2023.7.22 # via # -r requirements/base.txt @@ -73,6 +79,10 @@ cryptography==41.0.4 # -r requirements/base.txt # pyjwt # social-auth-core +decorator==5.1.1 + # via + # -r requirements/base.txt + # anki defusedxml==0.8.0rc2 # via # -r requirements/base.txt @@ -82,8 +92,11 @@ dill==0.3.7 # via pylint distlib==0.3.7 # via virtualenv +distro==1.8.0 + # via + # -r requirements/base.txt + # anki # via - # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt # -r requirements/base.txt # django-cors-headers # django-crum @@ -158,6 +171,10 @@ idna==3.4 # -r requirements/base.txt # requests # yarl +importlib-metadata==6.8.0 + # via + # -r requirements/base.txt + # markdown iniconfig==2.0.0 # via pytest isort==5.12.0 @@ -171,6 +188,10 @@ jinja2==3.1.2 # -r requirements/base.txt # code-annotations # coreschema +markdown==3.5 + # via + # -r requirements/base.txt + # anki markupsafe==2.1.3 # via # -r requirements/base.txt @@ -199,6 +220,10 @@ openapi-codec==1.3.2 # via # -r requirements/base.txt # django-rest-swagger +orjson==3.9.9 + # via + # -r requirements/base.txt + # anki packaging==23.2 # via # pytest @@ -215,6 +240,10 @@ pluggy==1.3.0 # via # pytest # tox +protobuf==4.24.4 + # via + # -r requirements/base.txt + # anki psutil==5.9.6 # via # -r requirements/base.txt @@ -256,6 +285,10 @@ pynacl==1.5.0 # via # -r requirements/base.txt # edx-django-utils +pysocks==1.7.1 + # via + # -r requirements/base.txt + # requests pytest==7.4.2 # via # pytest-cov @@ -273,20 +306,21 @@ python3-openid==3.2.0 pytz==2023.3.post1 # via # -r requirements/base.txt - # django # djangorestframework pyyaml==6.0.1 # via # -r requirements/base.txt # code-annotations # edx-django-release-util -requests==2.31.0 +requests[socks]==2.31.0 # via # -r requirements/base.txt + # anki # coreapi # edx-drf-extensions # edx-rest-api-client # openai + # requests # requests-oauthlib # slumber # social-auth-core @@ -322,6 +356,10 @@ social-auth-core==4.4.2 # -r requirements/base.txt # edx-auth-backends # social-auth-app-django +soupsieve==2.5 + # via + # -r requirements/base.txt + # beautifulsoup4 sqlparse==0.4.4 # via # -r requirements/base.txt @@ -344,7 +382,7 @@ tomlkit==0.12.1 # via pylint tox==3.28.0 # via - # -c https://raw.githubusercontent.com/edx/edx-lint/master/edx_lint/files/common_constraints.txt + # -c requirements/common_constraints.txt # -r requirements/test.in tqdm==4.66.1 # via @@ -365,9 +403,13 @@ urllib3==2.0.7 # via # -r requirements/base.txt # requests -virtualenv==20.24.5 +virtualenv==20.24.6 # via tox yarl==1.9.2 # via # -r requirements/base.txt # aiohttp +zipp==3.17.0 + # via + # -r requirements/base.txt + # importlib-metadata diff --git a/requirements/validation.txt b/requirements/validation.txt index 3738b2a..03c6ac3 100644 --- a/requirements/validation.txt +++ b/requirements/validation.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.9 # by the following command: # # make upgrade @@ -14,6 +14,10 @@ aiosignal==1.3.1 # -r requirements/quality.txt # -r requirements/test.txt # aiohttp +anki==2.1.66 + # via + # -r requirements/quality.txt + # -r requirements/test.txt asgiref==3.7.2 # via # -r requirements/quality.txt @@ -35,6 +39,11 @@ attrs==23.1.0 # -r requirements/quality.txt # -r requirements/test.txt # aiohttp +beautifulsoup4==4.12.2 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # anki certifi==2023.7.22 # via # -r requirements/quality.txt @@ -92,7 +101,13 @@ cryptography==41.0.4 # -r requirements/quality.txt # -r requirements/test.txt # pyjwt + # secretstorage # social-auth-core +decorator==5.1.1 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # anki defusedxml==0.8.0rc2 # via # -r requirements/quality.txt @@ -109,7 +124,12 @@ distlib==0.3.7 # -r requirements/quality.txt # -r requirements/test.txt # virtualenv -django==3.2.22 +distro==1.8.0 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # anki +django==4.2.6 # via # -r requirements/quality.txt # -r requirements/test.txt @@ -224,12 +244,10 @@ idna==3.4 importlib-metadata==6.8.0 # via # -r requirements/quality.txt + # -r requirements/test.txt # keyring + # markdown # twine -importlib-resources==6.1.0 - # via - # -r requirements/quality.txt - # keyring iniconfig==2.0.0 # via # -r requirements/quality.txt @@ -249,6 +267,11 @@ jaraco-classes==3.3.0 # via # -r requirements/quality.txt # keyring +jeepney==0.8.0 + # via + # -r requirements/quality.txt + # keyring + # secretstorage jinja2==3.1.2 # via # -r requirements/quality.txt @@ -259,6 +282,11 @@ keyring==24.2.0 # via # -r requirements/quality.txt # twine +markdown==3.5 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # anki markdown-it-py==3.0.0 # via # -r requirements/quality.txt @@ -315,6 +343,11 @@ openapi-codec==1.3.2 # -r requirements/quality.txt # -r requirements/test.txt # django-rest-swagger +orjson==3.9.9 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # anki packaging==23.2 # via # -r requirements/quality.txt @@ -342,6 +375,11 @@ pluggy==1.3.0 # -r requirements/test.txt # pytest # tox +protobuf==4.24.4 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # anki psutil==5.9.6 # via # -r requirements/quality.txt @@ -410,6 +448,11 @@ pynacl==1.5.0 # -r requirements/quality.txt # -r requirements/test.txt # edx-django-utils +pysocks==1.7.1 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # requests pytest==7.4.2 # via # -r requirements/quality.txt @@ -438,7 +481,6 @@ pytz==2023.3.post1 # via # -r requirements/quality.txt # -r requirements/test.txt - # django # djangorestframework pyyaml==6.0.1 # via @@ -450,14 +492,16 @@ readme-renderer==42.0 # via # -r requirements/quality.txt # twine -requests==2.31.0 +requests[socks]==2.31.0 # via # -r requirements/quality.txt # -r requirements/test.txt + # anki # coreapi # edx-drf-extensions # edx-rest-api-client # openai + # requests # requests-oauthlib # requests-toolbelt # slumber @@ -480,6 +524,10 @@ rich==13.6.0 # via # -r requirements/quality.txt # twine +secretstorage==3.3.3 + # via + # -r requirements/quality.txt + # keyring semantic-version==2.10.0 # via # -r requirements/quality.txt @@ -518,6 +566,11 @@ social-auth-core==4.4.2 # -r requirements/test.txt # edx-auth-backends # social-auth-app-django +soupsieve==2.5 + # via + # -r requirements/quality.txt + # -r requirements/test.txt + # beautifulsoup4 sqlparse==0.4.4 # via # -r requirements/quality.txt @@ -567,7 +620,6 @@ typing-extensions==4.8.0 # astroid # edx-opaque-keys # pylint - # rich uritemplate==4.1.1 # via # -r requirements/quality.txt @@ -579,7 +631,7 @@ urllib3==2.0.7 # -r requirements/test.txt # requests # twine -virtualenv==20.24.5 +virtualenv==20.24.6 # via # -r requirements/quality.txt # -r requirements/test.txt @@ -592,5 +644,5 @@ yarl==1.9.2 zipp==3.17.0 # via # -r requirements/quality.txt + # -r requirements/test.txt # importlib-metadata - # importlib-resources From 41fd2117aeb69d25e477bae9885aa3ccc7a1c9cb Mon Sep 17 00:00:00 2001 From: Jeremy Bowman Date: Tue, 24 Oct 2023 09:33:23 -0400 Subject: [PATCH 2/3] fix: Fix pycodestyle and pylint failures Correct assorted spacing issues and unused imports. --- flashcards/apps/core/tests/test_context_processors.py | 4 ++-- flashcards/apps/core/tests/test_models.py | 3 ++- flashcards/apps/core/tests/test_views.py | 1 + flashcards/utils.py | 11 +++++++---- requirements/dev.txt | 2 +- requirements/doc.txt | 2 +- requirements/quality.txt | 2 +- requirements/test.txt | 2 +- requirements/validation.txt | 2 +- 9 files changed, 17 insertions(+), 12 deletions(-) diff --git a/flashcards/apps/core/tests/test_context_processors.py b/flashcards/apps/core/tests/test_context_processors.py index 76fde48..a4a9035 100644 --- a/flashcards/apps/core/tests/test_context_processors.py +++ b/flashcards/apps/core/tests/test_context_processors.py @@ -2,7 +2,7 @@ from django.test import TestCase, override_settings -from flashcards.apps.core.context_processors import core +# from flashcards.apps.core.context_processors import core PLATFORM_NAME = 'Test Platform' @@ -12,6 +12,6 @@ class CoreContextProcessorTests(TestCase): @override_settings(PLATFORM_NAME=PLATFORM_NAME) def test_core(self): - return + return # request = RequestFactory().get('/') # self.assertDictEqual(core(request), {'platform_name': PLATFORM_NAME}) diff --git a/flashcards/apps/core/tests/test_models.py b/flashcards/apps/core/tests/test_models.py index 427505c..4281235 100644 --- a/flashcards/apps/core/tests/test_models.py +++ b/flashcards/apps/core/tests/test_models.py @@ -1,10 +1,11 @@ """ Tests for core models. """ from django.test import TestCase + # from django_dynamic_fixture import G # from social_django.models import UserSocialAuth -from flashcards.apps.core.models import User +# from flashcards.apps.core.models import User class UserTests(TestCase): diff --git a/flashcards/apps/core/tests/test_views.py b/flashcards/apps/core/tests/test_views.py index 665eaa1..e180298 100644 --- a/flashcards/apps/core/tests/test_views.py +++ b/flashcards/apps/core/tests/test_views.py @@ -6,6 +6,7 @@ from django.contrib.auth import get_user_model # from django.db import DatabaseError from django.test import TestCase + # from django.test.utils import override_settings # from django.urls import reverse diff --git a/flashcards/utils.py b/flashcards/utils.py index dd3533f..f4b912f 100644 --- a/flashcards/utils.py +++ b/flashcards/utils.py @@ -1,10 +1,13 @@ """ -Integration with openai to generate 'flashcards' in csv form +OpenAI integration utilities. + +Integration with OpenAI to generate 'flashcards' in csv form based on course content """ import openai -from flashcards.settings.private import OPENAI_API_KEY # pylint: disable=import-error,no-name-in-module + +from flashcards.settings.private import OPENAI_API_KEY # pylint: disable=import-error,no-name-in-module openai.api_key = OPENAI_API_KEY @@ -25,7 +28,7 @@ Lesson 5: Filamentous Fungi Lesson 6: Aged Meat and Cheese Lesson 7: Chocolate and Coffee -""" +""" # noqa course_content = """ ROBERTO KOLTER: While humans have been preparing and consuming @@ -169,7 +172,7 @@ Why can the Dead Sea keep swimmers afloat?,Due to high salt content Why is the Dead Sea called Dead?,Because only simple organisms can live in it Why only simple organisms can live in the Dead Sea?,Because of high salt content -""" +""" # noqa messages = [ {"role": "system", diff --git a/requirements/dev.txt b/requirements/dev.txt index 420c4fa..091dbef 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -177,7 +177,7 @@ edx-drf-extensions==8.12.0 # via -r requirements/validation.txt edx-i18n-tools==1.3.0 # via -r requirements/dev.in -edx-lint==5.3.4 +edx-lint==5.3.6 # via -r requirements/validation.txt edx-opaque-keys==2.5.1 # via diff --git a/requirements/doc.txt b/requirements/doc.txt index 82c43df..47594aa 100644 --- a/requirements/doc.txt +++ b/requirements/doc.txt @@ -177,7 +177,7 @@ edx-django-utils==5.7.0 # edx-rest-api-client edx-drf-extensions==8.12.0 # via -r requirements/test.txt -edx-lint==5.3.4 +edx-lint==5.3.6 # via -r requirements/test.txt edx-opaque-keys==2.5.1 # via diff --git a/requirements/quality.txt b/requirements/quality.txt index bcb676c..8dfbaf2 100644 --- a/requirements/quality.txt +++ b/requirements/quality.txt @@ -159,7 +159,7 @@ edx-django-utils==5.7.0 # edx-rest-api-client edx-drf-extensions==8.12.0 # via -r requirements/test.txt -edx-lint==5.3.4 +edx-lint==5.3.6 # via # -r requirements/quality.in # -r requirements/test.txt diff --git a/requirements/test.txt b/requirements/test.txt index 3150a92..45840fe 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -147,7 +147,7 @@ edx-django-utils==5.7.0 # edx-rest-api-client edx-drf-extensions==8.12.0 # via -r requirements/base.txt -edx-lint==5.3.4 +edx-lint==5.3.6 # via -r requirements/test.in edx-opaque-keys==2.5.1 # via diff --git a/requirements/validation.txt b/requirements/validation.txt index 03c6ac3..005a49a 100644 --- a/requirements/validation.txt +++ b/requirements/validation.txt @@ -205,7 +205,7 @@ edx-drf-extensions==8.12.0 # via # -r requirements/quality.txt # -r requirements/test.txt -edx-lint==5.3.4 +edx-lint==5.3.6 # via # -r requirements/quality.txt # -r requirements/test.txt From de1cc693672bd18fa8ae52c3c815c5308e586195 Mon Sep 17 00:00:00 2001 From: Jeremy Bowman Date: Tue, 24 Oct 2023 10:01:28 -0400 Subject: [PATCH 3/3] fix: Fix documentation builds Resolve import and setup issues that were causing doc builds to fail. --- docs/conf.py | 8 ++++++++ flashcards/settings/base.py | 3 +++ flashcards/utils.py | 36 +++++++++++++++++------------------- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 026cc5f..e8c6783 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -39,6 +39,14 @@ def get_version(*file_paths): VERSION = get_version('../flashcards', '__init__.py') +# Specify settings module (which will be picked up from the sandbox) +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'flashcards.settings.test') + +import django + + +django.setup() + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. diff --git a/flashcards/settings/base.py b/flashcards/settings/base.py index c12ec6f..cd4bddb 100644 --- a/flashcards/settings/base.py +++ b/flashcards/settings/base.py @@ -241,3 +241,6 @@ def root(*path_fragments): # Set up logging for development use (logging to stdout) LOGGING = get_logger_config(debug=DEBUG) + +# OpenAI API key, to be specified in the private settings file +OPENAI_API_KEY = '' diff --git a/flashcards/utils.py b/flashcards/utils.py index f4b912f..82f2722 100644 --- a/flashcards/utils.py +++ b/flashcards/utils.py @@ -6,10 +6,9 @@ """ import openai +from django.conf import settings -from flashcards.settings.private import OPENAI_API_KEY # pylint: disable=import-error,no-name-in-module - -openai.api_key = OPENAI_API_KEY +openai.api_key = settings.OPENAI_API_KEY content_prompt = """ @@ -181,19 +180,18 @@ "content": content_prompt + course_content}, ] - -c3 = openai.ChatCompletion.create( - model="gpt-3.5-turbo", - messages=messages, - temperature=1.0, -) - -print(c3['choices'][0]['message']['content']) - -# c4 = openai.ChatCompletion.create( -# model="gpt-4", -# messages=messages, -# temperature=1.0, -# ) - -# print(c4) +if openai.api_key: + c3 = openai.ChatCompletion.create( + model="gpt-3.5-turbo", + messages=messages, + temperature=1.0, + ) + print(c3['choices'][0]['message']['content']) + + # c4 = openai.ChatCompletion.create( + # model="gpt-4", + # messages=messages, + # temperature=1.0, + # ) + + # print(c4)