lhcbdiracx-db 0.0.1a3__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.
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: lhcbdiracx-db
3
+ Version: 0.0.1a3
4
+ Summary: DB classes for the lhcbdiracx diracx extension
5
+ License: GPL-3.0-only
6
+ Classifier: Intended Audience :: Science/Research
7
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Topic :: Scientific/Engineering
10
+ Classifier: Topic :: System :: Distributed Computing
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: diracx-db
14
+ Requires-Dist: sqlalchemy[oracle-oracledb]
15
+ Provides-Extra: testing
16
+ Requires-Dist: lhcbdiracx-testing; extra == "testing"
17
+ Requires-Dist: diracx-testing; extra == "testing"
@@ -0,0 +1,56 @@
1
+ [project]
2
+ name = "lhcbdiracx-db"
3
+ description = "DB classes for the lhcbdiracx diracx extension"
4
+ readme = "README.md"
5
+ requires-python = ">=3.11"
6
+ keywords = []
7
+ license = { text = "GPL-3.0-only" }
8
+ classifiers = [
9
+ "Intended Audience :: Science/Research",
10
+ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
11
+ "Programming Language :: Python :: 3",
12
+ "Topic :: Scientific/Engineering",
13
+ "Topic :: System :: Distributed Computing",
14
+ ]
15
+ dependencies = [
16
+ # This is obvious
17
+ "diracx-db",
18
+ "sqlalchemy[oracle-oracledb]",
19
+ ]
20
+ dynamic = ["version"]
21
+
22
+ [project.optional-dependencies]
23
+ testing = ["lhcbdiracx-testing", "diracx-testing"]
24
+
25
+ [project.entry-points."diracx.dbs.sql"]
26
+ BookkeepingDB = "lhcbdiracx.db.sql:BookkeepingDB"
27
+
28
+ [tool.setuptools.packages.find]
29
+ where = ["src"]
30
+
31
+ [build-system]
32
+ requires = ["setuptools>=61", "wheel", "setuptools_scm>=8"]
33
+ build-backend = "setuptools.build_meta"
34
+
35
+ # This should not be in your extension !
36
+ # It is just because we have this demo extension
37
+ # in a subfolder of our git repo
38
+ [tool.setuptools_scm]
39
+ root = ".."
40
+
41
+ [tool.pytest.ini_options]
42
+ testpaths = ["tests"]
43
+ addopts = [
44
+ "-v",
45
+ "--cov=lhcbdiracx.db",
46
+ "--cov-report=term-missing",
47
+ # Both lhcbdiracx and diracx are needed here
48
+ "-plhcbdiracx.testing",
49
+ "-pdiracx.testing",
50
+ "-pdiracx.testing.osdb",
51
+ "--import-mode=importlib",
52
+ ]
53
+ asyncio_mode = "auto"
54
+ markers = [
55
+ "enabled_dependencies: List of dependencies which should be available to the FastAPI test client",
56
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ from __future__ import annotations
2
+
3
+ # Do not forget that, as otherwise diracx won't find your DBs
4
+ __all__ = ("sql",)
5
+
6
+ from . import sql
File without changes
@@ -0,0 +1,6 @@
1
+ from __future__ import annotations
2
+
3
+ __all__ = ("BookkeepingDB",)
4
+
5
+
6
+ from .bookkeeping.db import BookkeepingDB
@@ -0,0 +1,20 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import cast
4
+
5
+ from diracx.db.sql.utils import BaseSQLDB
6
+ from sqlalchemy import func, select
7
+
8
+ from .schema import Base as BookkeepingDBBase
9
+ from .schema import Configuration
10
+
11
+
12
+ class BookkeepingDB(BaseSQLDB):
13
+ # This needs to be here for the BaseSQLDB to create the engine
14
+ metadata = BookkeepingDBBase.metadata
15
+
16
+ async def hello(self) -> int:
17
+
18
+ query = select(func.count()).select_from(Configuration.__table__)
19
+ result = await self.conn.execute(query)
20
+ return cast(int, result.scalar())
@@ -0,0 +1,17 @@
1
+ from diracx.db.sql.utils import Column
2
+ from sqlalchemy import Integer, String, UniqueConstraint
3
+ from sqlalchemy.orm import declarative_base
4
+
5
+ Base = declarative_base()
6
+
7
+
8
+ class Configuration(Base):
9
+ __tablename__ = "configurations"
10
+
11
+ configurationid = Column(Integer, primary_key=True)
12
+ configname = Column(String(128), nullable=False)
13
+ configversion = Column(String(128), nullable=False)
14
+
15
+ __table_args__ = (
16
+ UniqueConstraint("configname", "configversion", name="configuration_uk"),
17
+ )
@@ -0,0 +1,17 @@
1
+ Metadata-Version: 2.4
2
+ Name: lhcbdiracx-db
3
+ Version: 0.0.1a3
4
+ Summary: DB classes for the lhcbdiracx diracx extension
5
+ License: GPL-3.0-only
6
+ Classifier: Intended Audience :: Science/Research
7
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Topic :: Scientific/Engineering
10
+ Classifier: Topic :: System :: Distributed Computing
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+ Requires-Dist: diracx-db
14
+ Requires-Dist: sqlalchemy[oracle-oracledb]
15
+ Provides-Extra: testing
16
+ Requires-Dist: lhcbdiracx-testing; extra == "testing"
17
+ Requires-Dist: diracx-testing; extra == "testing"
@@ -0,0 +1,14 @@
1
+ pyproject.toml
2
+ src/lhcbdiracx/db/__init__.py
3
+ src/lhcbdiracx/db/py.typed
4
+ src/lhcbdiracx/db/sql/__init__.py
5
+ src/lhcbdiracx/db/sql/bookkeeping/__init__.py
6
+ src/lhcbdiracx/db/sql/bookkeeping/db.py
7
+ src/lhcbdiracx/db/sql/bookkeeping/schema.py
8
+ src/lhcbdiracx_db.egg-info/PKG-INFO
9
+ src/lhcbdiracx_db.egg-info/SOURCES.txt
10
+ src/lhcbdiracx_db.egg-info/dependency_links.txt
11
+ src/lhcbdiracx_db.egg-info/entry_points.txt
12
+ src/lhcbdiracx_db.egg-info/requires.txt
13
+ src/lhcbdiracx_db.egg-info/top_level.txt
14
+ tests/test_bookkeepingdb.py
@@ -0,0 +1,2 @@
1
+ [diracx.dbs.sql]
2
+ BookkeepingDB = lhcbdiracx.db.sql:BookkeepingDB
@@ -0,0 +1,6 @@
1
+ diracx-db
2
+ sqlalchemy[oracle-oracledb]
3
+
4
+ [testing]
5
+ lhcbdiracx-testing
6
+ diracx-testing
@@ -0,0 +1,29 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING
4
+
5
+ import pytest
6
+
7
+ from lhcbdiracx.db.sql.bookkeeping.db import BookkeepingDB
8
+
9
+ if TYPE_CHECKING:
10
+ from typing import AsyncGenerator
11
+
12
+ # Each DB test class must defined a fixture looking like this one
13
+ # It allows to get an instance of an in memory DB,
14
+
15
+
16
+ @pytest.fixture
17
+ async def bookkeeping_db(tmp_path) -> AsyncGenerator[BookkeepingDB, None]:
18
+ bookkeeping_db = BookkeepingDB("sqlite+aiosqlite:///:memory:")
19
+ async with bookkeeping_db.engine_context():
20
+ async with bookkeeping_db.engine.begin() as conn:
21
+ await conn.run_sync(bookkeeping_db.metadata.create_all)
22
+ yield bookkeeping_db
23
+
24
+
25
+ async def test_insert_and_summary(bookkeeping_db: BookkeepingDB):
26
+ async with bookkeeping_db as bookkeeping_db:
27
+ # First we check that the DB is empty
28
+ result = await bookkeeping_db.hello()
29
+ assert result == 0, result