tutor 23.0.0.dev3234__tar.gz → 23.0.0.dev3237__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/PKG-INFO +1 -1
  2. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/cli.py +51 -3
  3. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/config.py +2 -1
  4. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/context.py +21 -1
  5. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/plugins.py +2 -1
  6. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/hooks/catalog.py +9 -0
  7. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/plugins/__init__.py +2 -1
  8. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/.gitignore +0 -0
  9. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/.hatch_build.py +0 -0
  10. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/LICENSE.txt +0 -0
  11. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/README.rst +0 -0
  12. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/pyproject.toml +0 -0
  13. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/requirements/base.in +0 -0
  14. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/requirements/dev.txt +0 -0
  15. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/requirements/plugins.txt +0 -0
  16. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/__about__.py +0 -0
  17. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/__init__.py +0 -0
  18. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/bindmount.py +0 -0
  19. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/__init__.py +0 -0
  20. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/compose.py +0 -0
  21. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/dev.py +0 -0
  22. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/images.py +0 -0
  23. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/jobs.py +0 -0
  24. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/jobs_utils.py +0 -0
  25. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/k8s.py +0 -0
  26. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/local.py +0 -0
  27. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/mounts.py +0 -0
  28. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/params.py +0 -0
  29. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/upgrade/__init__.py +0 -0
  30. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/upgrade/common.py +0 -0
  31. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/upgrade/compose.py +0 -0
  32. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/commands/upgrade/k8s.py +0 -0
  33. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/config.py +0 -0
  34. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/core/__init__.py +0 -0
  35. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/core/hooks/__init__.py +0 -0
  36. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/core/hooks/actions.py +0 -0
  37. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/core/hooks/contexts.py +0 -0
  38. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/core/hooks/filters.py +0 -0
  39. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/core/hooks/priorities.py +0 -0
  40. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/env.py +0 -0
  41. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/exceptions.py +0 -0
  42. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/fmt.py +0 -0
  43. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/hooks/__init__.py +0 -0
  44. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/images.py +0 -0
  45. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/interactive.py +0 -0
  46. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/plugins/base.py +0 -0
  47. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/plugins/indexes.py +0 -0
  48. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/plugins/openedx.py +0 -0
  49. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/plugins/v0.py +0 -0
  50. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/plugins/v1.py +0 -0
  51. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/py.typed +0 -0
  52. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/serialize.py +0 -0
  53. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/tasks.py +0 -0
  54. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/caddy/Caddyfile +0 -0
  55. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/config/cms.env.yml +0 -0
  56. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/config/lms.env.yml +0 -0
  57. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/config/partials/auth.yml +0 -0
  58. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/granian-config +0 -0
  59. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/settings/cms/__init__.py +0 -0
  60. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/settings/cms/development.py +0 -0
  61. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/settings/cms/production.py +0 -0
  62. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/settings/cms/test.py +0 -0
  63. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/settings/lms/__init__.py +0 -0
  64. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/settings/lms/development.py +0 -0
  65. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/settings/lms/production.py +0 -0
  66. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/settings/lms/test.py +0 -0
  67. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/settings/partials/common_all.py +0 -0
  68. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/settings/partials/common_cms.py +0 -0
  69. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/settings/partials/common_lms.py +0 -0
  70. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/openedx/settings/partials/common_test.py +0 -0
  71. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/permissions/fix-volume-permissions.sh +0 -0
  72. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/permissions/setowners.sh +0 -0
  73. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/apps/redis/redis.conf +0 -0
  74. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/Dockerfile +0 -0
  75. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/bin/reload-granian +0 -0
  76. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/bin/run-granian +0 -0
  77. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/bin/wait-for-tcp +0 -0
  78. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/revisions.yml +0 -0
  79. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/settings/cms/__init__.py +0 -0
  80. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/settings/cms/assets.py +0 -0
  81. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/settings/cms/i18n.py +0 -0
  82. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/settings/granian-config +0 -0
  83. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/settings/lms/__init__.py +0 -0
  84. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/settings/lms/assets.py +0 -0
  85. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/settings/lms/i18n.py +0 -0
  86. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/settings/partials/assets.py +0 -0
  87. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/settings/partials/i18n.py +0 -0
  88. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/openedx/themes/README +0 -0
  89. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/permissions/Dockerfile +0 -0
  90. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/build/permissions/setowner.sh +0 -0
  91. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/config/base.yml +0 -0
  92. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/config/defaults.yml +0 -0
  93. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/dev/docker-compose.jobs.yml +0 -0
  94. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/dev/docker-compose.yml +0 -0
  95. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/jobs/init/cms.sh +0 -0
  96. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/jobs/init/lms.sh +0 -0
  97. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/jobs/init/meilisearch.sh +0 -0
  98. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/jobs/init/mounted-directories.sh +0 -0
  99. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/jobs/init/mysql.sh +0 -0
  100. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/k8s/deployments.yml +0 -0
  101. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/k8s/jobs.yml +0 -0
  102. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/k8s/namespace.yml +0 -0
  103. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/k8s/override.yml +0 -0
  104. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/k8s/services.yml +0 -0
  105. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/k8s/volumes.yml +0 -0
  106. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/kustomization.yml +0 -0
  107. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/local/docker-compose.jobs.yml +0 -0
  108. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/local/docker-compose.prod.yml +0 -0
  109. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/local/docker-compose.yml +0 -0
  110. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/templates/version +0 -0
  111. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/types.py +0 -0
  112. {tutor-23.0.0.dev3234 → tutor-23.0.0.dev3237}/tutor/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tutor
3
- Version: 23.0.0.dev3234
3
+ Version: 23.0.0.dev3237
4
4
  Summary: The Docker-based Open edX distribution designed for peace of mind
5
5
  Project-URL: Homepage, https://docs.tutor.edly.io/
6
6
  Project-URL: Documentation, https://docs.tutor.edly.io/
@@ -9,7 +9,7 @@ import click
9
9
  from tutor import exceptions, fmt, hooks, utils
10
10
  from tutor.__about__ import __app__, __version__
11
11
  from tutor.commands.config import config_command
12
- from tutor.commands.context import Context
12
+ from tutor.commands.context import Context, ignore_plugin_errors
13
13
  from tutor.commands.dev import dev
14
14
  from tutor.commands.images import images_command
15
15
  from tutor.commands.k8s import k8s
@@ -32,6 +32,41 @@ def main() -> None:
32
32
  sys.exit(1)
33
33
 
34
34
 
35
+ def check_plugin_errors(context: click.Context) -> None:
36
+ """
37
+ Check for plugin loading errors and exit with code 1 if any were found,
38
+ unless --ignore-plugin-errors is set.
39
+ """
40
+ errors: list[tuple[str, str]] = list(hooks.Filters.PLUGIN_ERRORS.iterate())
41
+ if not errors or context.invoked_subcommand is None:
42
+ return
43
+ # This is done to narrow the type. This function is only called from a one
44
+ # place which is always a group.
45
+ assert isinstance(context.command, click.Group)
46
+ subcommand = context.command.get_command(context, context.invoked_subcommand)
47
+ ignore = context.obj.ignore_plugin_errors or getattr(
48
+ subcommand, "ignore_plugin_errors", False
49
+ )
50
+
51
+ for plugin, error in errors:
52
+ if ignore:
53
+ fmt.echo_alert(f"Failed to enable plugin '{plugin}': {error}")
54
+ else:
55
+ fmt.echo_error(f"Plugin '{plugin}' failed to load: {error}")
56
+ # Only exit with an error code if:
57
+ # - errors are not being ignored
58
+ # - no exception has already been raised that would return its own error code
59
+ if ignore:
60
+ return
61
+ match sys.exc_info()[1]:
62
+ case None:
63
+ sys.exit(1)
64
+ case SystemExit(code=code) | click.exceptions.Exit(exit_code=code) if code == 0:
65
+ sys.exit(1)
66
+ case _:
67
+ return
68
+
69
+
35
70
  class TutorCli(click.Group):
36
71
  """
37
72
  Dynamically load subcommands at runtime.
@@ -99,20 +134,33 @@ class TutorCli(click.Group):
99
134
  is_flag=True,
100
135
  help="Print this help",
101
136
  )
137
+ @click.option(
138
+ "--ignore-plugin-errors",
139
+ "ignore_plugin_errors",
140
+ is_flag=True,
141
+ default=False,
142
+ help="Continue running even if plugin loading fails",
143
+ )
102
144
  @click.pass_context
103
- def cli(context: click.Context, root: str, show_help: bool) -> None:
145
+ def cli(
146
+ context: click.Context, root: str, show_help: bool, ignore_plugin_errors: bool
147
+ ) -> None:
104
148
  if utils.is_root():
105
149
  fmt.echo_alert(
106
150
  "You are running Tutor as root. This is strongly not recommended. If you are doing this in order to access"
107
151
  " the Docker daemon, you should instead add your user to the 'docker' group. (see https://docs.docker.com"
108
152
  "/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user)"
109
153
  )
110
- context.obj = Context(root)
154
+ context.obj = Context(root, ignore_plugin_errors)
111
155
  context.help_option_names = ["-h", "--help"]
156
+
157
+ check_plugin_errors(context)
158
+
112
159
  if context.invoked_subcommand is None or show_help:
113
160
  click.echo(context.get_help())
114
161
 
115
162
 
163
+ @ignore_plugin_errors
116
164
  @click.command(help="Print this help", name="help")
117
165
  @click.pass_context
118
166
  def help_command(context: click.Context) -> None:
@@ -11,11 +11,12 @@ import click.shell_completion
11
11
  from tutor import config as tutor_config
12
12
  from tutor import env, exceptions, fmt, hooks, serialize, utils
13
13
  from tutor import interactive as interactive_config
14
- from tutor.commands.context import Context
14
+ from tutor.commands.context import Context, ignore_plugin_errors
15
15
  from tutor.commands.params import ConfigLoaderParam, ParamValue
16
16
  from tutor.types import Config, ConfigValue
17
17
 
18
18
 
19
+ @ignore_plugin_errors
19
20
  @click.group(
20
21
  name="config",
21
22
  short_help="Configure Open edX",
@@ -1,3 +1,7 @@
1
+ from typing import TypeVar
2
+
3
+ import click
4
+
1
5
  from tutor.tasks import BaseTaskRunner
2
6
  from tutor.types import Config
3
7
 
@@ -12,8 +16,9 @@ class Context:
12
16
  $ tutor --root=... local run ...
13
17
  """
14
18
 
15
- def __init__(self, root: str) -> None:
19
+ def __init__(self, root: str, ignore_plugin_errors: bool = False) -> None:
16
20
  self.root = root
21
+ self.ignore_plugin_errors = ignore_plugin_errors
17
22
 
18
23
 
19
24
  class BaseTaskContext(Context):
@@ -28,3 +33,18 @@ class BaseTaskContext(Context):
28
33
  Return a runner capable of running docker-compose/kubectl commands.
29
34
  """
30
35
  raise NotImplementedError
36
+
37
+
38
+ CMD = TypeVar("CMD", bound=click.Command)
39
+
40
+
41
+ def ignore_plugin_errors(command: CMD) -> CMD:
42
+ """
43
+ Ignore plugins errors for commands marked with this.
44
+
45
+ Commands decorated with this will run even if there were errors when loading
46
+ plugins. This needs to be the first decorator and only works for top-level
47
+ command, exempting all subcommands.
48
+ """
49
+ setattr(command, "ignore_plugin_errors", True)
50
+ return command
@@ -16,7 +16,7 @@ from tutor.plugins import indexes
16
16
  from tutor.plugins.base import PLUGINS_ROOT, PLUGINS_ROOT_ENV_VAR_NAME
17
17
  from tutor.types import Config
18
18
 
19
- from .context import Context
19
+ from .context import Context, ignore_plugin_errors
20
20
 
21
21
 
22
22
  class PluginName(click.ParamType[str]):
@@ -74,6 +74,7 @@ class IndexPluginNameOrLocation(IndexPluginName):
74
74
  return autocompleted
75
75
 
76
76
 
77
+ @ignore_plugin_errors
77
78
  @click.group(
78
79
  name="plugins",
79
80
  short_help="Manage Tutor plugins",
@@ -479,6 +479,15 @@ class Filters:
479
479
  #: regular expression. For instance: ``("openedx", r".*xblock.*")``.
480
480
  MOUNTED_DIRECTORIES: Filter[list[tuple[str, str]], []] = Filter()
481
481
 
482
+ #: List of plugins that failed to load, along with the corresponding error
483
+ #: message. This filter is populated by `tutor.plugins.load_all` when a
484
+ #: plugin raises an exception during loading. It is consumed by the CLI to
485
+ #: report errors after the subcommand has finished.
486
+ #:
487
+ #: :parameter list[tuple[str, str]] errors: list of ``(plugin_name, error_message)``
488
+ #: tuples.
489
+ PLUGIN_ERRORS: Filter[list[tuple[str, str]], []] = Filter()
490
+
482
491
  #: List of plugin indexes that are loaded when we run ``tutor plugins update``. By
483
492
  #: default, the plugin indexes are stored in the user configuration. This filter makes
484
493
  #: it possible to extend and modify this list with plugins.
@@ -61,7 +61,8 @@ def load_all(names: t.Iterable[str]) -> None:
61
61
  try:
62
62
  load(name)
63
63
  except Exception as e:
64
- fmt.echo_alert(f"Failed to enable plugin '{name}': {e}")
64
+ with hooks.Contexts.PLUGINS.enter():
65
+ hooks.Filters.PLUGIN_ERRORS.add_item((name, str(e)))
65
66
  hooks.Actions.PLUGINS_LOADED.do()
66
67
 
67
68