celery-yaml 2.2.0__tar.gz → 2.2.2__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.
@@ -1,3 +1,10 @@
1
+ ## 2.2.2 - Released on 2026-08-28
2
+ * Use alternatives method to crash the process if the yaml is invalid.
3
+
4
+ ## 2.2.1 - Released on 2026-04-29
5
+ * Log exception in case yaml file is invalid, because celery eat it.
6
+ * Update releasing script
7
+
1
8
  ## 2.2.0 - Released on 2025-04-17
2
9
  * Implement crontab for schedule.
3
10
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: celery-yaml
3
- Version: 2.2.0
3
+ Version: 2.2.2
4
4
  Summary: Easy configuration for celery app using Yaml file
5
5
  Author-Email: Guillaume Gauvrit <guillaume@gauvr.it>
6
6
  License: BSD
@@ -13,6 +13,9 @@ Requires-Python: >=3.9
13
13
  Requires-Dist: celery<6,>=5.4.0
14
14
  Requires-Dist: pyyaml<7,>=6.0.0
15
15
  Requires-Dist: envsub<1,>=0.1.15
16
+ Provides-Extra: pyramid
17
+ Requires-Dist: pyramid<3,>=1.9; extra == "pyramid"
18
+ Requires-Dist: plaster-yaml<3,>=2.0; extra == "pyramid"
16
19
  Description-Content-Type: text/markdown
17
20
 
18
21
  [![Continuous Integration](https://github.com/mardiros/celery-yaml/actions/workflows/tests.yml/badge.svg)](https://github.com/mardiros/celery-yaml/actions/workflows/tests.yml)
@@ -25,14 +28,12 @@ command in order to inject its configuration.
25
28
 
26
29
  It also handle help to configurate this application for Pyramid application.
27
30
 
28
-
29
31
  ## Usage
30
32
 
31
33
  ```sh
32
34
  celery -A my_application.module_containing_my.app worker --yaml development.yaml ...
33
35
  ```
34
36
 
35
-
36
37
  This will configure the application `my_application` containing an application
37
38
  `app` in a submodule `module_containing_my`.
38
39
 
@@ -51,10 +52,10 @@ add_yaml_option(app)
51
52
 
52
53
  ```yaml
53
54
  celery:
54
- broker_url: 'amqp://guest:guest@localhost:5672//'
55
- result_backend: 'rpc://'
55
+ broker_url: "amqp://guest:guest@localhost:5672//"
56
+ result_backend: "rpc://"
56
57
  imports:
57
- - my_application.tasks
58
+ - my_application.tasks
58
59
  # see all settings in the celery docs:
59
60
  # https://docs.celeryproject.org/en/stable/userguide/configuration.html
60
61
 
@@ -65,26 +66,71 @@ logging:
65
66
  ```
66
67
 
67
68
  ---
69
+
68
70
  **NOTE**
69
71
 
70
- The broker_url can also be override by an environment variable `CELERY_BROKER_URL`
71
- to avoid password in the configuration file.
72
+ To **avoid password in** the **configuration file**:
73
+
74
+ - Every variables can be substitute with an environment variable.
75
+ The yaml file will replace variable using [envsub](https://mardiros.github.io/envsub/).
76
+
77
+ ```yaml
78
+ celery:
79
+ broker_url: "${CELERY_BROKER_URL-amqp://guest:guest@localhost:5672//}"
80
+
81
+ ```
82
+
83
+ - **DEPRECATED**: The `broker_url` is always overriden by the environment variable
84
+ `CELERY_BROKER_URL` without any declaration.
85
+
72
86
  ---
73
87
 
88
+ ### Using celery beat
89
+
90
+ Celery beat can schedule tasks using interval or crontab.
91
+
92
+ The schedule parameter can be an int, a float or a mapping.
93
+ If it is a mapping, it will be cast to a [crontab](https://docs.celeryq.dev/en/stable/reference/celery.schedules.html#celery.schedules.crontab),
94
+ the mapping will be passed as acrontab parameters.
95
+
96
+ ```yaml
97
+ celery:
98
+ beat_schedule:
99
+ beat_second:
100
+ task: beat_it
101
+ schedule: 10 # example of interval schedule, every 10 seconds
102
+
103
+ beat_crontab:
104
+ task: beat_it
105
+ schedule: # example of crontab
106
+ hour: 9
107
+ minute: 0
108
+ day_of_week: 1
109
+ ```
110
+
74
111
  ## Using Celery in a Pyramid App.
75
112
 
76
113
  The extras "pyramid" must be added to install the extras depencencies.
77
114
 
78
- ### With poetry
115
+ ### With PEP 621 (uv, pdm, ...)
79
116
 
80
117
  ```toml
81
- [tool.poetry.dependencies]
82
- celery-yaml = { version = "^0.1.3", extras = ["pyramid"] }
118
+ [dependency-groups]
119
+ celery = ["celery >=5.2.7,<6", "celery-yaml[pyramid]>=2.0.0,<3"]
120
+
121
+ [project.entry-points."paste.app_factory"]
122
+ main = "pyramid_helloworld:main"
123
+
124
+ [project.entry-points."celery_yaml.app"]
125
+ main = "pyramid_helloworld.backend:app"
83
126
  ```
84
127
 
85
- Then some entry_points have to configure, such as:
128
+ ### With poetry
86
129
 
87
130
  ```toml
131
+ [tool.poetry.dependencies]
132
+ celery-yaml = { version = "^2.0.0", extras = ["pyramid"] }
133
+
88
134
  [tool.poetry.plugins."paste.app_factory"]
89
135
  main = "pyramid_app.wsgi:main"
90
136
 
@@ -102,14 +148,13 @@ of a yaml file instead of an `ini` file to configure it.
102
148
  Then the `celery_yaml.app` is used by `celery-yaml` as an entrypoint to
103
149
  the celery app.
104
150
 
105
-
106
151
  Then, in the configuration file,
107
152
 
108
153
  ```yaml
109
154
  celery: &celery
110
- result_backend: 'rpc://'
155
+ result_backend: "rpc://"
111
156
  imports:
112
- - pyramid_app.tasks
157
+ - pyramid_app.tasks
113
158
 
114
159
  app:
115
160
  "use": "egg:pyramid_app"
@@ -142,7 +187,6 @@ class Celery(CeleryBase):
142
187
 
143
188
  This is particullary usefull for depenency injection purpose.
144
189
 
145
-
146
190
  #### Environment substitution
147
191
 
148
192
  ```yaml
@@ -150,7 +194,7 @@ celery:
150
194
  broker_url: ${CELERY_BROKER_URL}
151
195
  result_backend: ${CELERY_BACKEND_RESULT}
152
196
  imports:
153
- - pyramid_app.tasks
197
+ - pyramid_app.tasks
154
198
 
155
199
  database_dsn: ${DATABASE_DSN}
156
200
  ```
@@ -164,7 +208,6 @@ This is particullary usefull to keep your configuration structured but keep
164
208
  secrets in environment variable, for security reason. And also to build docker
165
209
  container that can be easily customizable.
166
210
 
167
-
168
211
  #### See full example in the examples directory:
169
212
 
170
213
  https://github.com/mardiros/celery-yaml/tree/master/examples/pyramid-app
@@ -8,14 +8,12 @@ command in order to inject its configuration.
8
8
 
9
9
  It also handle help to configurate this application for Pyramid application.
10
10
 
11
-
12
11
  ## Usage
13
12
 
14
13
  ```sh
15
14
  celery -A my_application.module_containing_my.app worker --yaml development.yaml ...
16
15
  ```
17
16
 
18
-
19
17
  This will configure the application `my_application` containing an application
20
18
  `app` in a submodule `module_containing_my`.
21
19
 
@@ -34,10 +32,10 @@ add_yaml_option(app)
34
32
 
35
33
  ```yaml
36
34
  celery:
37
- broker_url: 'amqp://guest:guest@localhost:5672//'
38
- result_backend: 'rpc://'
35
+ broker_url: "amqp://guest:guest@localhost:5672//"
36
+ result_backend: "rpc://"
39
37
  imports:
40
- - my_application.tasks
38
+ - my_application.tasks
41
39
  # see all settings in the celery docs:
42
40
  # https://docs.celeryproject.org/en/stable/userguide/configuration.html
43
41
 
@@ -48,26 +46,71 @@ logging:
48
46
  ```
49
47
 
50
48
  ---
49
+
51
50
  **NOTE**
52
51
 
53
- The broker_url can also be override by an environment variable `CELERY_BROKER_URL`
54
- to avoid password in the configuration file.
52
+ To **avoid password in** the **configuration file**:
53
+
54
+ - Every variables can be substitute with an environment variable.
55
+ The yaml file will replace variable using [envsub](https://mardiros.github.io/envsub/).
56
+
57
+ ```yaml
58
+ celery:
59
+ broker_url: "${CELERY_BROKER_URL-amqp://guest:guest@localhost:5672//}"
60
+
61
+ ```
62
+
63
+ - **DEPRECATED**: The `broker_url` is always overriden by the environment variable
64
+ `CELERY_BROKER_URL` without any declaration.
65
+
55
66
  ---
56
67
 
68
+ ### Using celery beat
69
+
70
+ Celery beat can schedule tasks using interval or crontab.
71
+
72
+ The schedule parameter can be an int, a float or a mapping.
73
+ If it is a mapping, it will be cast to a [crontab](https://docs.celeryq.dev/en/stable/reference/celery.schedules.html#celery.schedules.crontab),
74
+ the mapping will be passed as acrontab parameters.
75
+
76
+ ```yaml
77
+ celery:
78
+ beat_schedule:
79
+ beat_second:
80
+ task: beat_it
81
+ schedule: 10 # example of interval schedule, every 10 seconds
82
+
83
+ beat_crontab:
84
+ task: beat_it
85
+ schedule: # example of crontab
86
+ hour: 9
87
+ minute: 0
88
+ day_of_week: 1
89
+ ```
90
+
57
91
  ## Using Celery in a Pyramid App.
58
92
 
59
93
  The extras "pyramid" must be added to install the extras depencencies.
60
94
 
61
- ### With poetry
95
+ ### With PEP 621 (uv, pdm, ...)
62
96
 
63
97
  ```toml
64
- [tool.poetry.dependencies]
65
- celery-yaml = { version = "^0.1.3", extras = ["pyramid"] }
98
+ [dependency-groups]
99
+ celery = ["celery >=5.2.7,<6", "celery-yaml[pyramid]>=2.0.0,<3"]
100
+
101
+ [project.entry-points."paste.app_factory"]
102
+ main = "pyramid_helloworld:main"
103
+
104
+ [project.entry-points."celery_yaml.app"]
105
+ main = "pyramid_helloworld.backend:app"
66
106
  ```
67
107
 
68
- Then some entry_points have to configure, such as:
108
+ ### With poetry
69
109
 
70
110
  ```toml
111
+ [tool.poetry.dependencies]
112
+ celery-yaml = { version = "^2.0.0", extras = ["pyramid"] }
113
+
71
114
  [tool.poetry.plugins."paste.app_factory"]
72
115
  main = "pyramid_app.wsgi:main"
73
116
 
@@ -85,14 +128,13 @@ of a yaml file instead of an `ini` file to configure it.
85
128
  Then the `celery_yaml.app` is used by `celery-yaml` as an entrypoint to
86
129
  the celery app.
87
130
 
88
-
89
131
  Then, in the configuration file,
90
132
 
91
133
  ```yaml
92
134
  celery: &celery
93
- result_backend: 'rpc://'
135
+ result_backend: "rpc://"
94
136
  imports:
95
- - pyramid_app.tasks
137
+ - pyramid_app.tasks
96
138
 
97
139
  app:
98
140
  "use": "egg:pyramid_app"
@@ -125,7 +167,6 @@ class Celery(CeleryBase):
125
167
 
126
168
  This is particullary usefull for depenency injection purpose.
127
169
 
128
-
129
170
  #### Environment substitution
130
171
 
131
172
  ```yaml
@@ -133,7 +174,7 @@ celery:
133
174
  broker_url: ${CELERY_BROKER_URL}
134
175
  result_backend: ${CELERY_BACKEND_RESULT}
135
176
  imports:
136
- - pyramid_app.tasks
177
+ - pyramid_app.tasks
137
178
 
138
179
  database_dsn: ${DATABASE_DSN}
139
180
  ```
@@ -147,7 +188,6 @@ This is particullary usefull to keep your configuration structured but keep
147
188
  secrets in environment variable, for security reason. And also to build docker
148
189
  container that can be easily customizable.
149
190
 
150
-
151
191
  #### See full example in the examples directory:
152
192
 
153
193
  https://github.com/mardiros/celery-yaml/tree/master/examples/pyramid-app
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "celery-yaml"
3
- version = "2.2.0"
3
+ version = "2.2.2"
4
4
  description = "Easy configuration for celery app using Yaml file"
5
5
  authors = [
6
6
  { name = "Guillaume Gauvrit", email = "guillaume@gauvr.it" },
@@ -23,19 +23,22 @@ Repository = "https://github.com/mardiros/celery-yaml.git"
23
23
  Issues = "https://github.com/mardiros/celery-yaml/issues"
24
24
  Changelog = "https://github.com/mardiros/celery-yaml/blob/main/CHANGELOG.md"
25
25
 
26
+ [project.optional-dependencies]
27
+ pyramid = [
28
+ "pyramid >=1.9,<3",
29
+ "plaster-yaml >=2.0,<3",
30
+ ]
31
+
26
32
  [dependency-groups]
27
33
  dev = [
28
- "celery>=5.2.0,<6",
29
- "coverage>=6.2,<7",
30
- "mypy>=1.13.0,<2",
31
- "pytest>=8.3.3,<9",
32
- "pytest-cov>=5.0.0,<6",
33
- "pyramid-helloworld>=2.0.0",
34
- "types-pyyaml>=6.0.12.20240917,<7",
35
- ]
36
- pyramid = [
37
- "pyramid>=1.9,<3",
38
- "plaster-yaml>=2.0,<3",
34
+ "celery >=5.2.0,<6",
35
+ "coverage >=6.2,<7",
36
+ "mypy >=1.13.0,<2",
37
+ "pyramid >=1.9,<3",
38
+ "pytest >=8.3.3,<9",
39
+ "pytest-cov >=5.0.0,<6",
40
+ "pyramid-helloworld >=2.0.0,<3",
41
+ "types-pyyaml >=6.0.12.20240917,<7",
39
42
  ]
40
43
 
41
44
  [tool.pdm.build]
@@ -3,6 +3,7 @@
3
3
  import logging
4
4
  import os
5
5
  import sys
6
+ import traceback
6
7
  from collections.abc import Iterator, Mapping
7
8
  from logging.config import dictConfig
8
9
  from typing import Any, Tuple
@@ -28,8 +29,12 @@ def on_preload_parsed(options: Mapping[str, Any], **kwargs: Any) -> None:
28
29
  print("You must provide the --yaml argument")
29
30
  sys.exit(-1)
30
31
 
31
- loader = YamlLoader(app, config=config_path, config_key=config_key)
32
- loader.read_configuration()
32
+ try:
33
+ loader = YamlLoader(app, config=config_path, config_key=config_key)
34
+ loader.read_configuration()
35
+ except Exception:
36
+ traceback.print_exc()
37
+ sys.exit(1)
33
38
 
34
39
 
35
40
  def add_yaml_option(app: Celery) -> None:
File without changes