feat: upgrade to Palm

This commit is contained in:
Jhony Avella 2023-06-14 18:03:44 -05:00 committed by GitHub
parent 2da25c576c
commit 702e029d55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 54 additions and 25 deletions

View File

@ -2,7 +2,7 @@ variables:
TUTOR_PLUGIN: notes TUTOR_PLUGIN: notes
TUTOR_IMAGES: notes TUTOR_IMAGES: notes
TUTOR_PYPI_PACKAGE: tutor-notes TUTOR_PYPI_PACKAGE: tutor-notes
OPENEDX_RELEASE: olive OPENEDX_RELEASE: palm
GITHUB_REPO: overhangio/tutor-notes GITHUB_REPO: overhangio/tutor-notes
include: include:

View File

@ -1,9 +1,9 @@
Students notes plugin for `Tutor <https://docs.tutor.overhang.io>`_ Students notes plugin for `Tutor <https://docs.tutor.overhang.io>`_
=================================================================== ===================================================================
This is a plugin for `Tutor <https://docs.tutor.overhang.io>`_ to easily add the `Open edX note-taking app <https://github.com/openedx/edx-notes-api>`_ to an Open edX platform. This app allows students to annotate portions of the courseware (see `the official documentation <https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/open-release-olive.master/exercises_tools/notes.html>`_). This is a plugin for `Tutor <https://docs.tutor.overhang.io>`_ to easily add the `Open edX note-taking app <https://github.com/openedx/edx-notes-api>`_ to an Open edX platform. This app allows students to annotate portions of the courseware (see `the official documentation <https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/open-release-palm.master/exercises_tools/notes.html>`_).
.. image:: https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/open-release-olive.master/_images/SFD_SN_bodyexample.png .. image:: https://edx.readthedocs.io/projects/open-edx-building-and-running-a-course/en/open-release-palm.master/_images/SFD_SN_bodyexample.png
:alt: Notes in action :alt: Notes in action
Installation Installation

View File

@ -31,8 +31,8 @@ setup(
long_description=readme, long_description=readme,
packages=find_packages(exclude=["tests*"]), packages=find_packages(exclude=["tests*"]),
include_package_data=True, include_package_data=True,
python_requires=">=3.7", python_requires=">=3.8",
install_requires=["tutor>=15.0.0,<16.0.0"], install_requires=["tutor>=16.0.0,<17.0.0"],
entry_points={"tutor.plugin.v1": ["notes = tutornotes.plugin"]}, entry_points={"tutor.plugin.v1": ["notes = tutornotes.plugin"]},
classifiers=[ classifiers=[
"Development Status :: 5 - Production/Stable", "Development Status :: 5 - Production/Stable",
@ -40,9 +40,9 @@ setup(
"License :: OSI Approved :: GNU Affero General Public License v3", "License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent", "Operating System :: OS Independent",
"Programming Language :: Python", "Programming Language :: Python",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
], ],
) )

View File

@ -1,4 +1,4 @@
__version__ = "15.0.4" __version__ = "16.0.0"
# Handle version suffix for nightly, just like tutor core. # Handle version suffix for nightly, just like tutor core.
__version_suffix__ = "" __version_suffix__ = ""

View File

@ -1,5 +1,8 @@
from __future__ import annotations
from glob import glob from glob import glob
import os import os
import typing as t
import pkg_resources import pkg_resources
@ -7,7 +10,6 @@ from tutor import hooks as tutor_hooks
from .__about__ import __version__ from .__about__ import __version__
config = { config = {
"unique": { "unique": {
"MYSQL_PASSWORD": "{{ 8|random_string }}", "MYSQL_PASSWORD": "{{ 8|random_string }}",
@ -26,18 +28,27 @@ config = {
} }
# Initialization hooks # Initialization hooks
tutor_hooks.Filters.COMMANDS_INIT.add_item((
"mysql", # To add a custom initialization task, create a bash script template under:
("notes", "tasks", "mysql", "init"), # tutorcodejail/templates/codejail/tasks/
)) # and then add it to the MY_INIT_TASKS list. Each task is in the format:
tutor_hooks.Filters.COMMANDS_INIT.add_item(( # ("<service>", ("<path>", "<to>", "<script>", "<template>"))
"lms", MY_INIT_TASKS: list[tuple[str, tuple[str, ...]]] = [
("notes", "tasks", "lms", "init"), ("mysql", ("notes", "tasks", "mysql", "init")),
)) ("lms", ("notes", "tasks", "lms", "init")),
tutor_hooks.Filters.COMMANDS_INIT.add_item(( ("notes", ("notes", "tasks", "notes", "init")),
"notes", ]
("notes", "tasks", "notes", "init"),
)) # For each task added to MY_INIT_TASKS, we load the task template
# and add it to the CLI_DO_INIT_TASKS filter, which tells Tutor to
# run it as part of the `init` job.
for service, template_path in MY_INIT_TASKS:
full_path: str = pkg_resources.resource_filename(
"tutornotes", os.path.join("templates", *template_path)
)
with open(full_path, encoding="utf-8") as init_task_file:
init_task: str = init_task_file.read()
tutor_hooks.Filters.CLI_DO_INIT_TASKS.add_item((service, init_task))
# Image management # Image management
tutor_hooks.Filters.IMAGES_BUILD.add_item(( tutor_hooks.Filters.IMAGES_BUILD.add_item((
@ -89,7 +100,9 @@ for path in glob(
) )
): ):
with open(path, encoding="utf-8") as patch_file: with open(path, encoding="utf-8") as patch_file:
tutor_hooks.Filters.ENV_PATCHES.add_item((os.path.basename(path), patch_file.read())) tutor_hooks.Filters.ENV_PATCHES.add_item(
(os.path.basename(path), patch_file.read())
)
# Add configuration entries # Add configuration entries
tutor_hooks.Filters.CONFIG_DEFAULTS.add_items( tutor_hooks.Filters.CONFIG_DEFAULTS.add_items(
[ [
@ -103,4 +116,15 @@ tutor_hooks.Filters.CONFIG_UNIQUE.add_items(
for key, value in config.get("unique", {}).items() for key, value in config.get("unique", {}).items()
] ]
) )
tutor_hooks.Filters.CONFIG_OVERRIDES.add_items(list(config.get("overrides", {}).items())) tutor_hooks.Filters.CONFIG_OVERRIDES.add_items(
list(config.get("overrides", {}).items())
)
# Notes public hosts
@tutor_hooks.Filters.APP_PUBLIC_HOSTS.add()
def _notes_public_hosts(hosts: list[str], context_name: t.Literal["local", "dev"]) -> list[str]:
if context_name == "dev":
hosts += ["{{ NOTES_HOST }}:8120"]
else:
hosts += ["{{ NOTES_HOST }}"]
return hosts

View File

@ -1,11 +1,15 @@
{% if is_buildkit_enabled() %}# syntax=docker/dockerfile:1.4{% endif %}
FROM docker.io/ubuntu:20.04 FROM docker.io/ubuntu:20.04
RUN apt update && \ RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked{% endif %} \
apt update && \
apt upgrade -y && \ apt upgrade -y && \
# python 3.8 # python 3.8
apt install -y language-pack-en git python3 python3-pip python3-venv libmysqlclient-dev apt install -y language-pack-en git python3 python3-pip python3-venv libmysqlclient-dev
RUN ln -s /usr/bin/python3 /usr/bin/python RUN ln -s /usr/bin/python3 /usr/bin/python
###### Git-clone Notes repo ######
ARG APP_USER_ID=1000 ARG APP_USER_ID=1000
RUN useradd --home-dir /app --create-home --shell /bin/bash --uid ${APP_USER_ID} app RUN useradd --home-dir /app --create-home --shell /bin/bash --uid ${APP_USER_ID} app
USER ${APP_USER_ID} USER ${APP_USER_ID}
@ -13,13 +17,14 @@ USER ${APP_USER_ID}
RUN git clone {{ NOTES_REPOSITORY }} --branch {{ NOTES_REPOSITORY_VERSION }} --depth 1 /app/edx-notes-api RUN git clone {{ NOTES_REPOSITORY }} --branch {{ NOTES_REPOSITORY_VERSION }} --depth 1 /app/edx-notes-api
WORKDIR /app/edx-notes-api WORKDIR /app/edx-notes-api
###### Install python venv ######
RUN python -m venv /app/venv RUN python -m venv /app/venv
ENV PATH /app/venv/bin:${PATH} ENV PATH /app/venv/bin:${PATH}
# https://pypi.org/project/setuptools/ # https://pypi.org/project/setuptools/
# https://pypi.org/project/pip/ # https://pypi.org/project/pip/
# https://pypi.org/project/wheel/ # https://pypi.org/project/wheel/
RUN pip install setuptools==65.5.1 pip==22.3.1 wheel==0.38.4 RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/app/.cache/pip,sharing=shared {% endif %}pip install setuptools==67.8.0 pip==23.1.2 wheel==0.40.0
RUN pip install -r requirements/base.txt RUN {% if is_buildkit_enabled() %}--mount=type=cache,target=/app/.cache/pip,sharing=shared {% endif %}pip install -r requirements/base.txt
EXPOSE 8000 EXPOSE 8000
CMD gunicorn --workers=2 --name notes --bind=0.0.0.0:8000 --max-requests=1000 notesserver.wsgi:application CMD gunicorn --workers=2 --name notes --bind=0.0.0.0:8000 --max-requests=1000 notesserver.wsgi:application