flagsmith-common 2.2.4__tar.gz → 2.2.6__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.
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/PKG-INFO +1 -1
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/pyproject.toml +1 -1
- flagsmith_common-2.2.6/src/common/core/constants.py +1 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/main.py +12 -15
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/utils.py +27 -37
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/LICENSE +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/README.md +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/app.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/cli/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/cli/healthcheck.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/logging.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/management/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/management/commands/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/management/commands/docgen.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/management/commands/start.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/management/commands/waitfordb.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/metrics.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/middleware.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/templates/docgen-metrics.md +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/urls.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/views.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/environments/permissions.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/features/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/features/multivariate/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/features/multivariate/serializers.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/features/serializers.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/features/versioning/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/features/versioning/serializers.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/gunicorn/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/gunicorn/conf.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/gunicorn/constants.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/gunicorn/logging.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/gunicorn/metrics.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/gunicorn/middleware.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/gunicorn/utils.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/migrations/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/migrations/helpers/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/migrations/helpers/postgres_helpers.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/organisations/permissions.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/projects/permissions.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/prometheus/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/prometheus/utils.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/py.typed +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/test_tools/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/test_tools/plugin.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/test_tools/types.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/test_tools/utils.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/types.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/admin.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/apps.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/decorators.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/exceptions.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/health.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/managers.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/metrics.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0001_initial.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0002_healthcheckmodel.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0003_add_completed_to_task.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0004_recreate_task_indexes.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0005_update_conditional_index_conditions.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0006_auto_20230221_0802.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0007_add_is_locked.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0008_add_get_task_to_process_function.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0009_add_recurring_task_run_first_run_at.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0010_task_priority.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0011_add_priority_to_get_tasks_to_process.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0012_add_locked_at_and_timeout.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0013_add_last_picked_at.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/sql/0008_get_recurring_tasks_to_process.sql +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/sql/0008_get_tasks_to_process.sql +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/sql/0011_get_tasks_to_process.sql +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/sql/0012_get_recurringtasks_to_process.sql +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/sql/0013_get_recurringtasks_to_process.sql +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/sql/__init__.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/models.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/monitoring.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/processor.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/py.typed +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/routers.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/serializers.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/task_registry.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/task_run_method.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/tasks.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/threads.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/types.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/urls.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/utils.py +0 -0
- {flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/views.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
DEFAULT_PROMETHEUS_MULTIPROC_DIR_NAME = "flagsmith-prometheus"
|
|
@@ -3,14 +3,15 @@ import logging
|
|
|
3
3
|
import os
|
|
4
4
|
import sys
|
|
5
5
|
import typing
|
|
6
|
+
from tempfile import gettempdir
|
|
6
7
|
|
|
7
8
|
from django.core.management import (
|
|
8
9
|
execute_from_command_line as django_execute_from_command_line,
|
|
9
10
|
)
|
|
10
|
-
from environs import Env
|
|
11
11
|
|
|
12
12
|
from common.core.cli import healthcheck
|
|
13
|
-
from common.core.
|
|
13
|
+
from common.core.constants import DEFAULT_PROMETHEUS_MULTIPROC_DIR_NAME
|
|
14
|
+
from common.core.utils import clear_directory, make_writable_directory
|
|
14
15
|
|
|
15
16
|
logger = logging.getLogger(__name__)
|
|
16
17
|
|
|
@@ -31,11 +32,19 @@ def ensure_cli_env() -> typing.Generator[None, None, None]:
|
|
|
31
32
|
main()
|
|
32
33
|
```
|
|
33
34
|
"""
|
|
34
|
-
env = Env()
|
|
35
35
|
ctx = contextlib.ExitStack()
|
|
36
36
|
|
|
37
37
|
# TODO @khvn26 Move logging setup to here
|
|
38
38
|
|
|
39
|
+
# Prometheus multiproc support
|
|
40
|
+
prom_dir = os.environ.setdefault(
|
|
41
|
+
"PROMETHEUS_MULTIPROC_DIR",
|
|
42
|
+
os.path.join(gettempdir(), DEFAULT_PROMETHEUS_MULTIPROC_DIR_NAME),
|
|
43
|
+
)
|
|
44
|
+
if os.path.exists(prom_dir):
|
|
45
|
+
clear_directory(prom_dir)
|
|
46
|
+
make_writable_directory(prom_dir)
|
|
47
|
+
|
|
39
48
|
# Currently we don't install Flagsmith modules as a package, so we need to add
|
|
40
49
|
# $CWD to the Python path to be able to import them
|
|
41
50
|
sys.path.append(os.getcwd())
|
|
@@ -44,18 +53,6 @@ def ensure_cli_env() -> typing.Generator[None, None, None]:
|
|
|
44
53
|
# without resorting to it being set outside of the application
|
|
45
54
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings.dev")
|
|
46
55
|
|
|
47
|
-
# Set up Prometheus' multiprocess mode
|
|
48
|
-
if not env.str("PROMETHEUS_MULTIPROC_DIR", ""):
|
|
49
|
-
delete = not env.bool("PROMETHEUS_MULTIPROC_DIR_KEEP", False)
|
|
50
|
-
prometheus_multiproc_dir_name = ctx.enter_context(
|
|
51
|
-
TemporaryDirectory(delete=delete)
|
|
52
|
-
)
|
|
53
|
-
logger.info(
|
|
54
|
-
"Created %s for Prometheus multi-process mode",
|
|
55
|
-
prometheus_multiproc_dir_name,
|
|
56
|
-
)
|
|
57
|
-
os.environ["PROMETHEUS_MULTIPROC_DIR"] = prometheus_multiproc_dir_name
|
|
58
|
-
|
|
59
56
|
if "docgen" in sys.argv:
|
|
60
57
|
os.environ["DOCGEN_MODE"] = "true"
|
|
61
58
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import logging
|
|
3
|
+
import os
|
|
3
4
|
import pathlib
|
|
4
5
|
import random
|
|
5
|
-
import
|
|
6
|
-
import tempfile
|
|
6
|
+
import shutil
|
|
7
7
|
from functools import lru_cache
|
|
8
8
|
from itertools import cycle
|
|
9
9
|
from typing import (
|
|
@@ -202,38 +202,28 @@ def using_database_replica(
|
|
|
202
202
|
return manager.db_manager(chosen_replica)
|
|
203
203
|
|
|
204
204
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
See https://docs.python.org/3.12/library/tempfile.html#tempfile.TemporaryDirectory for usage details.
|
|
231
|
-
"""
|
|
232
|
-
if delete:
|
|
233
|
-
return tempfile.TemporaryDirectory(suffix, prefix, dir)
|
|
234
|
-
|
|
235
|
-
@contextlib.contextmanager
|
|
236
|
-
def _tmpdir() -> Generator[str, None, None]:
|
|
237
|
-
yield tempfile.mkdtemp(suffix, prefix, dir)
|
|
238
|
-
|
|
239
|
-
return _tmpdir()
|
|
205
|
+
def clear_directory(directory_path: str) -> None:
|
|
206
|
+
"""
|
|
207
|
+
Safely clear a directory including all subdirectories and files.
|
|
208
|
+
"""
|
|
209
|
+
for p in pathlib.Path(directory_path).rglob("*"):
|
|
210
|
+
try:
|
|
211
|
+
# Ensure that the cleanup doesn't silently fail on
|
|
212
|
+
# files and subdirs created by other users.
|
|
213
|
+
p.chmod(0o777)
|
|
214
|
+
except (PermissionError, FileNotFoundError): # pragma: no cover
|
|
215
|
+
pass
|
|
216
|
+
|
|
217
|
+
shutil.rmtree(directory_path, ignore_errors=True)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def make_writable_directory(directory_path: str) -> None:
|
|
221
|
+
os.makedirs(directory_path, exist_ok=True)
|
|
222
|
+
|
|
223
|
+
try:
|
|
224
|
+
# While `mkdir` sets mode=0o777 by default, this can be affected by umask
|
|
225
|
+
# resulting in lesser permissions for other users. This step ensures the
|
|
226
|
+
# directory is writable for all users.
|
|
227
|
+
os.chmod(directory_path, 0o777)
|
|
228
|
+
except PermissionError: # pragma: no cover
|
|
229
|
+
pass
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/management/commands/__init__.py
RENAMED
|
File without changes
|
{flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/management/commands/docgen.py
RENAMED
|
File without changes
|
{flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/management/commands/start.py
RENAMED
|
File without changes
|
{flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/management/commands/waitfordb.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/core/templates/docgen-metrics.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/features/multivariate/__init__.py
RENAMED
|
File without changes
|
{flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/features/multivariate/serializers.py
RENAMED
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/features/versioning/__init__.py
RENAMED
|
File without changes
|
{flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/features/versioning/serializers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/common/migrations/helpers/postgres_helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/0001_initial.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flagsmith_common-2.2.4 → flagsmith_common-2.2.6}/src/task_processor/migrations/sql/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|