From 4a145f956b584f27d8150bbad54bf0cac1d86e3b Mon Sep 17 00:00:00 2001 From: David Ormsbee <dave@axim.org> Date: Fri, 17 May 2024 10:06:04 -0400 Subject: [PATCH] feat!: remove blockstore support + 0.3.0 version bump (#24) Blockstore was completely removed from edx-platform in: https://github.com/openedx/edx-platform/pull/34739 As a follow-on to that work, this commit removes the entirety of two blockstore-related plugins (tutor-contrib-blockstore-filesystem and tutor-contrib-blockstore-minio), as well most blockstore references present in tutor-contrib-library-authoring-mfe. The BLOCKSTORE_COLLECTION_UUID configuration value was left in place because it's expected by the Library Authoring MFE and currently required by the Django view that creates Libraries (even though the value is never used). We will remove those references in a later PR. --- README.rst | 4 +- .../.gitignore | 7 - .../MANIFEST.in | 2 - .../Makefile | 28 --- .../README.rst | 22 -- .../blockstore_config_filesystem/__about__.py | 1 - .../blockstore_config_filesystem/__init__.py | 0 .../patches/.gitignore | 0 .../patches/openedx-cms-common-settings | 7 - .../blockstore_config_filesystem/plugin.py | 233 ------------------ .../apps/.gitignore | 0 .../build/.gitignore | 0 .../jobs/init/.gitignore | 0 .../jobs/init/cms.sh | 5 - .../setup.py | 60 ----- .../tutor-contrib-blockstore-minio/.gitignore | 7 - .../MANIFEST.in | 2 - .../tutor-contrib-blockstore-minio/Makefile | 28 --- .../tutor-contrib-blockstore-minio/README.rst | 20 -- .../blockstore_config_minio/__about__.py | 1 - .../blockstore_config_minio/__init__.py | 0 .../patches/.gitignore | 0 .../patches/openedx-cms-common-settings | 3 - .../blockstore_config_minio/plugin.py | 233 ------------------ .../blockstore_config_minio/apps/.gitignore | 0 .../blockstore_config_minio/build/.gitignore | 0 .../jobs/init/.gitignore | 0 .../blockstore_config_minio/jobs/init/cms.sh | 5 - .../tutor-contrib-blockstore-minio/setup.py | 60 ----- .../README.rst | 16 +- .../tutor_library_authoring_mfe/__about__.py | 2 +- .../patches/openedx-lms-common-settings | 2 +- .../tutor_library_authoring_mfe/plugin.py | 5 + .../library_authoring_mfe/jobs/init/cms.sh | 4 - 34 files changed, 9 insertions(+), 748 deletions(-) delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/.gitignore delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/MANIFEST.in delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/Makefile delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/README.rst delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/__about__.py delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/__init__.py delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/patches/.gitignore delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/patches/openedx-cms-common-settings delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/plugin.py delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/apps/.gitignore delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/build/.gitignore delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/jobs/init/.gitignore delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/jobs/init/cms.sh delete mode 100644 plugins/tutor-contrib-blockstore-filesystem/setup.py delete mode 100644 plugins/tutor-contrib-blockstore-minio/.gitignore delete mode 100644 plugins/tutor-contrib-blockstore-minio/MANIFEST.in delete mode 100644 plugins/tutor-contrib-blockstore-minio/Makefile delete mode 100644 plugins/tutor-contrib-blockstore-minio/README.rst delete mode 100644 plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/__about__.py delete mode 100644 plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/__init__.py delete mode 100644 plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/patches/.gitignore delete mode 100644 plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/patches/openedx-cms-common-settings delete mode 100644 plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/plugin.py delete mode 100644 plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/apps/.gitignore delete mode 100644 plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/build/.gitignore delete mode 100644 plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/jobs/init/.gitignore delete mode 100644 plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/jobs/init/cms.sh delete mode 100644 plugins/tutor-contrib-blockstore-minio/setup.py diff --git a/README.rst b/README.rst index 7c15286..2540cd2 100644 --- a/README.rst +++ b/README.rst @@ -20,8 +20,6 @@ Plugin Status (*Experimental*, *Production*, or *D =================================== ====================================================== tutor-contrib-learner-dashboard-mfe Deprecated tutor-contrib-library-authoring-mfe Experimental -tutor-contrib-blockstore-filesystem Experimental -tutor-contrib-blockstore-minio Experimental =================================== ====================================================== Getting Started @@ -31,7 +29,7 @@ Generally, assuming `Tutor is installed`_, to add a plugin in this repository to your deployment environment you would: .. code:: bash - + git clone git@github.com:openedx/openedx-tutor-plugins cd openedx-tutor-plugins/plugins/<plugin-name> pip install -e . diff --git a/plugins/tutor-contrib-blockstore-filesystem/.gitignore b/plugins/tutor-contrib-blockstore-filesystem/.gitignore deleted file mode 100644 index f6a874f..0000000 --- a/plugins/tutor-contrib-blockstore-filesystem/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.*.swp -!.gitignore -TODO -__pycache__ -*.egg-info/ -/build/ -/dist/ diff --git a/plugins/tutor-contrib-blockstore-filesystem/MANIFEST.in b/plugins/tutor-contrib-blockstore-filesystem/MANIFEST.in deleted file mode 100644 index eefdcb4..0000000 --- a/plugins/tutor-contrib-blockstore-filesystem/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include blockstore_config_filesystem/patches * -recursive-include blockstore_config_filesystem/templates * diff --git a/plugins/tutor-contrib-blockstore-filesystem/Makefile b/plugins/tutor-contrib-blockstore-filesystem/Makefile deleted file mode 100644 index 05fedbd..0000000 --- a/plugins/tutor-contrib-blockstore-filesystem/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: docs -SRC_DIRS = ./blockstore_config_filesystem -BLACK_OPTS = --exclude templates ${SRC_DIRS} - -# Warning: These checks are not necessarily run on every PR. -test: test-lint test-types test-format # Run some static checks. - -test-format: ## Run code formatting tests - black --check --diff $(BLACK_OPTS) - -test-lint: ## Run code linting tests - pylint --errors-only --enable=unused-import,unused-argument --ignore=templates --ignore=docs/_ext ${SRC_DIRS} - -test-types: ## Run type checks. - mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ${SRC_DIRS} - -format: ## Format code automatically - black $(BLACK_OPTS) - -isort: ## Sort imports. This target is not mandatory because the output may be incompatible with black formatting. Provided for convenience purposes. - isort --skip=templates ${SRC_DIRS} - -ESCAPE = -help: ## Print this help - @grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \ - | sed 's/######* \(.*\)/@ $(ESCAPE)[1;31m\1$(ESCAPE)[0m/g' | tr '@' '\n' \ - | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/plugins/tutor-contrib-blockstore-filesystem/README.rst b/plugins/tutor-contrib-blockstore-filesystem/README.rst deleted file mode 100644 index decf42d..0000000 --- a/plugins/tutor-contrib-blockstore-filesystem/README.rst +++ /dev/null @@ -1,22 +0,0 @@ -blockstore :code:`FileSystemStorage` configuration plugin for `Tutor <https://docs.tutor.overhang.io>`__ -=================================================================================== - -Installation ------------- - -:: - - pip install git+https://github.com/openedx/openedx-tutor-plugins#subdirectory=plugins/tutor-contrib-blockstore-filesystem - -Usage ------ - -:: - - tutor plugins enable blockstore-filesystem - - -License -------- - -This software is licensed under the terms of the AGPLv3. diff --git a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/__about__.py b/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/__about__.py deleted file mode 100644 index d3ec452..0000000 --- a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/__about__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "0.2.0" diff --git a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/__init__.py b/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/patches/.gitignore b/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/patches/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/patches/openedx-cms-common-settings b/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/patches/openedx-cms-common-settings deleted file mode 100644 index b8a7030..0000000 --- a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/patches/openedx-cms-common-settings +++ /dev/null @@ -1,7 +0,0 @@ -BUNDLE_ASSET_STORAGE_SETTINGS = { - "STORAGE_CLASS": "django.core.files.storage.FileSystemStorage", - "STORAGE_KWARGS": { - "location": f"{MEDIA_ROOT}blockstore/", - "base_url": f"http://cms:8000{MEDIA_URL}blockstore/", - }, -} diff --git a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/plugin.py b/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/plugin.py deleted file mode 100644 index 4426942..0000000 --- a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/plugin.py +++ /dev/null @@ -1,233 +0,0 @@ -from __future__ import annotations - -import os -import os.path -from glob import glob - -import click -import pkg_resources -from tutor import hooks - -from .__about__ import __version__ - -######################################## -# CONFIGURATION -######################################## - -hooks.Filters.CONFIG_DEFAULTS.add_items( - [ - # Add your new settings that have default values here. - # Each new setting is a pair: (setting_name, default_value). - # Prefix your setting names with 'BLOCKSTORE_'. - ("BLOCKSTORE_VERSION", __version__), - ] -) - -hooks.Filters.CONFIG_UNIQUE.add_items( - [ - # Add settings that don't have a reasonable default for all users here. - # For instance: passwords, secret keys, etc. - # Each new setting is a pair: (setting_name, unique_generated_value). - # Prefix your setting names with 'BLOCKSTORE_'. - # For example: - ### ("BLOCKSTORE_SECRET_KEY", "{{ 24|random_string }}"), - ] -) - -hooks.Filters.CONFIG_OVERRIDES.add_items( - [ - # Danger zone! - # Add values to override settings from Tutor core or other plugins here. - # Each override is a pair: (setting_name, new_value). For example: - ### ("PLATFORM_NAME", "My platform"), - ] -) - - -######################################## -# INITIALIZATION TASKS -######################################## - -# To add a custom initialization task, create a bash script template under: -# blockstore_config_filesystem/templates/blockstore/jobs/init/ -# and then add it to the MY_INIT_TASKS list. Each task is in the format: -# ("<service>", ("<path>", "<to>", "<script>", "<template>")) -MY_INIT_TASKS: list[tuple[str, tuple[str, ...]]] = [ - # For example, to add LMS initialization steps, you could add the script template at: - # blockstore_config_filesystem/templates/blockstore/jobs/init/lms.sh - # And then add the line: - ("cms", ("blockstore_config_filesystem", "jobs", "init", "cms.sh")), -] - - -# 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( - "blockstore_config_filesystem", os.path.join("templates", *template_path) - ) - with open(full_path, encoding="utf-8") as init_task_file: - init_task: str = init_task_file.read() - hooks.Filters.CLI_DO_INIT_TASKS.add_item((service, init_task)) - - -######################################## -# DOCKER IMAGE MANAGEMENT -######################################## - - -# Images to be built by `tutor images build`. -# Each item is a quadruple in the form: -# ("<tutor_image_name>", ("path", "to", "build", "dir"), "<docker_image_tag>", "<build_args>") -hooks.Filters.IMAGES_BUILD.add_items( - [ - # To build `myimage` with `tutor images build myimage`, - # you would add a Dockerfile to templates/blockstore/build/myimage, - # and then write: - ### ( - ### "myimage", - ### ("plugins", "blockstore", "build", "myimage"), - ### "docker.io/myimage:{{ BLOCKSTORE_VERSION }}", - ### (), - ### ), - ] -) - - -# Images to be pulled as part of `tutor images pull`. -# Each item is a pair in the form: -# ("<tutor_image_name>", "<docker_image_tag>") -hooks.Filters.IMAGES_PULL.add_items( - [ - # To pull `myimage` with `tutor images pull myimage`, you would write: - ### ( - ### "myimage", - ### "docker.io/myimage:{{ BLOCKSTORE_VERSION }}", - ### ), - ] -) - - -# Images to be pushed as part of `tutor images push`. -# Each item is a pair in the form: -# ("<tutor_image_name>", "<docker_image_tag>") -hooks.Filters.IMAGES_PUSH.add_items( - [ - # To push `myimage` with `tutor images push myimage`, you would write: - ### ( - ### "myimage", - ### "docker.io/myimage:{{ BLOCKSTORE_VERSION }}", - ### ), - ] -) - - -######################################## -# TEMPLATE RENDERING -# (It is safe & recommended to leave -# this section as-is :) -######################################## - -hooks.Filters.ENV_TEMPLATE_ROOTS.add_items( - # Root paths for template files, relative to the project root. - [ - pkg_resources.resource_filename("blockstore_config_filesystem", "templates"), - ] -) - -hooks.Filters.ENV_TEMPLATE_TARGETS.add_items( - # For each pair (source_path, destination_path): - # templates at ``source_path`` (relative to your ENV_TEMPLATE_ROOTS) will be - # rendered to ``source_path/destination_path`` (relative to your Tutor environment). - # For example, ``blockstore_config_filesystem/templates/blockstore_config_filesystem/build`` - # will be rendered to ``$(tutor config printroot)/env/plugins/blockstore_config_filesystem/build``. - [ - ("blockstore_config_filesystem/build", "plugins"), - ("blockstore_config_filesystem/apps", "plugins"), - ], -) - - -######################################## -# PATCH LOADING -# (It is safe & recommended to leave -# this section as-is :) -######################################## - -# For each file in blockstore_config_filesystem/patches, -# apply a patch based on the file's name and contents. -for path in glob( - os.path.join( - pkg_resources.resource_filename("blockstore_config_filesystem", "patches"), - "*", - ) -): - with open(path, encoding="utf-8") as patch_file: - hooks.Filters.ENV_PATCHES.add_item((os.path.basename(path), patch_file.read())) - - -######################################## -# CUSTOM JOBS (a.k.a. "do-commands") -######################################## - -# A job is a set of tasks, each of which run inside a certain container. -# Jobs are invoked using the `do` command, for example: `tutor local do importdemocourse`. -# A few jobs are built in to Tutor, such as `init` and `createuser`. -# You can also add your own custom jobs: - -# To add a custom job, define a Click command that returns a list of tasks, -# where each task is a pair in the form ("<service>", "<shell_command>"). -# For example: -### @click.command() -### @click.option("-n", "--name", default="plugin developer") -### def say_hi(name: str) -> list[tuple[str, str]]: -### """ -### An example job that just prints 'hello' from within both LMS and CMS. -### """ -### return [ -### ("lms", f"echo 'Hello from LMS, {name}!'"), -### ("cms", f"echo 'Hello from CMS, {name}!'"), -### ] - - -# Then, add the command function to CLI_DO_COMMANDS: -## hooks.Filters.CLI_DO_COMMANDS.add_item(say_hi) - -# Now, you can run your job like this: -# $ tutor local do say-hi --name="Brian Smith" - - -####################################### -# CUSTOM CLI COMMANDS -####################################### - -# Your plugin can also add custom commands directly to the Tutor CLI. -# These commands are run directly on the user's host computer -# (unlike jobs, which are run in containers). - -# To define a command group for your plugin, you would define a Click -# group and then add it to CLI_COMMANDS: - - -### @click.group() -### def blockstore() -> None: -### pass -### -### -### hooks.Filters.CLI_COMMANDS.add_item(blockstore) - - -# Then, you would add subcommands directly to the Click group, for example: - - -### @blockstore.command() -### def example_command() -> None: -### """ -### This is helptext for an example command. -### """ -### print("You've run an example command.") - - -# This would allow you to run: -# $ tutor blockstore example-command diff --git a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/apps/.gitignore b/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/apps/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/build/.gitignore b/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/build/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/jobs/init/.gitignore b/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/jobs/init/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/jobs/init/cms.sh b/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/jobs/init/cms.sh deleted file mode 100644 index b477e83..0000000 --- a/plugins/tutor-contrib-blockstore-filesystem/blockstore_config_filesystem/templates/blockstore_config_filesystem/jobs/init/cms.sh +++ /dev/null @@ -1,5 +0,0 @@ -# Adapted from https://github.com/openedx/frontend-app-library-authoring/blob/26ea285dc2b5f0c32c6f1a9017a45c6add03f8d7/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/templates/library_authoring_mfe/tasks/cms/init -# -# Create waffle switches to enable the Blockstore app that's now built into -# edx-platform, rather than requiring it to be installed and enabled separately. -(./manage.py cms waffle_switch --list | grep blockstore.use_blockstore_app_api) || ./manage.py lms waffle_switch --create blockstore.use_blockstore_app_api on diff --git a/plugins/tutor-contrib-blockstore-filesystem/setup.py b/plugins/tutor-contrib-blockstore-filesystem/setup.py deleted file mode 100644 index 23809df..0000000 --- a/plugins/tutor-contrib-blockstore-filesystem/setup.py +++ /dev/null @@ -1,60 +0,0 @@ -import io -import os -from setuptools import setup, find_packages - -HERE = os.path.abspath(os.path.dirname(__file__)) - - -def load_readme(): - with io.open(os.path.join(HERE, "README.rst"), "rt", encoding="utf8") as f: - return f.read() - - -def load_about(): - about = {} - with io.open( - os.path.join(HERE, "blockstore_config_filesystem", "__about__.py"), - "rt", - encoding="utf-8", - ) as f: - exec(f.read(), about) # pylint: disable=exec-used - return about - - -ABOUT = load_about() - - -setup( - name="tutor-contrib-blockstore-filesystem", - version=ABOUT["__version__"], - url="https://github.com/openedx/openedx-tutor-plugins", - project_urls={ - "Code": "https://github.com/openedx/openedx-tutor-plugins", - "Issue tracker": "https://github.com/openedx/openedx-tutor-plugins/issues", - }, - license="AGPLv3", - author="Brian Smith", - description="blockstore FileSystemStorage configuration plugin for Tutor", - long_description=load_readme(), - packages=find_packages(exclude=["tests*"]), - include_package_data=True, - python_requires=">=3.8", - install_requires=["tutor>=17.0.0,<18.0.0"], - extras_require={"dev": ["tutor[dev]>=17.0.0,<18.0.0"]}, - entry_points={ - "tutor.plugin.v1": [ - "blockstore-filesystem = blockstore_config_filesystem.plugin" - ] - }, - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU Affero General Public License v3", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - ], -) diff --git a/plugins/tutor-contrib-blockstore-minio/.gitignore b/plugins/tutor-contrib-blockstore-minio/.gitignore deleted file mode 100644 index f6a874f..0000000 --- a/plugins/tutor-contrib-blockstore-minio/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -.*.swp -!.gitignore -TODO -__pycache__ -*.egg-info/ -/build/ -/dist/ diff --git a/plugins/tutor-contrib-blockstore-minio/MANIFEST.in b/plugins/tutor-contrib-blockstore-minio/MANIFEST.in deleted file mode 100644 index fe38053..0000000 --- a/plugins/tutor-contrib-blockstore-minio/MANIFEST.in +++ /dev/null @@ -1,2 +0,0 @@ -recursive-include blockstore_config_minio/patches * -recursive-include blockstore_config_minio/templates * diff --git a/plugins/tutor-contrib-blockstore-minio/Makefile b/plugins/tutor-contrib-blockstore-minio/Makefile deleted file mode 100644 index 439592c..0000000 --- a/plugins/tutor-contrib-blockstore-minio/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -.DEFAULT_GOAL := help -.PHONY: docs -SRC_DIRS = ./blockstore_config_minio -BLACK_OPTS = --exclude templates ${SRC_DIRS} - -# Warning: These checks are not necessarily run on every PR. -test: test-lint test-types test-format # Run some static checks. - -test-format: ## Run code formatting tests - black --check --diff $(BLACK_OPTS) - -test-lint: ## Run code linting tests - pylint --errors-only --enable=unused-import,unused-argument --ignore=templates --ignore=docs/_ext ${SRC_DIRS} - -test-types: ## Run type checks. - mypy --exclude=templates --ignore-missing-imports --implicit-reexport --strict ${SRC_DIRS} - -format: ## Format code automatically - black $(BLACK_OPTS) - -isort: ## Sort imports. This target is not mandatory because the output may be incompatible with black formatting. Provided for convenience purposes. - isort --skip=templates ${SRC_DIRS} - -ESCAPE = -help: ## Print this help - @grep -E '^([a-zA-Z_-]+:.*?## .*|######* .+)$$' Makefile \ - | sed 's/######* \(.*\)/@ $(ESCAPE)[1;31m\1$(ESCAPE)[0m/g' | tr '@' '\n' \ - | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[33m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/plugins/tutor-contrib-blockstore-minio/README.rst b/plugins/tutor-contrib-blockstore-minio/README.rst deleted file mode 100644 index d178a4e..0000000 --- a/plugins/tutor-contrib-blockstore-minio/README.rst +++ /dev/null @@ -1,20 +0,0 @@ -blockstore `minio <https://min.io/>`__ configuration plugin for `Tutor <https://docs.tutor.overhang.io>`__ -=================================================================================== - -Installation ------------- - -:: - - pip install git+https://github.com/openedx/openedx-tutor-plugins#subdirectory=plugins/tutor-contrib-blockstore-minio - -Usage ------ - -:: - - tutor plugins enable blockstore-minio -License -------- - -This software is licensed under the terms of the AGPLv3. diff --git a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/__about__.py b/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/__about__.py deleted file mode 100644 index d3ec452..0000000 --- a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/__about__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "0.2.0" diff --git a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/__init__.py b/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/patches/.gitignore b/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/patches/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/patches/openedx-cms-common-settings b/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/patches/openedx-cms-common-settings deleted file mode 100644 index 23213dd..0000000 --- a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/patches/openedx-cms-common-settings +++ /dev/null @@ -1,3 +0,0 @@ -BUNDLE_ASSET_URL_STORAGE_KEY="{{ OPENEDX_AWS_ACCESS_KEY }}" -BUNDLE_ASSET_URL_STORAGE_SECRET="{{ OPENEDX_AWS_SECRET_ACCESS_KEY }}" -BUNDLE_ASSET_STORAGE_SETTINGS = dict(STORAGE_CLASS="storages.backends.s3boto3.S3Boto3Storage", STORAGE_KWARGS=dict(bucket_name="blockstore", location="library/")) \ No newline at end of file diff --git a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/plugin.py b/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/plugin.py deleted file mode 100644 index 42aeb7f..0000000 --- a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/plugin.py +++ /dev/null @@ -1,233 +0,0 @@ -from __future__ import annotations - -import os -import os.path -from glob import glob - -import click -import pkg_resources -from tutor import hooks - -from .__about__ import __version__ - -######################################## -# CONFIGURATION -######################################## - -hooks.Filters.CONFIG_DEFAULTS.add_items( - [ - # Add your new settings that have default values here. - # Each new setting is a pair: (setting_name, default_value). - # Prefix your setting names with 'BLOCKSTORE_'. - ("BLOCKSTORE_VERSION", __version__), - ] -) - -hooks.Filters.CONFIG_UNIQUE.add_items( - [ - # Add settings that don't have a reasonable default for all users here. - # For instance: passwords, secret keys, etc. - # Each new setting is a pair: (setting_name, unique_generated_value). - # Prefix your setting names with 'BLOCKSTORE_'. - # For example: - ### ("BLOCKSTORE_SECRET_KEY", "{{ 24|random_string }}"), - ] -) - -hooks.Filters.CONFIG_OVERRIDES.add_items( - [ - # Danger zone! - # Add values to override settings from Tutor core or other plugins here. - # Each override is a pair: (setting_name, new_value). For example: - ### ("PLATFORM_NAME", "My platform"), - ] -) - - -######################################## -# INITIALIZATION TASKS -######################################## - -# To add a custom initialization task, create a bash script template under: -# blockstore_config_minio/templates/blockstore_config_minio/jobs/init/ -# and then add it to the MY_INIT_TASKS list. Each task is in the format: -# ("<service>", ("<path>", "<to>", "<script>", "<template>")) -MY_INIT_TASKS: list[tuple[str, tuple[str, ...]]] = [ - # For example, to add LMS initialization steps, you could add the script template at: - # blockstore_config_minio/templates/blockstore_config_minio/jobs/init/lms.sh - # And then add the line: - ("cms", ("blockstore_config_minio", "jobs", "init", "cms.sh")), -] - - -# 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( - "blockstore_config_minio", os.path.join("templates", *template_path) - ) - with open(full_path, encoding="utf-8") as init_task_file: - init_task: str = init_task_file.read() - hooks.Filters.CLI_DO_INIT_TASKS.add_item((service, init_task)) - - -######################################## -# DOCKER IMAGE MANAGEMENT -######################################## - - -# Images to be built by `tutor images build`. -# Each item is a quadruple in the form: -# ("<tutor_image_name>", ("path", "to", "build", "dir"), "<docker_image_tag>", "<build_args>") -hooks.Filters.IMAGES_BUILD.add_items( - [ - # To build `myimage` with `tutor images build myimage`, - # you would add a Dockerfile to templates/blockstore/build/myimage, - # and then write: - ### ( - ### "myimage", - ### ("plugins", "blockstore", "build", "myimage"), - ### "docker.io/myimage:{{ BLOCKSTORE_VERSION }}", - ### (), - ### ), - ] -) - - -# Images to be pulled as part of `tutor images pull`. -# Each item is a pair in the form: -# ("<tutor_image_name>", "<docker_image_tag>") -hooks.Filters.IMAGES_PULL.add_items( - [ - # To pull `myimage` with `tutor images pull myimage`, you would write: - ### ( - ### "myimage", - ### "docker.io/myimage:{{ BLOCKSTORE_VERSION }}", - ### ), - ] -) - - -# Images to be pushed as part of `tutor images push`. -# Each item is a pair in the form: -# ("<tutor_image_name>", "<docker_image_tag>") -hooks.Filters.IMAGES_PUSH.add_items( - [ - # To push `myimage` with `tutor images push myimage`, you would write: - ### ( - ### "myimage", - ### "docker.io/myimage:{{ BLOCKSTORE_VERSION }}", - ### ), - ] -) - - -######################################## -# TEMPLATE RENDERING -# (It is safe & recommended to leave -# this section as-is :) -######################################## - -hooks.Filters.ENV_TEMPLATE_ROOTS.add_items( - # Root paths for template files, relative to the project root. - [ - pkg_resources.resource_filename("blockstore_config_minio", "templates"), - ] -) - -hooks.Filters.ENV_TEMPLATE_TARGETS.add_items( - # For each pair (source_path, destination_path): - # templates at ``source_path`` (relative to your ENV_TEMPLATE_ROOTS) will be - # rendered to ``source_path/destination_path`` (relative to your Tutor environment). - # For example, ``blockstore_config_minio/templates/blockstore_config_minio/build`` - # will be rendered to ``$(tutor config printroot)/env/plugins/blockstore_config_minio/build``. - [ - ("blockstore_config_minio/build", "plugins"), - ("blockstore_config_minio/apps", "plugins"), - ], -) - - -######################################## -# PATCH LOADING -# (It is safe & recommended to leave -# this section as-is :) -######################################## - -# For each file in blockstore_config_minio/patches, -# apply a patch based on the file's name and contents. -for path in glob( - os.path.join( - pkg_resources.resource_filename("blockstore_config_minio", "patches"), - "*", - ) -): - with open(path, encoding="utf-8") as patch_file: - hooks.Filters.ENV_PATCHES.add_item((os.path.basename(path), patch_file.read())) - - -######################################## -# CUSTOM JOBS (a.k.a. "do-commands") -######################################## - -# A job is a set of tasks, each of which run inside a certain container. -# Jobs are invoked using the `do` command, for example: `tutor local do importdemocourse`. -# A few jobs are built in to Tutor, such as `init` and `createuser`. -# You can also add your own custom jobs: - -# To add a custom job, define a Click command that returns a list of tasks, -# where each task is a pair in the form ("<service>", "<shell_command>"). -# For example: -### @click.command() -### @click.option("-n", "--name", default="plugin developer") -### def say_hi(name: str) -> list[tuple[str, str]]: -### """ -### An example job that just prints 'hello' from within both LMS and CMS. -### """ -### return [ -### ("lms", f"echo 'Hello from LMS, {name}!'"), -### ("cms", f"echo 'Hello from CMS, {name}!'"), -### ] - - -# Then, add the command function to CLI_DO_COMMANDS: -## hooks.Filters.CLI_DO_COMMANDS.add_item(say_hi) - -# Now, you can run your job like this: -# $ tutor local do say-hi --name="Brian Smith" - - -####################################### -# CUSTOM CLI COMMANDS -####################################### - -# Your plugin can also add custom commands directly to the Tutor CLI. -# These commands are run directly on the user's host computer -# (unlike jobs, which are run in containers). - -# To define a command group for your plugin, you would define a Click -# group and then add it to CLI_COMMANDS: - - -### @click.group() -### def blockstore() -> None: -### pass -### -### -### hooks.Filters.CLI_COMMANDS.add_item(blockstore) - - -# Then, you would add subcommands directly to the Click group, for example: - - -### @blockstore.command() -### def example_command() -> None: -### """ -### This is helptext for an example command. -### """ -### print("You've run an example command.") - - -# This would allow you to run: -# $ tutor blockstore example-command diff --git a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/apps/.gitignore b/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/apps/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/build/.gitignore b/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/build/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/jobs/init/.gitignore b/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/jobs/init/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/jobs/init/cms.sh b/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/jobs/init/cms.sh deleted file mode 100644 index b477e83..0000000 --- a/plugins/tutor-contrib-blockstore-minio/blockstore_config_minio/templates/blockstore_config_minio/jobs/init/cms.sh +++ /dev/null @@ -1,5 +0,0 @@ -# Adapted from https://github.com/openedx/frontend-app-library-authoring/blob/26ea285dc2b5f0c32c6f1a9017a45c6add03f8d7/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/templates/library_authoring_mfe/tasks/cms/init -# -# Create waffle switches to enable the Blockstore app that's now built into -# edx-platform, rather than requiring it to be installed and enabled separately. -(./manage.py cms waffle_switch --list | grep blockstore.use_blockstore_app_api) || ./manage.py lms waffle_switch --create blockstore.use_blockstore_app_api on diff --git a/plugins/tutor-contrib-blockstore-minio/setup.py b/plugins/tutor-contrib-blockstore-minio/setup.py deleted file mode 100644 index 5d4187a..0000000 --- a/plugins/tutor-contrib-blockstore-minio/setup.py +++ /dev/null @@ -1,60 +0,0 @@ -import io -import os -from setuptools import setup, find_packages - -HERE = os.path.abspath(os.path.dirname(__file__)) - - -def load_readme(): - with io.open(os.path.join(HERE, "README.rst"), "rt", encoding="utf8") as f: - return f.read() - - -def load_about(): - about = {} - with io.open( - os.path.join(HERE, "blockstore_config_minio", "__about__.py"), - "rt", - encoding="utf-8", - ) as f: - exec(f.read(), about) # pylint: disable=exec-used - return about - - -ABOUT = load_about() - - -setup( - name="tutor-contrib-blockstore-minio", - version=ABOUT["__version__"], - url="https://github.com/openedx/openedx-tutor-plugins", - project_urls={ - "Code": "https://github.com/openedx/openedx-tutor-plugins", - "Issue tracker": "https://github.com/openedx/openedx-tutor-plugins/issues", - }, - license="AGPLv3", - author="Brian Smith", - description="blockstore minio configuration plugin for Tutor", - long_description=load_readme(), - packages=find_packages(exclude=["tests*"]), - include_package_data=True, - python_requires=">=3.8", - install_requires=["tutor>=17.0.0,<18.0.0"], - extras_require={"dev": ["tutor[dev]>=17.0.0,<18.0.0"]}, - entry_points={ - "tutor.plugin.v1": [ - "blockstore-minio = blockstore_config_minio.plugin" - ] - }, - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: GNU Affero General Public License v3", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - ], -) diff --git a/plugins/tutor-contrib-library-authoring-mfe/README.rst b/plugins/tutor-contrib-library-authoring-mfe/README.rst index c95d413..bcc4244 100644 --- a/plugins/tutor-contrib-library-authoring-mfe/README.rst +++ b/plugins/tutor-contrib-library-authoring-mfe/README.rst @@ -7,19 +7,9 @@ Installation Follow these instructions to enable this microfrontend: * Install `tutor <https://github.com/overhangio/tutor/>`_ and `tutor-mfe <https://github.com/overhangio/tutor-mfe/>`_: ``pip install tutor tutor-mfe`` -* To use blockstore with `minio <https://min.io/>`_ - - * Install `tutor-minio <https://github.com/overhangio/tutor-minio>`_ ``pip install tutor-minio`` - * Enable minio plugin: ``tutor plugins enable minio`` - * Enable the blockstore-minio plugin: ``tutor plugins enable blockstore-minio`` - -* To use blockstore with django :code:`FileSystemStorage` - - * Enable the blockstore-filesystem plugin: ``tutor plugins enable blockstore-filesystem`` - * Enable this plugin: ``tutor plugins enable library-authoring-mfe`` * Save the tutor config: ``tutor config save`` -* Build mfe image: ``tutor images build mfe`` (if you have trouble here you may need to run it with ``--no-cache``) +* Build mfe image: ``tutor images build mfe`` (if you have trouble here you may need to run it with ``--no-cache``) * Launch tutor: ``tutor local launch`` If you want to run this MFE in @@ -35,10 +25,6 @@ Setup ----- * Ensure you have created a user: https://docs.tutor.overhang.io/local.html#creating-a-new-user-with-staff-and-admin-rights * Ensure you have created an organization: http://studio.local.overhang.io/admin/organizations/organization/ -* If you're using minio - - * Log in to the `minio Web UI <http://minio.local.overhang.io>`_ (`instructions to find credentials <https://github.com/overhangio/tutor-minio#web-ui>`_) - * Create a **public** bucket for blockstore (the default configuration expects the bucket to be named :code:`blockstore`) Usage ----- diff --git a/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/__about__.py b/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/__about__.py index d3ec452..493f741 100644 --- a/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/__about__.py +++ b/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/__about__.py @@ -1 +1 @@ -__version__ = "0.2.0" +__version__ = "0.3.0" diff --git a/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/patches/openedx-lms-common-settings b/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/patches/openedx-lms-common-settings index 1cc1f1b..5d092f7 100644 --- a/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/patches/openedx-lms-common-settings +++ b/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/patches/openedx-lms-common-settings @@ -1,2 +1,2 @@ -MFE_CONFIG_OVERRIDES.setdefault("library-authoring", {})["BLOCKSTORE_COLLECTION_UUID"] = "{{BLOCKSTORE_COLLECTION_UUID}}" +MFE_CONFIG_OVERRIDES.setdefault("library-authoring", {}) MFE_CONFIG_OVERRIDES["library-authoring"]["SECURE_ORIGIN_XBLOCK_BOOTSTRAP_HTML_URL"] = "/library-authoring/xblock-bootstrap.html" diff --git a/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/plugin.py b/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/plugin.py index ccbe1c0..4bfec83 100644 --- a/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/plugin.py +++ b/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/plugin.py @@ -25,6 +25,11 @@ def _add_library_authoring_mfe(apps: dict[str, MFE_ATTRS_TYPE]) -> dict[str, MFE ) return apps +# This serves no backend purpose at the moment, and should be removed. But it's +# currently echoed through to the backend and the v2 library creation endpoint +# expects to receive some UUID, even if it doesn't do anything with it any +# longer. We should delete this after modifying the view and MFE code to stop +# using it. tutor_hooks.Filters.CONFIG_UNIQUE.add_items( [ ("BLOCKSTORE_COLLECTION_UUID", str(uuid.uuid4())) diff --git a/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/templates/library_authoring_mfe/jobs/init/cms.sh b/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/templates/library_authoring_mfe/jobs/init/cms.sh index 228d9aa..730ad48 100644 --- a/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/templates/library_authoring_mfe/jobs/init/cms.sh +++ b/plugins/tutor-contrib-library-authoring-mfe/tutor_library_authoring_mfe/templates/library_authoring_mfe/jobs/init/cms.sh @@ -1,6 +1,2 @@ # Enable the waffle flag to use this MFE (./manage.py cms waffle_flag --list | grep studio.library_authoring_mfe) || ./manage.py lms waffle_flag studio.library_authoring_mfe --create --everyone - -# Make sure a Blockstore "Collection" exists to hold the library content. -# the UUID is created in CONFIG_UNIQUE in plugin.py -echo "from blockstore.apps.bundles.models import Collection; coll, _ = Collection.objects.get_or_create(title='Libraries Content Collection', uuid='{{BLOCKSTORE_COLLECTION_UUID}}')" | ./manage.py cms shell