temdb 3.0.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.
Files changed (50) hide show
  1. temdb-3.0.0/.gitignore +155 -0
  2. temdb-3.0.0/LICENSE +11 -0
  3. temdb-3.0.0/PKG-INFO +16 -0
  4. temdb-3.0.0/alembic.ini +29 -0
  5. temdb-3.0.0/migrations/env.py +66 -0
  6. temdb-3.0.0/migrations/script.py.mako +28 -0
  7. temdb-3.0.0/migrations/versions/.gitkeep +0 -0
  8. temdb-3.0.0/migrations/versions/20260612_0001_initial_schema.py +542 -0
  9. temdb-3.0.0/migrations/versions/20260717_ec4c96d0bf77_add_description_to_block_table.py +32 -0
  10. temdb-3.0.0/migrations/versions/20260721_44f75ed44d66_updated_at_nullable_no_server_default.py +165 -0
  11. temdb-3.0.0/migrations/versions/20260721_bec991e0d0eb_dataset_status_server_default.py +38 -0
  12. temdb-3.0.0/migrations/versions/20260801_a1d2f3e4b5c6_add_sections_run_parameters.py +67 -0
  13. temdb-3.0.0/pyproject.toml +33 -0
  14. temdb-3.0.0/src/temdb/server/__init__.py +3 -0
  15. temdb-3.0.0/src/temdb/server/api/__init__.py +0 -0
  16. temdb-3.0.0/src/temdb/server/api/v2/__init__.py +0 -0
  17. temdb-3.0.0/src/temdb/server/api/v2/acquisition.py +1094 -0
  18. temdb-3.0.0/src/temdb/server/api/v2/block.py +228 -0
  19. temdb-3.0.0/src/temdb/server/api/v2/cutting_session.py +229 -0
  20. temdb-3.0.0/src/temdb/server/api/v2/dataset.py +139 -0
  21. temdb-3.0.0/src/temdb/server/api/v2/lens_correction.py +121 -0
  22. temdb-3.0.0/src/temdb/server/api/v2/microscope.py +93 -0
  23. temdb-3.0.0/src/temdb/server/api/v2/quality_control.py +185 -0
  24. temdb-3.0.0/src/temdb/server/api/v2/roi.py +372 -0
  25. temdb-3.0.0/src/temdb/server/api/v2/section.py +457 -0
  26. temdb-3.0.0/src/temdb/server/api/v2/specimen.py +246 -0
  27. temdb-3.0.0/src/temdb/server/api/v2/substrate.py +180 -0
  28. temdb-3.0.0/src/temdb/server/api/v2/tasks.py +508 -0
  29. temdb-3.0.0/src/temdb/server/cli.py +48 -0
  30. temdb-3.0.0/src/temdb/server/config.py +46 -0
  31. temdb-3.0.0/src/temdb/server/database.py +75 -0
  32. temdb-3.0.0/src/temdb/server/dependencies.py +24 -0
  33. temdb-3.0.0/src/temdb/server/exception_handlers.py +109 -0
  34. temdb-3.0.0/src/temdb/server/ids.py +12 -0
  35. temdb-3.0.0/src/temdb/server/main.py +172 -0
  36. temdb-3.0.0/src/temdb/server/sqlmodels/__init__.py +29 -0
  37. temdb-3.0.0/src/temdb/server/sqlmodels/acquisition.py +101 -0
  38. temdb-3.0.0/src/temdb/server/sqlmodels/base.py +41 -0
  39. temdb-3.0.0/src/temdb/server/sqlmodels/block.py +18 -0
  40. temdb-3.0.0/src/temdb/server/sqlmodels/cutting_session.py +27 -0
  41. temdb-3.0.0/src/temdb/server/sqlmodels/dataset.py +34 -0
  42. temdb-3.0.0/src/temdb/server/sqlmodels/lens_correction.py +36 -0
  43. temdb-3.0.0/src/temdb/server/sqlmodels/microscope.py +22 -0
  44. temdb-3.0.0/src/temdb/server/sqlmodels/roi.py +55 -0
  45. temdb-3.0.0/src/temdb/server/sqlmodels/section.py +55 -0
  46. temdb-3.0.0/src/temdb/server/sqlmodels/specimen.py +17 -0
  47. temdb-3.0.0/src/temdb/server/sqlmodels/substrate.py +23 -0
  48. temdb-3.0.0/src/temdb/server/sqlmodels/task.py +60 -0
  49. temdb-3.0.0/src/temdb/server/sqlmodels/tile.py +53 -0
  50. temdb-3.0.0/src/temdb/server/sqlmodels/tile_partition.py +147 -0
temdb-3.0.0/.gitignore ADDED
@@ -0,0 +1,155 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
temdb-3.0.0/LICENSE ADDED
@@ -0,0 +1,11 @@
1
+ Copyright 2026 Allen Institute
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
temdb-3.0.0/PKG-INFO ADDED
@@ -0,0 +1,16 @@
1
+ Metadata-Version: 2.5
2
+ Name: temdb
3
+ Version: 3.0.0
4
+ Summary: TEMdb - Metadata database server
5
+ License-Expression: BSD-3-Clause
6
+ License-File: LICENSE
7
+ Requires-Python: >=3.10
8
+ Requires-Dist: alembic>=1.18
9
+ Requires-Dist: asyncpg>=0.31
10
+ Requires-Dist: fastapi>=0.136
11
+ Requires-Dist: pydantic-settings>=2.14
12
+ Requires-Dist: pydantic>=2.13
13
+ Requires-Dist: sqlalchemy[asyncio]>=2.1.0b2
14
+ Requires-Dist: temdb-models==3.0.0
15
+ Requires-Dist: uuid-utils>=0.16
16
+ Requires-Dist: uvicorn>=0.49
@@ -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
@@ -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