-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathpyproject.toml
More file actions
311 lines (288 loc) · 11.2 KB
/
Copy pathpyproject.toml
File metadata and controls
311 lines (288 loc) · 11.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
[project]
name = "flexmeasures"
description = "The *FlexMeasures Platform* is the intelligent backend to support real-time energy flexibility apps, rapidly and scalable."
readme = "README.md"
requires-python = ">=3.10, <3.13"
license = "Apache-2.0"
license-files = ["LICENSE"]
authors = [
{name = "Seita BV", email = "nicolas@seita.nl"}
]
keywords = ["smart grid", "renewables", "balancing", "forecasting", "scheduling"]
classifiers = [
"Environment :: Console",
"Environment :: Web Environment",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Framework :: Flask",
"Development Status :: 5 - Production/Stable",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Natural Language :: English"
]
dynamic = ["version"]
dependencies = [
"pyyaml>=6.0.3",
"altair>=6.0.0",
"pandas>=2.2.1",
"pint>=0.19.1",
"py-moneyed>=3.0",
"iso8601>=2.1.0",
"xlrd>=2.0.2",
"openpyxl>=3.1.5",
"workalendar>=17.0.0",
"holidays>=0.57",
"inflection>=0.5.1",
"pydantic>=2.12.5",
"humanize>=4.15.0",
"psycopg2-binary>=2.9.11",
# hashing backend for passlib
"argon2-cffi>=25.1.0",
"bcrypt==4.3.0", # see https://github.com/SeitaBV/flexmeasures-cloudinfra/issues/283
"pytz>=2025.2",
"isodate>=0.7.2",
"click>=8.2.0",
"click-default-group>=1.2.4",
# for automations: matching cron strings and describing them in natural language
"croniter>=2.0.0",
"cron-descriptor>=1.4.0",
"email-validator>=2.3.0",
"rq>=2.6.1",
# sort order
"rq-dashboard>=0.8.7",
# the following uses environment markers (see PEP 496)
"rq-win; os_name == 'nt' or os_name == 'win'",
# Note: we sometimes limit redis due to our use of fakeredis (check their pyproject.toml)
"redis>4.5",
"tldextract>=5.3.1",
# pinned to <6.9 due to a HiGHS deadlock, see https://github.com/FlexMeasures/flexmeasures/issues/1443
"pyomo>=5.6,<6.9",
"tabulate>=0.9.0",
# 4.2.0: stopped declaring single-column indexes on event_start and sensor_id, which migration b7e5a2c40f18 drops.
"timely-beliefs>=4.2.0",
"python-dotenv>=1.2.1",
# see GH#607 for issue on this pin
"sqlalchemy>=2.0",
"flask-sslify>=0.1.5",
"flask-json>=0.4.0",
"flask-migrate>=4.1.0",
"flask-wtf>=1.2.2",
"flask-mail>=0.10.0",
"Flask-Security-Too[fsqla,mfa]>=5.0",
"flask-login>=0.6.3",
"Flask-Classful>=0.16",
"flask-marshmallow>=1.4.0",
"flask-cors>=6.0.2",
"flask-swagger-ui>=5.21.0",
# Note: the redis extra (used for rate-limit storage) currently pins redis<8
"Flask-Limiter[redis]>=4.0",
# Flask-Limiter's rate-limit parser, which we also import directly (to validate rate limits),
# so we declare it rather than lean on it arriving transitively.
# The floor is Flask-Limiter's own, as we only use the long-standing limits.parse.
"limits>=3.13",
"sentry-sdk[flask]>=2.52.0",
"marshmallow>=3",
# See GH#1450 (failing tests on older Python versions)
"marshmallow~=3.0; python_version < '3.11'",
"marshmallow-oneofschema>=3.2.0",
"marshmallow-polyfield>=5.11",
"marshmallow-sqlalchemy>=0.23.1",
# OpenAPI Documentation
"packaging>=26.2",
"apispec>=6.9.0",
"apispec-oneofschema>=3.0.2",
"apispec-webframeworks>=1.2.0",
"webargs>=8.7.1",
# Minimum version that supports datetimes on the (x-)axis.
"uniplot>=0.12.1",
# >=2.5.2: https://github.com/marshmallow-code/flask-marshmallow/issues/262
"Flask-SQLAlchemy>=2.5.2",
# flask should be after all the flask plugins, because setup might find they ARE flask
"flask>=3.1.3", # https://github.com/FlexMeasures/flexmeasures/security/dependabot/588
"vl-convert-python>=1.9.0.post1",
# Forecaster: TrainPredictPipeline
"lightgbm>=4.6.0",
"darts>=0.41.0",
# LP solver. Required to test the function device_scheduler which is used by the StorageScheduler
"highspy>=1.12",
"rq-win>=0.4.2",
# Below: minimum requirements solely here for security reasons
"urllib3>=2.7.0", # https://github.com/FlexMeasures/flexmeasures/security/dependabot/602 (and 603)
"cryptography>=48.0.1", # https://github.com/FlexMeasures/flexmeasures/security/dependabot/606
"pyopenssl>=26.0.0", # https://github.com/FlexMeasures/flexmeasures/security/dependabot/590
"werkzeug>=3.1.6", # https://github.com/FlexMeasures/flexmeasures/security/dependabot/587
"pillow>=12.2.0", # https://github.com/FlexMeasures/flexmeasures/security/dependabot/599
"pyasn1>=0.6.4", # https://github.com/FlexMeasures/flexmeasures/security/dependabot/622 (and 623)
"setuptools>=83.0.0", # https://github.com/FlexMeasures/flexmeasures/security/dependabot/621
]
[project.urls]
Homepage = "https://flexmeasures.io"
Documentation = "https://flexmeasures.readthedocs.io/"
"Source code" = "https://github.com/FlexMeasures/flexmeasures"
[project.scripts]
flexmeasures = "flexmeasures.utils.app_utils:flexmeasures_cli"
[tool.poe.tasks.test]
# Simple for now, but allows us to configure tests in one place later.
help = "Run the test suite."
cmd = "pytest"
[tool.poe.tasks.show-file-space]
help = "Show where file space is being used."
shell = "du --summarize --human-readable --total ./* ./.[a-zA-Z]* | sort -h"
[tool.poe.tasks.upgrade-db]
help = "Upgrade the database to the latest migration."
shell = """
flask db current
flask db upgrade
flask db current
"""
[tool.poe.tasks.show-data-model]
help = "Show the data model as a PNG picture. Use --uml to show the UML diagram, or --schema to show the schema diagram."
script = "flexmeasures.data.scripts.visualize_data_model"
[tool.poe.tasks.clean-db]
help = "Clean the database."
# This is a "cmd" and not a "shell" task on purpose.
# Poe feeds the content of a shell task to the interpreter over stdin,
# which leaves the script without a terminal to read from,
# so its password and confirmation prompts would silently read empty.
# A cmd task runs the script directly and lets it inherit our stdin.
# The arguments have to be named explicitly, because poe otherwise only exposes them as environment variables.
cmd = "flexmeasures/data/scripts/clean_database.sh ${db_name} ${db_user}"
use_exec = true
args = [
{name = "db-name", required = true, help = "The name of the database to clean."},
{name = "db-user", help = "The user to clean the database for."},
]
[tool.poe.tasks.cli-autocomplete]
help = "Set up CLI autocomplete for the flexmeasures command."
shell = "flexmeasures/cli/scripts/add_scripts_path.sh"
args = [
{name = "extension", help = "Shell extension type."}
]
[tool.poe.tasks.type-check]
help = "Run mypy type checking on Python files with type hints (excluding legacy code)."
shell = """
files=$(find flexmeasures \
-not \\( -path flexmeasures/data/scripts -prune \\) \
-not \\( -path flexmeasures/data/models -prune \\) \
-not \\( -path flexmeasures/data/services -prune \\) \
-name \\*.py | xargs grep -l "from typing import")
mypy --follow-imports skip --ignore-missing-imports $files
"""
[tool.poe.tasks.update-docs]
help = "Update the documentation and OpenAPI specifications"
shell = """
printf "Installing docs dependencies ...\n"
uv sync --group docs --inexact
printf "Generating OpenAPI specifications ...\n"
uv run poe generate-open-api-specs
printf "Creating documentation ...\n"
sphinx-build -M html documentation flexmeasures/ui/static/documentation -W --keep-going -n
# Make sphinxcontrib-httpdomain links point to openapi-sphinx links.
python << 'EOF'
from pathlib import Path
doc_file = Path('flexmeasures/ui/static/documentation/html/api/v3_0.html')
doc_file.write_text(doc_file.read_text().replace('(id)', 'id'))
EOF
"""
env = { GEN_CODE_DOCS = "False" }
args = [
{name = "gen-code-docs", help = "Generate code documentation", default = "False"}
]
[tool.poe.tasks.generate-open-api-specs]
help = "Generate OpenAPI specifications"
script = "flexmeasures.api.scripts.generate_open_api_specs"
env = {FLEXMEASURES_ENV = "documentation", FLEXMEASURES_PLUGINS = ""}
[tool.poe.tasks.changelog-check]
help = "List merged PRs since the last tag, to help assemble changelog.rst entries (does not write any files)."
shell = "ci/list-merged-prs-since-tag.sh"
args = [
{name = "since", help = "Git tag to diff from (default: latest tag reachable from HEAD)", default = ""},
]
[dependency-groups]
dev = [
"black==26.3.1",
"flake8==7.1.1",
"flake8-blind-except",
"pytest-runner",
"watchdog",
"pyinstrument",
"poethepoet>=0.41.0",
# pre-commit runs the hooks in CI, so keep it locked rather than resolved at run time.
"pre-commit>=4.6",
# Type checking
"mypy>=0.902",
"types-pytz>=2025.2.0.20251108",
"types-requests>=2.32.4.20260107",
"types-flask>=1.1.6",
"types-click>=7.1.8",
"types-redis>=4.6.0.20241004",
"types-tzlocal>=5.1.0.1",
"types-python-dateutil>=2.9.0.20260124",
"types-setuptools>=82.0.0.20260210",
"types-tabulate>=0.9.0.20241207",
"types-pyyaml>=6.0.12.20250915",
]
docs = [
"sphinx>=7.5",
"sphinx-rtd-theme>=1.2",
"sphinxcontrib.httpdomain>=2.0",
"sphinx_fontawesome>=0.0.6",
"sphinx_copybutton>=0.5.2",
"sphinx-tabs>=3.5.0",
"sphinxcontrib-mermaid>=2.0",
"sphinxcontrib-openapi>=0.8.4",
]
visualize-data-model = [
"pillow>=12.1.1",
"sqlalchemy-schemadisplay>=2.0",
"packaging",
]
test = [
"pytest>=9.0.2",
"pytest-flask>=1.3.0",
"pytest-sugar>=1.1.1",
"pytest-cov>=7.0.0",
# to test calls to the API
"requests>=2.32.5",
# to test responses from our API, as given to our UI code
"requests-mock>=1.12.1",
# lets tests run successfully in containers
"fakeredis>=2.33.0",
# required with fakeredis, maybe because we use rq
"lupa>=2.6",
"pytest-mock>=3.15.1",
"pytest-runner>=6.0.1",
# to run the UI's JavaScript modules in a browser, see flexmeasures/ui/tests/js
"selenium>=4.36.0",
]
[tool.hatch.build.targets.wheel]
packages = ["flexmeasures"]
[tool.hatch.version]
source = "vcs"
[tool.pytest.ini_options]
addopts = "--strict-markers --ignore=docker-compose-data"
markers = [
"skip_github: skip test in GitHub Actions. Useful in case the test passes, but breaks the test suite on GH Actions."
]
# Restrict uv's dependency resolution to the three real target platforms.
# Without this, uv generates fork markers for impossible platform combinations
# (e.g. os_name == 'nt' AND sys_platform == 'darwin'), which causes
# `uv sync --locked` to fail because the fork markers don't fully cover the
# declared environment space.
[tool.uv]
# Contributors and CI should write uv.lock with the same uv version.
# Otherwise, environment markers get reformatted, and a small dependency change comes out as a huge diff.
# This gates every uv invocation, so bumping it means bumping the pins in our workflows, Dockerfile and .readthedocs.yaml, too.
# See documentation/dev/dependency-management.rst.
required-version = "==0.12.7"
environments = [
"sys_platform == 'linux'",
"sys_platform == 'darwin'",
"sys_platform == 'win32'",
]