temdb 3.0.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.
- temdb/alembic.ini +29 -0
- temdb/migrations/env.py +66 -0
- temdb/migrations/script.py.mako +28 -0
- temdb/migrations/versions/.gitkeep +0 -0
- temdb/migrations/versions/20260612_0001_initial_schema.py +542 -0
- temdb/migrations/versions/20260717_ec4c96d0bf77_add_description_to_block_table.py +32 -0
- temdb/migrations/versions/20260721_44f75ed44d66_updated_at_nullable_no_server_default.py +165 -0
- temdb/migrations/versions/20260721_bec991e0d0eb_dataset_status_server_default.py +38 -0
- temdb/migrations/versions/20260801_a1d2f3e4b5c6_add_sections_run_parameters.py +67 -0
- temdb/server/__init__.py +3 -0
- temdb/server/api/__init__.py +0 -0
- temdb/server/api/v2/__init__.py +0 -0
- temdb/server/api/v2/acquisition.py +1094 -0
- temdb/server/api/v2/block.py +228 -0
- temdb/server/api/v2/cutting_session.py +229 -0
- temdb/server/api/v2/dataset.py +139 -0
- temdb/server/api/v2/lens_correction.py +121 -0
- temdb/server/api/v2/microscope.py +93 -0
- temdb/server/api/v2/quality_control.py +185 -0
- temdb/server/api/v2/roi.py +372 -0
- temdb/server/api/v2/section.py +457 -0
- temdb/server/api/v2/specimen.py +246 -0
- temdb/server/api/v2/substrate.py +180 -0
- temdb/server/api/v2/tasks.py +508 -0
- temdb/server/cli.py +48 -0
- temdb/server/config.py +46 -0
- temdb/server/database.py +75 -0
- temdb/server/dependencies.py +24 -0
- temdb/server/exception_handlers.py +109 -0
- temdb/server/ids.py +12 -0
- temdb/server/main.py +172 -0
- temdb/server/sqlmodels/__init__.py +29 -0
- temdb/server/sqlmodels/acquisition.py +101 -0
- temdb/server/sqlmodels/base.py +41 -0
- temdb/server/sqlmodels/block.py +18 -0
- temdb/server/sqlmodels/cutting_session.py +27 -0
- temdb/server/sqlmodels/dataset.py +34 -0
- temdb/server/sqlmodels/lens_correction.py +36 -0
- temdb/server/sqlmodels/microscope.py +22 -0
- temdb/server/sqlmodels/roi.py +55 -0
- temdb/server/sqlmodels/section.py +55 -0
- temdb/server/sqlmodels/specimen.py +17 -0
- temdb/server/sqlmodels/substrate.py +23 -0
- temdb/server/sqlmodels/task.py +60 -0
- temdb/server/sqlmodels/tile.py +53 -0
- temdb/server/sqlmodels/tile_partition.py +147 -0
- temdb-3.0.0.dist-info/METADATA +16 -0
- temdb-3.0.0.dist-info/RECORD +51 -0
- temdb-3.0.0.dist-info/WHEEL +4 -0
- temdb-3.0.0.dist-info/entry_points.txt +3 -0
- temdb-3.0.0.dist-info/licenses/LICENSE +11 -0
temdb/alembic.ini
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
[alembic]
|
|
2
|
+
script_location = %(here)s/migrations
|
|
3
|
+
file_template = %%(year)d%%(month).2d%%(day).2d_%%(rev)s_%%(slug)s
|
|
4
|
+
prepend_sys_path = src
|
|
5
|
+
|
|
6
|
+
[loggers]
|
|
7
|
+
keys = root,sqlalchemy,alembic
|
|
8
|
+
[handlers]
|
|
9
|
+
keys = console
|
|
10
|
+
[formatters]
|
|
11
|
+
keys = generic
|
|
12
|
+
[logger_root]
|
|
13
|
+
level = WARNING
|
|
14
|
+
handlers = console
|
|
15
|
+
[logger_sqlalchemy]
|
|
16
|
+
level = WARNING
|
|
17
|
+
handlers =
|
|
18
|
+
qualname = sqlalchemy.engine
|
|
19
|
+
[logger_alembic]
|
|
20
|
+
level = INFO
|
|
21
|
+
handlers =
|
|
22
|
+
qualname = alembic
|
|
23
|
+
[handler_console]
|
|
24
|
+
class = StreamHandler
|
|
25
|
+
args = (sys.stderr,)
|
|
26
|
+
level = NOTSET
|
|
27
|
+
formatter = generic
|
|
28
|
+
[formatter_generic]
|
|
29
|
+
format = %(levelname)-5.5s [%(name)s] %(message)s
|
temdb/migrations/env.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
import sqlalchemy as sa
|
|
5
|
+
from alembic import context
|
|
6
|
+
from sqlalchemy.ext.asyncio import async_engine_from_config
|
|
7
|
+
|
|
8
|
+
from temdb.server.config import get_config
|
|
9
|
+
from temdb.server.sqlmodels import Base
|
|
10
|
+
|
|
11
|
+
target_metadata = Base.metadata
|
|
12
|
+
|
|
13
|
+
MIGRATION_LOCK_KEY = 7_323_488_513_002_001
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def include_object(obj, name, type_, reflected, compare_to):
|
|
17
|
+
if type_ == "table" and name.startswith("tile_d_"):
|
|
18
|
+
return False
|
|
19
|
+
return True
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _database_url() -> str:
|
|
23
|
+
url = os.environ.get("TEMDB_MIGRATION_URL") or get_config().database_url
|
|
24
|
+
if not url:
|
|
25
|
+
raise RuntimeError("No database_url configured (set TEMDB_MIGRATION_URL or dev.env)")
|
|
26
|
+
return url
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _configure(connection):
|
|
30
|
+
connection.execute(sa.text(f"SELECT pg_advisory_lock({MIGRATION_LOCK_KEY})"))
|
|
31
|
+
context.configure(
|
|
32
|
+
connection=connection,
|
|
33
|
+
target_metadata=target_metadata,
|
|
34
|
+
include_object=include_object,
|
|
35
|
+
compare_type=True,
|
|
36
|
+
compare_server_default=True,
|
|
37
|
+
)
|
|
38
|
+
with context.begin_transaction():
|
|
39
|
+
context.run_migrations()
|
|
40
|
+
connection.commit()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def run_migrations_offline():
|
|
44
|
+
context.configure(
|
|
45
|
+
url=_database_url(),
|
|
46
|
+
target_metadata=target_metadata,
|
|
47
|
+
literal_binds=True,
|
|
48
|
+
include_object=include_object,
|
|
49
|
+
)
|
|
50
|
+
with context.begin_transaction():
|
|
51
|
+
context.run_migrations()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
async def run_async_migrations():
|
|
55
|
+
cfg = context.config.get_section(context.config.config_ini_section, {})
|
|
56
|
+
cfg["sqlalchemy.url"] = _database_url()
|
|
57
|
+
engine = async_engine_from_config(cfg, prefix="sqlalchemy.")
|
|
58
|
+
async with engine.connect() as conn:
|
|
59
|
+
await conn.run_sync(_configure)
|
|
60
|
+
await engine.dispose()
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
if context.is_offline_mode():
|
|
64
|
+
run_migrations_offline()
|
|
65
|
+
else:
|
|
66
|
+
asyncio.run(run_async_migrations())
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""${message}
|
|
2
|
+
|
|
3
|
+
Revision ID: ${up_revision}
|
|
4
|
+
Revises: ${down_revision | comma,n}
|
|
5
|
+
Create Date: ${create_date}
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
from collections.abc import Sequence
|
|
9
|
+
|
|
10
|
+
import sqlalchemy as sa
|
|
11
|
+
from alembic import op
|
|
12
|
+
${imports if imports else ""}
|
|
13
|
+
|
|
14
|
+
# revision identifiers, used by Alembic.
|
|
15
|
+
revision: str = ${repr(up_revision)}
|
|
16
|
+
down_revision: str | Sequence[str] | None = ${repr(down_revision)}
|
|
17
|
+
branch_labels: str | Sequence[str] | None = ${repr(branch_labels)}
|
|
18
|
+
depends_on: str | Sequence[str] | None = ${repr(depends_on)}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def upgrade() -> None:
|
|
22
|
+
"""Upgrade schema."""
|
|
23
|
+
${upgrades if upgrades else "pass"}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def downgrade() -> None:
|
|
27
|
+
"""Downgrade schema."""
|
|
28
|
+
${downgrades if downgrades else "pass"}
|
|
File without changes
|