libres 1.3.0__tar.gz → 1.4.0__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.
- {libres-1.3.0 → libres-1.4.0}/HISTORY.rst +9 -0
- {libres-1.3.0/src/libres.egg-info → libres-1.4.0}/PKG-INFO +11 -3
- {libres-1.3.0 → libres-1.4.0}/pyproject.toml +3 -9
- {libres-1.3.0 → libres-1.4.0}/src/libres/__init__.py +1 -1
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/queries.py +1 -1
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/scheduler.py +9 -4
- {libres-1.3.0 → libres-1.4.0/src/libres.egg-info}/PKG-INFO +11 -3
- libres-1.4.0/src/libres.egg-info/requires.txt +4 -0
- {libres-1.3.0 → libres-1.4.0}/tests/test_scheduler.py +5 -4
- {libres-1.3.0 → libres-1.4.0}/tests/test_session.py +9 -3
- libres-1.3.0/src/libres.egg-info/requires.txt +0 -5
- {libres-1.3.0 → libres-1.4.0}/LICENSE +0 -0
- {libres-1.3.0 → libres-1.4.0}/MANIFEST.in +0 -0
- {libres-1.3.0 → libres-1.4.0}/README.rst +0 -0
- {libres-1.3.0 → libres-1.4.0}/docs/Makefile +0 -0
- {libres-1.3.0 → libres-1.4.0}/docs/_static/custom.css +0 -0
- {libres-1.3.0 → libres-1.4.0}/docs/_static/favicon.ico +0 -0
- {libres-1.3.0 → libres-1.4.0}/docs/_static/logo.svg +0 -0
- {libres-1.3.0 → libres-1.4.0}/docs/api.rst +0 -0
- {libres-1.3.0 → libres-1.4.0}/docs/concepts.rst +0 -0
- {libres-1.3.0 → libres-1.4.0}/docs/conf.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/docs/customizations.rst +0 -0
- {libres-1.3.0 → libres-1.4.0}/docs/faq.rst +0 -0
- {libres-1.3.0 → libres-1.4.0}/docs/index.rst +0 -0
- {libres-1.3.0 → libres-1.4.0}/docs/requirements.txt +0 -0
- {libres-1.3.0 → libres-1.4.0}/docs/under_the_hood.rst +0 -0
- {libres-1.3.0 → libres-1.4.0}/setup.cfg +0 -0
- {libres-1.3.0 → libres-1.4.0}/setup.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/.gitignore +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/context/__init__.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/context/core.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/context/exposure.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/context/registry.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/context/session.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/context/settings.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/__init__.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/__init__.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/allocation.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/base.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/blocker.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/other.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/reservation.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/reserved_slot.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/timespan.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/timestamp.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/types/__init__.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/types/json_type.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/types/utcdatetime.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/db/models/types/uuid_type.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/modules/__init__.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/modules/errors.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/modules/events.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/modules/rasterizer.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/modules/utils.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres/py.typed +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres.egg-info/SOURCES.txt +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres.egg-info/dependency_links.txt +0 -0
- {libres-1.3.0 → libres-1.4.0}/src/libres.egg-info/top_level.txt +0 -0
- {libres-1.3.0 → libres-1.4.0}/tests/test_allocation.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/tests/test_registry.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/tests/test_reservation.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/tests/test_reserved_slot.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/tests/test_scheduler_blockers.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/tests/test_test.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/tests/test_types.py +0 -0
- {libres-1.3.0 → libres-1.4.0}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: libres
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: A library to reserve things
|
|
5
5
|
Author-email: Denis Krienbühl <denis@href.ch>
|
|
6
6
|
Maintainer-email: Seantis GmbH <info@seantis.ch>
|
|
@@ -22,11 +22,10 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
22
22
|
Requires-Python: >=3.11
|
|
23
23
|
Description-Content-Type: text/x-rst
|
|
24
24
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: jsonpickle<5
|
|
26
25
|
Requires-Dist: python-dateutil
|
|
27
26
|
Requires-Dist: pytz
|
|
28
27
|
Requires-Dist: sedate>=1.0.0
|
|
29
|
-
Requires-Dist: SQLAlchemy<2.
|
|
28
|
+
Requires-Dist: SQLAlchemy<2.2.0,>=2.1.0
|
|
30
29
|
Dynamic: license-file
|
|
31
30
|
|
|
32
31
|
Libres
|
|
@@ -117,6 +116,15 @@ After this, create a new release on Github.
|
|
|
117
116
|
Changelog
|
|
118
117
|
---------
|
|
119
118
|
|
|
119
|
+
1.4.0 (15.10.2026)
|
|
120
|
+
~~~~~~~~~~~~~~~~~~~
|
|
121
|
+
|
|
122
|
+
- Adds support for SQLAlchemy 2.1
|
|
123
|
+
[Daverball]
|
|
124
|
+
|
|
125
|
+
- Drops support for SQLAlchemy 2.0
|
|
126
|
+
[Daverball]
|
|
127
|
+
|
|
120
128
|
1.3.0 (15.10.2026)
|
|
121
129
|
~~~~~~~~~~~~~~~~~~~
|
|
122
130
|
|
|
@@ -31,12 +31,10 @@ classifiers = [
|
|
|
31
31
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
32
32
|
]
|
|
33
33
|
dependencies = [
|
|
34
|
-
# FIXME: Remove this pin after upgrading to SQLAlchemy 2.1
|
|
35
|
-
"jsonpickle < 5",
|
|
36
34
|
"python-dateutil",
|
|
37
35
|
"pytz",
|
|
38
36
|
"sedate >= 1.0.0",
|
|
39
|
-
"SQLAlchemy >= 2.
|
|
37
|
+
"SQLAlchemy >= 2.1.0, < 2.2.0",
|
|
40
38
|
]
|
|
41
39
|
|
|
42
40
|
[project.urls]
|
|
@@ -75,7 +73,7 @@ lint = [
|
|
|
75
73
|
]
|
|
76
74
|
test = [
|
|
77
75
|
"jsonpickle",
|
|
78
|
-
"
|
|
76
|
+
"psycopg[binary]",
|
|
79
77
|
"pytest",
|
|
80
78
|
"pytest-codecov[git]",
|
|
81
79
|
"testing.postgresql",
|
|
@@ -96,17 +94,13 @@ dev = [
|
|
|
96
94
|
[tool.pytest.ini_options]
|
|
97
95
|
log_level = "INFO"
|
|
98
96
|
testpaths = ["tests"]
|
|
99
|
-
filterwarnings = [
|
|
100
|
-
# FIXME: Remove after upgrading to SQLAlchemy 2.1
|
|
101
|
-
'''ignore:keys will default to True in jsonpickle 5\.0\.0:DeprecationWarning''',
|
|
102
|
-
]
|
|
103
97
|
|
|
104
98
|
[tool.coverage.run]
|
|
105
99
|
branch = true
|
|
106
100
|
source = ["src"]
|
|
107
101
|
|
|
108
102
|
[tool.bumpversion]
|
|
109
|
-
current_version = "1.
|
|
103
|
+
current_version = "1.4.0"
|
|
110
104
|
commit = true
|
|
111
105
|
message = "Release {new_version}"
|
|
112
106
|
tag = true
|
|
@@ -521,7 +521,7 @@ class Queries(ContextServicesMixin):
|
|
|
521
521
|
|
|
522
522
|
# first get the session ids which are expired
|
|
523
523
|
query: Query[tuple[UUID, datetime, datetime | None]]
|
|
524
|
-
query = self.session.query(
|
|
524
|
+
query = self.session.query(
|
|
525
525
|
Reservation.session_id,
|
|
526
526
|
func.max(Reservation.created),
|
|
527
527
|
func.max(Reservation.modified)
|
|
@@ -33,7 +33,9 @@ if TYPE_CHECKING:
|
|
|
33
33
|
from collections.abc import Collection
|
|
34
34
|
from collections.abc import Iterable
|
|
35
35
|
from collections.abc import Iterator
|
|
36
|
+
from collections.abc import Sequence
|
|
36
37
|
from sedate.types import DateLike
|
|
38
|
+
from sqlalchemy.engine import Row
|
|
37
39
|
from sqlalchemy.orm import Query
|
|
38
40
|
from typing import NotRequired
|
|
39
41
|
from typing import TypeAlias
|
|
@@ -419,12 +421,12 @@ class Scheduler(ContextServicesMixin):
|
|
|
419
421
|
def allocation_dates_by_group(
|
|
420
422
|
self,
|
|
421
423
|
group: UUID
|
|
422
|
-
) -> list[
|
|
424
|
+
) -> list[Row[datetime, datetime]]:
|
|
423
425
|
|
|
424
426
|
return self.allocations_by_group(group).with_entities(
|
|
425
427
|
Allocation._start,
|
|
426
428
|
Allocation._end
|
|
427
|
-
).
|
|
429
|
+
).all()
|
|
428
430
|
|
|
429
431
|
def allocation_mirrors_by_master(
|
|
430
432
|
self,
|
|
@@ -941,7 +943,10 @@ class Scheduler(ContextServicesMixin):
|
|
|
941
943
|
if change.is_master: # (mirrors return the same values)
|
|
942
944
|
for pending in change.pending_reservations.with_entities(
|
|
943
945
|
Reservation.start, Reservation.end):
|
|
944
|
-
|
|
946
|
+
# FIXME: Technically start/end can be None, we may
|
|
947
|
+
# want to remove this ability, since we don't
|
|
948
|
+
# use it anywhere anymore
|
|
949
|
+
if not new.contains(pending.start, pending.end):
|
|
945
950
|
raise errors.AffectedPendingReservationError(
|
|
946
951
|
pending
|
|
947
952
|
)
|
|
@@ -1458,7 +1463,7 @@ class Scheduler(ContextServicesMixin):
|
|
|
1458
1463
|
# write out the slots
|
|
1459
1464
|
slots_to_reserve = []
|
|
1460
1465
|
|
|
1461
|
-
dates:
|
|
1466
|
+
dates: Sequence[_dtrange]
|
|
1462
1467
|
if reservation.target_type == 'group':
|
|
1463
1468
|
dates = self.allocation_dates_by_group(reservation.target)
|
|
1464
1469
|
else:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: libres
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: A library to reserve things
|
|
5
5
|
Author-email: Denis Krienbühl <denis@href.ch>
|
|
6
6
|
Maintainer-email: Seantis GmbH <info@seantis.ch>
|
|
@@ -22,11 +22,10 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
|
22
22
|
Requires-Python: >=3.11
|
|
23
23
|
Description-Content-Type: text/x-rst
|
|
24
24
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: jsonpickle<5
|
|
26
25
|
Requires-Dist: python-dateutil
|
|
27
26
|
Requires-Dist: pytz
|
|
28
27
|
Requires-Dist: sedate>=1.0.0
|
|
29
|
-
Requires-Dist: SQLAlchemy<2.
|
|
28
|
+
Requires-Dist: SQLAlchemy<2.2.0,>=2.1.0
|
|
30
29
|
Dynamic: license-file
|
|
31
30
|
|
|
32
31
|
Libres
|
|
@@ -117,6 +116,15 @@ After this, create a new release on Github.
|
|
|
117
116
|
Changelog
|
|
118
117
|
---------
|
|
119
118
|
|
|
119
|
+
1.4.0 (15.10.2026)
|
|
120
|
+
~~~~~~~~~~~~~~~~~~~
|
|
121
|
+
|
|
122
|
+
- Adds support for SQLAlchemy 2.1
|
|
123
|
+
[Daverball]
|
|
124
|
+
|
|
125
|
+
- Drops support for SQLAlchemy 2.0
|
|
126
|
+
[Daverball]
|
|
127
|
+
|
|
120
128
|
1.3.0 (15.10.2026)
|
|
121
129
|
~~~~~~~~~~~~~~~~~~~
|
|
122
130
|
|
|
@@ -5,12 +5,13 @@ import sedate
|
|
|
5
5
|
|
|
6
6
|
from copy import copy
|
|
7
7
|
from datetime import date, datetime, timedelta, time
|
|
8
|
+
from functools import partial
|
|
8
9
|
from libres.db.models import Reservation, Allocation
|
|
9
10
|
from libres.modules import errors, events
|
|
10
11
|
from libres.modules import utils
|
|
11
12
|
from operator import attrgetter
|
|
12
13
|
from unittest.mock import Mock
|
|
13
|
-
from sqlalchemy.exc import MultipleResultsFound, NoResultFound
|
|
14
|
+
from sqlalchemy.exc import MultipleResultsFound, NoResultFound
|
|
14
15
|
from uuid import uuid4 as new_uuid
|
|
15
16
|
|
|
16
17
|
|
|
@@ -2095,7 +2096,7 @@ def test_data_coding(scheduler: Scheduler) -> None:
|
|
|
2095
2096
|
end = datetime(2014, 1, 30, 19, 0)
|
|
2096
2097
|
|
|
2097
2098
|
# this won't work as json doesn't do datetimes by default
|
|
2098
|
-
with pytest.raises(
|
|
2099
|
+
with pytest.raises(TypeError, match=r'not JSON serializable'):
|
|
2099
2100
|
scheduler.allocate((start, end), data=data)
|
|
2100
2101
|
|
|
2101
2102
|
scheduler.rollback()
|
|
@@ -2106,8 +2107,8 @@ def test_data_coding(scheduler: Scheduler) -> None:
|
|
|
2106
2107
|
|
|
2107
2108
|
def session_provider(context: Context) -> SessionProvider:
|
|
2108
2109
|
return SessionProvider(context.get_setting('dsn'), engine_config=dict(
|
|
2109
|
-
json_serializer=jsonpickle.encode,
|
|
2110
|
-
json_deserializer=jsonpickle.decode
|
|
2110
|
+
json_serializer=partial(jsonpickle.encode, keys=True),
|
|
2111
|
+
json_deserializer=partial(jsonpickle.decode, keys=True)
|
|
2111
2112
|
))
|
|
2112
2113
|
|
|
2113
2114
|
# setting the service again will get rid of the existing cached value
|
|
@@ -7,7 +7,7 @@ from datetime import datetime
|
|
|
7
7
|
from libres.context.session import SessionProvider
|
|
8
8
|
from libres.db.models import Allocation
|
|
9
9
|
from libres.db.scheduler import Scheduler
|
|
10
|
-
from
|
|
10
|
+
from psycopg.errors import OperationalError
|
|
11
11
|
from threading import Thread
|
|
12
12
|
from uuid import uuid4 as new_uuid
|
|
13
13
|
|
|
@@ -105,7 +105,10 @@ def test_collision(scheduler: Scheduler) -> None:
|
|
|
105
105
|
exceptions = (t1.exception, t2.exception)
|
|
106
106
|
|
|
107
107
|
def is_rollback(ex: Exception | None) -> bool:
|
|
108
|
-
return
|
|
108
|
+
return (
|
|
109
|
+
isinstance(err := getattr(ex, 'orig', None), OperationalError)
|
|
110
|
+
and (err.sqlstate or '').startswith('40')
|
|
111
|
+
)
|
|
109
112
|
|
|
110
113
|
def is_nothing(ex: Exception | None) -> bool:
|
|
111
114
|
return not is_rollback(ex)
|
|
@@ -147,7 +150,10 @@ def test_non_collision(scheduler: Scheduler) -> None:
|
|
|
147
150
|
exceptions = (t1.exception, t2.exception)
|
|
148
151
|
|
|
149
152
|
def is_rollback(ex: Exception | None) -> bool:
|
|
150
|
-
return
|
|
153
|
+
return (
|
|
154
|
+
isinstance(err := getattr(ex, 'orig', None), OperationalError)
|
|
155
|
+
and (err.sqlstate or '').startswith('40')
|
|
156
|
+
)
|
|
151
157
|
|
|
152
158
|
rollbacks = list(filter(is_rollback, exceptions))
|
|
153
159
|
assert len(rollbacks) == 0
|
|
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
|
|
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
|
|
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
|