weightsdb 0.2.0__py3-none-any.whl
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.
- weightsdb/__about__.py +1 -0
- weightsdb/__init__.py +71 -0
- weightsdb/backup.py +610 -0
- weightsdb/engine.py +229 -0
- weightsdb/errors.py +83 -0
- weightsdb/health.py +318 -0
- weightsdb/migrations.py +328 -0
- weightsdb/py.typed +0 -0
- weightsdb/redaction.py +26 -0
- weightsdb/session.py +115 -0
- weightsdb/testing.py +131 -0
- weightsdb/types.py +187 -0
- weightsdb-0.2.0.dist-info/METADATA +96 -0
- weightsdb-0.2.0.dist-info/RECORD +16 -0
- weightsdb-0.2.0.dist-info/WHEEL +4 -0
- weightsdb-0.2.0.dist-info/licenses/LICENSE +201 -0
weightsdb/types.py
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"""weightsdb.types — portable column types, the ULID primary key, and the one sanctioned upsert.
|
|
2
|
+
|
|
3
|
+
The type behaviour here is a **major** compatibility contract (spec §19): changing how
|
|
4
|
+
``UtcDateTime`` or ``PortableJSON`` serialize would require a data migration in every consumer.
|
|
5
|
+
Moved from FreeWeight's ``infrastructure.db.types`` and ``infrastructure.db.upsert``, both written
|
|
6
|
+
"as if they were WeightsDB's own" modules for exactly this move (ADR-0011); behaviour is unchanged.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from datetime import UTC, datetime
|
|
12
|
+
from typing import TYPE_CHECKING, Any
|
|
13
|
+
|
|
14
|
+
from baseaicore import ValidationError, new_id
|
|
15
|
+
from sqlalchemy import JSON, DateTime, Float, String
|
|
16
|
+
from sqlalchemy.dialects import postgresql, sqlite
|
|
17
|
+
from sqlalchemy.dialects.postgresql import JSONB
|
|
18
|
+
from sqlalchemy.orm import Mapped, mapped_column
|
|
19
|
+
from sqlalchemy.types import TypeDecorator
|
|
20
|
+
|
|
21
|
+
if TYPE_CHECKING:
|
|
22
|
+
from sqlalchemy.engine import Dialect
|
|
23
|
+
from sqlalchemy.orm import DeclarativeBase, Session
|
|
24
|
+
from sqlalchemy.types import TypeEngine
|
|
25
|
+
|
|
26
|
+
__all__ = ["PortableJSON", "UtcDateTime", "measurement_columns", "ulid_primary_key", "upsert"]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class UtcDateTime(TypeDecorator[datetime]):
|
|
30
|
+
"""Stores a timezone-aware UTC instant portably across SQLite and PostgreSQL.
|
|
31
|
+
|
|
32
|
+
SQLite has no reliable native storage for a timezone-aware value — its ``DATETIME`` affinity
|
|
33
|
+
stores whatever ``isoformat()`` produces as text, and the default parser does not round-trip a
|
|
34
|
+
UTC-offset suffix cleanly. This type sidesteps that dialect trap entirely rather than working
|
|
35
|
+
around it: every bound value is converted to UTC and stored **naive**, and every value read
|
|
36
|
+
back has UTC tzinfo reattached. The instant stored is identical either way; only the
|
|
37
|
+
representation on disk changes, and the same naive-UTC-underneath approach behaves identically
|
|
38
|
+
on PostgreSQL, so there is exactly one code path for both dialects.
|
|
39
|
+
|
|
40
|
+
A naive input is rejected rather than assumed to already be UTC (spec §11.3) — silently
|
|
41
|
+
guessing here is exactly the kind of ambiguity that breaks a timestamp comparison months later,
|
|
42
|
+
on whichever row happened to be written by the one caller that forgot a timezone.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
impl = DateTime
|
|
46
|
+
cache_ok = True
|
|
47
|
+
|
|
48
|
+
def process_bind_param(self, value: datetime | None, dialect: Dialect) -> datetime | None:
|
|
49
|
+
"""Convert an aware datetime to naive UTC for storage, or raise on a naive input."""
|
|
50
|
+
if value is None:
|
|
51
|
+
return None
|
|
52
|
+
if value.tzinfo is None or value.tzinfo.utcoffset(value) is None:
|
|
53
|
+
raise ValidationError(
|
|
54
|
+
"UtcDateTime requires a timezone-aware datetime; got a naive value "
|
|
55
|
+
f"{value!r}. Use baseaicore.utc_now() or attach a timezone explicitly.",
|
|
56
|
+
details={"value": repr(value)},
|
|
57
|
+
)
|
|
58
|
+
return value.astimezone(UTC).replace(tzinfo=None)
|
|
59
|
+
|
|
60
|
+
def process_result_value(self, value: datetime | None, dialect: Dialect) -> datetime | None:
|
|
61
|
+
"""Reattach UTC tzinfo to the naive value read back from either dialect."""
|
|
62
|
+
if value is None:
|
|
63
|
+
return None
|
|
64
|
+
return value.replace(tzinfo=UTC) if value.tzinfo is None else value.astimezone(UTC)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
class PortableJSON(TypeDecorator[Any]):
|
|
68
|
+
"""JSON storage that becomes ``JSONB`` on PostgreSQL and plain ``JSON`` elsewhere.
|
|
69
|
+
|
|
70
|
+
SQLAlchemy's generic ``JSON`` type already round-trips nested structures and unicode correctly
|
|
71
|
+
on SQLite; the only dialect-specific behaviour needed is upgrading to ``JSONB`` on PostgreSQL
|
|
72
|
+
for indexing and containment-query support later in the suite's life.
|
|
73
|
+
"""
|
|
74
|
+
|
|
75
|
+
impl = JSON
|
|
76
|
+
cache_ok = True
|
|
77
|
+
|
|
78
|
+
def load_dialect_impl(self, dialect: Dialect) -> TypeEngine[Any]:
|
|
79
|
+
"""Return ``JSONB`` on PostgreSQL, else the generic ``JSON`` implementation."""
|
|
80
|
+
if dialect.name == "postgresql":
|
|
81
|
+
return dialect.type_descriptor(JSONB())
|
|
82
|
+
return dialect.type_descriptor(JSON())
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def ulid_primary_key() -> Mapped[str]:
|
|
86
|
+
"""Return a ``CHAR(26)`` ULID primary key column, defaulted from :func:`baseaicore.new_id`.
|
|
87
|
+
|
|
88
|
+
Time-sortable, safe to expose in URLs and logs, and needs no cross-process sequence
|
|
89
|
+
coordination (database standards §3). The default is a plain callable rather than a
|
|
90
|
+
server-side default so it works identically on SQLite and PostgreSQL without a
|
|
91
|
+
dialect-specific ``DEFAULT`` expression.
|
|
92
|
+
"""
|
|
93
|
+
return mapped_column(String(26), primary_key=True, default=new_id)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def measurement_columns(name: str) -> tuple[Mapped[float | None], Mapped[str | None]]:
|
|
97
|
+
"""Return the ``(<name>, <name>_unavailable_reason)`` column pair for a ``Measurement`` field.
|
|
98
|
+
|
|
99
|
+
``NULL`` alone never means "not measurable" (ADR-0016); a table storing a value that may be
|
|
100
|
+
``baseaicore.measurement.UNSUPPORTED`` uses this pair rather than a single nullable column, so
|
|
101
|
+
"not yet measured" and "not measurable here, and here is why" stay distinguishable. The names
|
|
102
|
+
are fixed, not suggested: a metadata scan finds no unpaired measurement column across every
|
|
103
|
+
consumer's tables.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
name: The measurement's base name; the reason column is ``f"{name}_unavailable_reason"``.
|
|
107
|
+
|
|
108
|
+
Returns:
|
|
109
|
+
A ``(value_column, reason_column)`` pair. The caller assigns them to two class attributes
|
|
110
|
+
named ``name`` and ``f"{name}_unavailable_reason"`` respectively — this function does not
|
|
111
|
+
(and cannot) name the attributes itself, only build the columns that belong under those
|
|
112
|
+
names.
|
|
113
|
+
"""
|
|
114
|
+
value_column: Mapped[float | None] = mapped_column(Float, nullable=True)
|
|
115
|
+
reason_column: Mapped[str | None] = mapped_column(String, nullable=True)
|
|
116
|
+
return value_column, reason_column
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def upsert(
|
|
120
|
+
session: Session,
|
|
121
|
+
model: type[DeclarativeBase],
|
|
122
|
+
values: dict[str, Any],
|
|
123
|
+
*,
|
|
124
|
+
index_elements: list[str],
|
|
125
|
+
no_update: frozenset[str] = frozenset(),
|
|
126
|
+
) -> None:
|
|
127
|
+
"""Insert ``values`` as a new row, or update the existing row conflicting on ``index_elements``.
|
|
128
|
+
|
|
129
|
+
The dialect-correct ``INSERT ... ON CONFLICT (index_elements) DO UPDATE SET ...`` for a plain
|
|
130
|
+
(non-partial) unique index or constraint — the suite's one sanctioned upsert (ADR-0006).
|
|
131
|
+
Select-then-insert is a race under both dialects, and a hand-written ``ON CONFLICT`` is how a
|
|
132
|
+
dialect-specific variant gets in; this is the single place that emits one.
|
|
133
|
+
|
|
134
|
+
The ``UPDATE`` branch touches every column named in ``values`` **except** those listed in
|
|
135
|
+
``no_update`` — which exists for exactly one kind of column: one that must be set on the
|
|
136
|
+
initial insert from the same clock the caller is already using (so a test can assert its
|
|
137
|
+
value), but must never move on a later sighting, such as a ``first_seen_at``. Passing it as a
|
|
138
|
+
plain keyword to ``Column.default`` would make it non-deterministic in tests; omitting it from
|
|
139
|
+
``values`` entirely would make it impossible to set to anything but wall-clock time on the very
|
|
140
|
+
first insert. ``no_update`` is how both are true at once. Any column present in neither
|
|
141
|
+
``values`` nor ``index_elements`` still receives its normal ``Column.default`` on the initial
|
|
142
|
+
insert, exactly as a plain ``INSERT`` would.
|
|
143
|
+
|
|
144
|
+
Not usable against a **partial** unique index (one with a ``WHERE`` clause) — PostgreSQL and
|
|
145
|
+
SQLite both require the same ``WHERE`` predicate to be repeated on the conflict target for that
|
|
146
|
+
case, which this function does not thread through; a caller with that shape needs explicit
|
|
147
|
+
update-then-insert logic instead. This function is for the ordinary single-natural-key case.
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
session: The caller's active session; never opened here.
|
|
151
|
+
model: The mapped class to upsert against.
|
|
152
|
+
values: Column values for the insert; also the conflict ``SET`` clause, minus
|
|
153
|
+
``no_update``. Must not be empty.
|
|
154
|
+
index_elements: The column names forming the unique index or constraint to conflict on.
|
|
155
|
+
no_update: Columns present in ``values`` (for the insert) that must never appear in the
|
|
156
|
+
conflict ``SET`` clause.
|
|
157
|
+
|
|
158
|
+
Raises:
|
|
159
|
+
ValueError: ``values`` is empty, or ``session`` is bound to a dialect other than SQLite or
|
|
160
|
+
PostgreSQL (database standards §2 — only these two are supported).
|
|
161
|
+
"""
|
|
162
|
+
if not values:
|
|
163
|
+
raise ValueError("upsert() requires at least one column in `values`.")
|
|
164
|
+
|
|
165
|
+
dialect_name = session.get_bind().dialect.name
|
|
166
|
+
if dialect_name == "sqlite":
|
|
167
|
+
sqlite_insert = sqlite.insert(model).values(**values)
|
|
168
|
+
session.execute(
|
|
169
|
+
sqlite_insert.on_conflict_do_update(
|
|
170
|
+
index_elements=index_elements,
|
|
171
|
+
set_={key: sqlite_insert.excluded[key] for key in values if key not in no_update},
|
|
172
|
+
)
|
|
173
|
+
)
|
|
174
|
+
elif dialect_name == "postgresql":
|
|
175
|
+
postgresql_insert = postgresql.insert(model).values(**values)
|
|
176
|
+
session.execute(
|
|
177
|
+
postgresql_insert.on_conflict_do_update(
|
|
178
|
+
index_elements=index_elements,
|
|
179
|
+
set_={
|
|
180
|
+
key: postgresql_insert.excluded[key] for key in values if key not in no_update
|
|
181
|
+
},
|
|
182
|
+
)
|
|
183
|
+
)
|
|
184
|
+
else:
|
|
185
|
+
raise ValueError(
|
|
186
|
+
f"upsert() supports sqlite and postgresql only; got dialect {dialect_name!r}."
|
|
187
|
+
)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: weightsdb
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Shared SQLAlchemy + Alembic plumbing: engines, sessions, pragmas, migrations, backup and health. No application table, no shared schema.
|
|
5
|
+
Project-URL: Homepage, https://github.com/JPKell/WeightsDB
|
|
6
|
+
Project-URL: Documentation, https://github.com/JPKell/WeightsDB/tree/main/docs
|
|
7
|
+
Project-URL: Changelog, https://github.com/JPKell/WeightsDB/blob/main/CHANGELOG.md
|
|
8
|
+
Author: Local AI Suite contributors
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.12
|
|
19
|
+
Requires-Dist: alembic<2,>=1.13
|
|
20
|
+
Requires-Dist: baseaicore<0.5,>=0.4
|
|
21
|
+
Requires-Dist: sqlalchemy<3,>=2.0.30
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: import-linter<3,>=2.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: mypy<2,>=1.11; extra == 'dev'
|
|
25
|
+
Requires-Dist: psycopg[binary]<4,>=3.2; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest-cov<6,>=5; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-randomly<4,>=3; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest<10,>=9.0.3; extra == 'dev'
|
|
29
|
+
Requires-Dist: respx<1,>=0.21; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff<1,>=0.6; extra == 'dev'
|
|
31
|
+
Provides-Extra: postgres
|
|
32
|
+
Requires-Dist: psycopg[binary]<4,>=3.2; extra == 'postgres'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# WeightsDB
|
|
36
|
+
|
|
37
|
+
Shared SQLAlchemy + Alembic plumbing: engines, sessions, pragmas, migrations, backup and health. No application table, no shared schema.
|
|
38
|
+
|
|
39
|
+
**Status:** Phases 1–3 complete — engine, sessions, types, migrations, backup/restore and health
|
|
40
|
+
are implemented and tested on SQLite (PostgreSQL exercised wherever a server is configured; see
|
|
41
|
+
[docs/packages/weightsdb/development-plan.md](docs/packages/weightsdb/development-plan.md)).
|
|
42
|
+
Extracted from FreeWeight's `infrastructure.db` per ADR-0011; FreeWeight itself adopts this package
|
|
43
|
+
in its own Phase 12 — see [docs/adoption-checklist.md](docs/adoption-checklist.md).
|
|
44
|
+
|
|
45
|
+
Part of the **Local AI Suite**.
|
|
46
|
+
|
|
47
|
+
## Install
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install weightsdb
|
|
51
|
+
# or, with PostgreSQL support:
|
|
52
|
+
pip install "weightsdb[postgres]"
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Quickstart
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from weightsdb import create_engine_for, session_factory, session_scope
|
|
59
|
+
|
|
60
|
+
engine = create_engine_for("sqlite:///./myapp.sqlite3")
|
|
61
|
+
factory = session_factory(engine)
|
|
62
|
+
with session_scope(factory) as session:
|
|
63
|
+
...
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
See [docs/quickstart.md](docs/quickstart.md) for the full walkthrough (engine, schema, sessions,
|
|
67
|
+
upserts, migrations, backup/restore, health, and testing your own application against it), and
|
|
68
|
+
[docs/packages/weightsdb/spec.md](docs/packages/weightsdb/spec.md) §20 for the formal acceptance
|
|
69
|
+
criteria.
|
|
70
|
+
|
|
71
|
+
## Documentation
|
|
72
|
+
|
|
73
|
+
Project documentation lives under [`docs/`](docs/README.md). Start with [`docs/README.md`](docs/README.md).
|
|
74
|
+
|
|
75
|
+
| Read this | For |
|
|
76
|
+
|---|---|
|
|
77
|
+
| [docs/quickstart.md](docs/quickstart.md) | Get started: engine, schema, sessions, migrations, backup, health |
|
|
78
|
+
| [docs/adoption-checklist.md](docs/adoption-checklist.md) | FreeWeight Phase 12: what to delete, what changed shape, what must still pass |
|
|
79
|
+
| [docs/packages/weightsdb/spec.md](docs/packages/weightsdb/spec.md) | Purpose, scope, non-goals, public contracts, configuration, acceptance criteria |
|
|
80
|
+
| [docs/packages/weightsdb/development-plan.md](docs/packages/weightsdb/development-plan.md) | The phased build plan: goals, work, tests, acceptance criteria per phase |
|
|
81
|
+
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
python -m venv .venv && source .venv/bin/activate
|
|
86
|
+
pip install -e ".[dev]"
|
|
87
|
+
pre-commit install
|
|
88
|
+
pytest -m "not live and not performance"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
See [`CONTRIBUTING.md`](CONTRIBUTING.md) for the full workflow and [`SECURITY.md`](SECURITY.md) for
|
|
92
|
+
how to report a vulnerability.
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
|
|
96
|
+
Apache-2.0 — see [`LICENSE`](LICENSE).
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
weightsdb/__about__.py,sha256=Zn1KFblwuFHiDRdRAiRnDBRkbPttWh44jKa5zG2ov0E,22
|
|
2
|
+
weightsdb/__init__.py,sha256=gA6ZKqsy4xmGxg5bGXFRzNYAWpXS_EATphWERXczP1E,1846
|
|
3
|
+
weightsdb/backup.py,sha256=JR2pMKem_Ed6C_8v7j8_S9erwKWmm3-mQ6PWHW3lZYA,26694
|
|
4
|
+
weightsdb/engine.py,sha256=dUz155_nx7cHyVTInhzJryoJO-qZEOFpiFXMyCCgMAo,11876
|
|
5
|
+
weightsdb/errors.py,sha256=Q1hCnhLjFeL4zCNGzfXN9dmX-TKpw7HL6nDcgBPBJLg,2564
|
|
6
|
+
weightsdb/health.py,sha256=pTkae4eBuyQw7U5xu9UmPO2fCInhNiWXVg-nEk4BgQw,12430
|
|
7
|
+
weightsdb/migrations.py,sha256=QJg5JzjfzYiJtM-MPyKvKCkKxONKRUpes_EFeb2Zumg,15549
|
|
8
|
+
weightsdb/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
weightsdb/redaction.py,sha256=_lHPcGxsHZGfa7jbOTKFPOKfUVIVeiMMOHCuc8ppPpw,1002
|
|
10
|
+
weightsdb/session.py,sha256=3psyDsNnegUjrONkbqKhPVDTslia4H0emIV6ba8FrNw,4969
|
|
11
|
+
weightsdb/testing.py,sha256=gD7x6wDCTYDDo6FEfN0FfbmGYm7pAInSDVE--QsuCMU,5281
|
|
12
|
+
weightsdb/types.py,sha256=s70k9EJereaKACjJa9R4IUCeVBz94FG1iKXdEUmTIOk,9316
|
|
13
|
+
weightsdb-0.2.0.dist-info/METADATA,sha256=BP4grajj29cEPeFw0sdColAq9CPtBIqXV9pp1IhZnNY,3908
|
|
14
|
+
weightsdb-0.2.0.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
15
|
+
weightsdb-0.2.0.dist-info/licenses/LICENSE,sha256=Z_u6VqnVuMVvUeE3gaeA9X5qn2CwG8ytbLZ_0q7EPAQ,11356
|
|
16
|
+
weightsdb-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 the weightsdb contributors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|