lsst-felis 27.2024.2700__py3-none-any.whl → 27.2024.2900__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.
Potentially problematic release.
This version of lsst-felis might be problematic. Click here for more details.
- felis/datamodel.py +20 -0
- felis/db/dialects.py +2 -2
- felis/db/sqltypes.py +8 -15
- felis/db/utils.py +1 -1
- felis/metadata.py +34 -6
- felis/version.py +1 -1
- {lsst_felis-27.2024.2700.dist-info → lsst_felis-27.2024.2900.dist-info}/METADATA +1 -1
- lsst_felis-27.2024.2900.dist-info/RECORD +21 -0
- {lsst_felis-27.2024.2700.dist-info → lsst_felis-27.2024.2900.dist-info}/WHEEL +1 -1
- lsst_felis-27.2024.2700.dist-info/RECORD +0 -21
- {lsst_felis-27.2024.2700.dist-info → lsst_felis-27.2024.2900.dist-info}/COPYRIGHT +0 -0
- {lsst_felis-27.2024.2700.dist-info → lsst_felis-27.2024.2900.dist-info}/LICENSE +0 -0
- {lsst_felis-27.2024.2700.dist-info → lsst_felis-27.2024.2900.dist-info}/entry_points.txt +0 -0
- {lsst_felis-27.2024.2700.dist-info → lsst_felis-27.2024.2900.dist-info}/top_level.txt +0 -0
- {lsst_felis-27.2024.2700.dist-info → lsst_felis-27.2024.2900.dist-info}/zip-safe +0 -0
felis/datamodel.py
CHANGED
|
@@ -141,6 +141,13 @@ class Column(BaseObject):
|
|
|
141
141
|
length: int | None = Field(None, gt=0)
|
|
142
142
|
"""Length of the column."""
|
|
143
143
|
|
|
144
|
+
precision: int | None = Field(None, ge=0)
|
|
145
|
+
"""The numerical precision of the column.
|
|
146
|
+
|
|
147
|
+
For timestamps, this is the number of fractional digits retained in the
|
|
148
|
+
seconds field.
|
|
149
|
+
"""
|
|
150
|
+
|
|
144
151
|
nullable: bool = True
|
|
145
152
|
"""Whether the column can be ``NULL``."""
|
|
146
153
|
|
|
@@ -363,6 +370,19 @@ class Column(BaseObject):
|
|
|
363
370
|
)
|
|
364
371
|
return self
|
|
365
372
|
|
|
373
|
+
@model_validator(mode="after")
|
|
374
|
+
def check_precision(self) -> Column:
|
|
375
|
+
"""Check that precision is only valid for timestamp columns.
|
|
376
|
+
|
|
377
|
+
Returns
|
|
378
|
+
-------
|
|
379
|
+
`Column`
|
|
380
|
+
The column being validated.
|
|
381
|
+
"""
|
|
382
|
+
if self.precision is not None and self.datatype != "timestamp":
|
|
383
|
+
raise ValueError("Precision is only valid for timestamp columns")
|
|
384
|
+
return self
|
|
385
|
+
|
|
366
386
|
|
|
367
387
|
class Constraint(BaseObject):
|
|
368
388
|
"""Table constraint model."""
|
felis/db/dialects.py
CHANGED
|
@@ -30,11 +30,11 @@ from sqlalchemy import dialects
|
|
|
30
30
|
from sqlalchemy.engine import Dialect
|
|
31
31
|
from sqlalchemy.engine.mock import create_mock_engine
|
|
32
32
|
|
|
33
|
-
from .sqltypes import MYSQL,
|
|
33
|
+
from .sqltypes import MYSQL, POSTGRES, SQLITE
|
|
34
34
|
|
|
35
35
|
__all__ = ["get_supported_dialects", "get_dialect_module"]
|
|
36
36
|
|
|
37
|
-
_DIALECT_NAMES = (MYSQL, POSTGRES, SQLITE
|
|
37
|
+
_DIALECT_NAMES = (MYSQL, POSTGRES, SQLITE)
|
|
38
38
|
"""List of supported dialect names.
|
|
39
39
|
|
|
40
40
|
This list is used to create the dialect and module dictionaries.
|
felis/db/sqltypes.py
CHANGED
|
@@ -28,7 +28,7 @@ from collections.abc import Callable, Mapping
|
|
|
28
28
|
from typing import Any
|
|
29
29
|
|
|
30
30
|
from sqlalchemy import SmallInteger, types
|
|
31
|
-
from sqlalchemy.dialects import mysql,
|
|
31
|
+
from sqlalchemy.dialects import mysql, postgresql
|
|
32
32
|
from sqlalchemy.ext.compiler import compiles
|
|
33
33
|
|
|
34
34
|
__all__ = [
|
|
@@ -49,7 +49,6 @@ __all__ = [
|
|
|
49
49
|
]
|
|
50
50
|
|
|
51
51
|
MYSQL = "mysql"
|
|
52
|
-
ORACLE = "oracle"
|
|
53
52
|
POSTGRES = "postgresql"
|
|
54
53
|
SQLITE = "sqlite"
|
|
55
54
|
|
|
@@ -88,21 +87,18 @@ def compile_tinyint(type_: Any, compiler: Any, **kwargs: Any) -> str:
|
|
|
88
87
|
|
|
89
88
|
_TypeMap = Mapping[str, types.TypeEngine | type[types.TypeEngine]]
|
|
90
89
|
|
|
91
|
-
boolean_map: _TypeMap = {MYSQL: mysql.BOOLEAN,
|
|
90
|
+
boolean_map: _TypeMap = {MYSQL: mysql.BOOLEAN, POSTGRES: postgresql.BOOLEAN()}
|
|
92
91
|
|
|
93
92
|
byte_map: _TypeMap = {
|
|
94
93
|
MYSQL: mysql.TINYINT(),
|
|
95
|
-
ORACLE: oracle.NUMBER(3),
|
|
96
94
|
POSTGRES: postgresql.SMALLINT(),
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
short_map: _TypeMap = {
|
|
100
98
|
MYSQL: mysql.SMALLINT(),
|
|
101
|
-
ORACLE: oracle.NUMBER(5),
|
|
102
99
|
POSTGRES: postgresql.SMALLINT(),
|
|
103
100
|
}
|
|
104
101
|
|
|
105
|
-
# Skip Oracle
|
|
106
102
|
int_map: _TypeMap = {
|
|
107
103
|
MYSQL: mysql.INTEGER(),
|
|
108
104
|
POSTGRES: postgresql.INTEGER(),
|
|
@@ -110,52 +106,49 @@ int_map: _TypeMap = {
|
|
|
110
106
|
|
|
111
107
|
long_map: _TypeMap = {
|
|
112
108
|
MYSQL: mysql.BIGINT(),
|
|
113
|
-
ORACLE: oracle.NUMBER(38, 0),
|
|
114
109
|
POSTGRES: postgresql.BIGINT(),
|
|
115
110
|
}
|
|
116
111
|
|
|
117
112
|
float_map: _TypeMap = {
|
|
118
113
|
MYSQL: mysql.FLOAT(),
|
|
119
|
-
ORACLE: oracle.BINARY_FLOAT(),
|
|
120
114
|
POSTGRES: postgresql.FLOAT(),
|
|
121
115
|
}
|
|
122
116
|
|
|
123
117
|
double_map: _TypeMap = {
|
|
124
118
|
MYSQL: mysql.DOUBLE(),
|
|
125
|
-
ORACLE: oracle.BINARY_DOUBLE(),
|
|
126
119
|
POSTGRES: postgresql.DOUBLE_PRECISION(),
|
|
127
120
|
}
|
|
128
121
|
|
|
129
122
|
char_map: _TypeMap = {
|
|
130
123
|
MYSQL: mysql.CHAR,
|
|
131
|
-
ORACLE: oracle.CHAR,
|
|
132
124
|
POSTGRES: postgresql.CHAR,
|
|
133
125
|
}
|
|
134
126
|
|
|
135
127
|
string_map: _TypeMap = {
|
|
136
128
|
MYSQL: mysql.VARCHAR,
|
|
137
|
-
ORACLE: oracle.VARCHAR2,
|
|
138
129
|
POSTGRES: postgresql.VARCHAR,
|
|
139
130
|
}
|
|
140
131
|
|
|
141
132
|
unicode_map: _TypeMap = {
|
|
142
133
|
MYSQL: mysql.NVARCHAR,
|
|
143
|
-
ORACLE: oracle.NVARCHAR2,
|
|
144
134
|
POSTGRES: postgresql.VARCHAR,
|
|
145
135
|
}
|
|
146
136
|
|
|
147
137
|
text_map: _TypeMap = {
|
|
148
138
|
MYSQL: mysql.LONGTEXT,
|
|
149
|
-
ORACLE: oracle.CLOB,
|
|
150
139
|
POSTGRES: postgresql.TEXT,
|
|
151
140
|
}
|
|
152
141
|
|
|
153
142
|
binary_map: _TypeMap = {
|
|
154
143
|
MYSQL: mysql.LONGBLOB,
|
|
155
|
-
ORACLE: oracle.BLOB,
|
|
156
144
|
POSTGRES: postgresql.BYTEA,
|
|
157
145
|
}
|
|
158
146
|
|
|
147
|
+
timestamp_map: _TypeMap = {
|
|
148
|
+
MYSQL: mysql.DATETIME(timezone=False),
|
|
149
|
+
POSTGRES: postgresql.TIMESTAMP(timezone=False),
|
|
150
|
+
}
|
|
151
|
+
|
|
159
152
|
|
|
160
153
|
def boolean(**kwargs: Any) -> types.TypeEngine:
|
|
161
154
|
"""Get the SQL type for Felis `~felis.types.Boolean` with variants.
|
|
@@ -370,7 +363,7 @@ def timestamp(**kwargs: Any) -> types.TypeEngine:
|
|
|
370
363
|
`~sqlalchemy.types.TypeEngine`
|
|
371
364
|
The SQL type for a Felis timestamp.
|
|
372
365
|
"""
|
|
373
|
-
return types.TIMESTAMP()
|
|
366
|
+
return _vary(types.TIMESTAMP(timezone=False), timestamp_map, kwargs)
|
|
374
367
|
|
|
375
368
|
|
|
376
369
|
def get_type_func(type_name: str) -> Callable:
|
felis/db/utils.py
CHANGED
|
@@ -299,6 +299,6 @@ class DatabaseContext:
|
|
|
299
299
|
The mock connection object.
|
|
300
300
|
"""
|
|
301
301
|
writer = SQLWriter(output_file)
|
|
302
|
-
engine = create_mock_engine(engine_url, executor=writer.write)
|
|
302
|
+
engine = create_mock_engine(engine_url, executor=writer.write, paramstyle="pyformat")
|
|
303
303
|
writer.dialect = engine.dialect
|
|
304
304
|
return engine
|
felis/metadata.py
CHANGED
|
@@ -40,6 +40,7 @@ from sqlalchemy import (
|
|
|
40
40
|
UniqueConstraint,
|
|
41
41
|
text,
|
|
42
42
|
)
|
|
43
|
+
from sqlalchemy.dialects import mysql, postgresql
|
|
43
44
|
from sqlalchemy.types import TypeEngine
|
|
44
45
|
|
|
45
46
|
from felis.datamodel import Schema
|
|
@@ -54,6 +55,28 @@ __all__ = ("MetaDataBuilder", "get_datatype_with_variants")
|
|
|
54
55
|
logger = logging.getLogger(__name__)
|
|
55
56
|
|
|
56
57
|
|
|
58
|
+
def _handle_timestamp_column(column_obj: datamodel.Column, variant_dict: dict[str, TypeEngine[Any]]) -> None:
|
|
59
|
+
"""Handle columns with the timestamp datatype.
|
|
60
|
+
|
|
61
|
+
Parameters
|
|
62
|
+
----------
|
|
63
|
+
column_obj
|
|
64
|
+
The column object representing the timestamp.
|
|
65
|
+
variant_dict
|
|
66
|
+
The dictionary of variant overrides for the datatype.
|
|
67
|
+
|
|
68
|
+
Notes
|
|
69
|
+
-----
|
|
70
|
+
This function updates the variant dictionary with the appropriate
|
|
71
|
+
timestamp type for the column object but only if the precision is set.
|
|
72
|
+
Otherwise, the default timestamp objects defined in the Felis type system
|
|
73
|
+
will be used instead.
|
|
74
|
+
"""
|
|
75
|
+
if column_obj.precision is not None:
|
|
76
|
+
args: Any = [False, column_obj.precision] # Turn off timezone.
|
|
77
|
+
variant_dict.update({"postgresql": postgresql.TIMESTAMP(*args), "mysql": mysql.DATETIME(*args)})
|
|
78
|
+
|
|
79
|
+
|
|
57
80
|
def get_datatype_with_variants(column_obj: datamodel.Column) -> TypeEngine:
|
|
58
81
|
"""Use the Felis type system to get a SQLAlchemy datatype with variant
|
|
59
82
|
overrides from the information in a Felis column object.
|
|
@@ -71,18 +94,23 @@ def get_datatype_with_variants(column_obj: datamodel.Column) -> TypeEngine:
|
|
|
71
94
|
Raises
|
|
72
95
|
------
|
|
73
96
|
ValueError
|
|
74
|
-
If the column has a sized type but no length
|
|
97
|
+
If the column has a sized type but no length or if the datatype is
|
|
98
|
+
invalid.
|
|
75
99
|
"""
|
|
76
100
|
variant_dict = make_variant_dict(column_obj)
|
|
77
101
|
felis_type = FelisType.felis_type(column_obj.datatype.value)
|
|
78
|
-
datatype_fun = getattr(sqltypes, column_obj.datatype.value)
|
|
102
|
+
datatype_fun = getattr(sqltypes, column_obj.datatype.value, None)
|
|
103
|
+
if datatype_fun is None:
|
|
104
|
+
raise ValueError(f"Unknown datatype: {column_obj.datatype.value}")
|
|
105
|
+
args = []
|
|
79
106
|
if felis_type.is_sized:
|
|
107
|
+
# Add length argument for size types.
|
|
80
108
|
if not column_obj.length:
|
|
81
109
|
raise ValueError(f"Column {column_obj.name} has sized type '{column_obj.datatype}' but no length")
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return
|
|
110
|
+
args = [column_obj.length]
|
|
111
|
+
if felis_type.is_timestamp:
|
|
112
|
+
_handle_timestamp_column(column_obj, variant_dict)
|
|
113
|
+
return datatype_fun(*args, **variant_dict)
|
|
86
114
|
|
|
87
115
|
|
|
88
116
|
_VALID_SERVER_DEFAULTS = ("CURRENT_TIMESTAMP", "NOW()", "LOCALTIMESTAMP", "NULL")
|
felis/version.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
__all__ = ["__version__"]
|
|
2
|
-
__version__ = "27.2024.
|
|
2
|
+
__version__ = "27.2024.2900"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lsst-felis
|
|
3
|
-
Version: 27.2024.
|
|
3
|
+
Version: 27.2024.2900
|
|
4
4
|
Summary: A vocabulary for describing catalogs and acting on those descriptions
|
|
5
5
|
Author-email: Rubin Observatory Data Management <dm-admin@lists.lsst.org>
|
|
6
6
|
License: GNU General Public License v3 or later (GPLv3+)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
felis/__init__.py,sha256=THmRg3ylB4E73XhFjJX7YlnV_CM3lr_gZO_HqQFzIQ4,937
|
|
2
|
+
felis/cli.py,sha256=i5FlA9OBecqHP4SISngaveQ7YbWH8pxRGHeOzMOOMyg,14086
|
|
3
|
+
felis/datamodel.py,sha256=BajYwp2rk0j3P4KSc2T9Acnk9p9pjzXiKgZG2c_OuZI,26517
|
|
4
|
+
felis/metadata.py,sha256=8r2LM86kdJLSuI0_t--oE3OtRPf-s5aH3FeIDDDAPZ8,13414
|
|
5
|
+
felis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
felis/tap.py,sha256=YBWl1CicdN4jW_KhPJQ7-TuhOfFFTIYIH4tTJ8P_o1c,21035
|
|
7
|
+
felis/types.py,sha256=m80GSGfNHQ3-NzRuTzKOyRXLJboPxdk9kzpp1SO8XdY,5510
|
|
8
|
+
felis/version.py,sha256=IrpaDaI-IyY9Sbo84xgm9VHx9dydDb3gMPiEsDfHl6s,55
|
|
9
|
+
felis/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
felis/db/dialects.py,sha256=x9ehMbW6OW-v18lwf3v614zdykhTZv0I1a0_gI_ojB0,3510
|
|
11
|
+
felis/db/sqltypes.py,sha256=UNxKCRQU-pAIIGbrXcKUkx6-JwPGqxeqd_fLyN9Oyog,11053
|
|
12
|
+
felis/db/utils.py,sha256=_vWVsPsq_kVl-WQuDeoLY3ZxElGCCEzPp3tfBTENGB8,10200
|
|
13
|
+
felis/db/variants.py,sha256=o5m101upQQbWZD_l8qlB8gt-ZQ9-VqsWZrmxQO1eEQA,5246
|
|
14
|
+
lsst_felis-27.2024.2900.dist-info/COPYRIGHT,sha256=vJAFLFTSF1mhy9eIuA3P6R-3yxTWKQgpig88P-1IzRw,129
|
|
15
|
+
lsst_felis-27.2024.2900.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
|
16
|
+
lsst_felis-27.2024.2900.dist-info/METADATA,sha256=1IpNFJvTYCTbm2qIYrb098nVe4RVW2VkBiATRjDw6vg,1288
|
|
17
|
+
lsst_felis-27.2024.2900.dist-info/WHEEL,sha256=FZ75kcLy9M91ncbIgG8dnpCncbiKXSRGJ_PFILs6SFg,91
|
|
18
|
+
lsst_felis-27.2024.2900.dist-info/entry_points.txt,sha256=Gk2XFujA_Gp52VBk45g5kim8TDoMDJFPctsMqiq72EM,40
|
|
19
|
+
lsst_felis-27.2024.2900.dist-info/top_level.txt,sha256=F4SvPip3iZRVyISi50CHhwTIAokAhSxjWiVcn4IVWRI,6
|
|
20
|
+
lsst_felis-27.2024.2900.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
21
|
+
lsst_felis-27.2024.2900.dist-info/RECORD,,
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
felis/__init__.py,sha256=THmRg3ylB4E73XhFjJX7YlnV_CM3lr_gZO_HqQFzIQ4,937
|
|
2
|
-
felis/cli.py,sha256=i5FlA9OBecqHP4SISngaveQ7YbWH8pxRGHeOzMOOMyg,14086
|
|
3
|
-
felis/datamodel.py,sha256=k0wAZpIhwOWVvAlHLLpzCOYYxY5iD8jpjlOu_lpzv-4,25902
|
|
4
|
-
felis/metadata.py,sha256=W1Y4s7izAEiH3MLJkKQpvxHsGE5Dbu4lhhNCzWlfl0o,12290
|
|
5
|
-
felis/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
felis/tap.py,sha256=YBWl1CicdN4jW_KhPJQ7-TuhOfFFTIYIH4tTJ8P_o1c,21035
|
|
7
|
-
felis/types.py,sha256=m80GSGfNHQ3-NzRuTzKOyRXLJboPxdk9kzpp1SO8XdY,5510
|
|
8
|
-
felis/version.py,sha256=Py-EC2UdOs7tbGMklTl45bEVHW1tbRLsn35DytqzMs0,55
|
|
9
|
-
felis/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
felis/db/dialects.py,sha256=IsjdD_2n7tucUdR7TMyRd2gWtnD-2kXPAJUUQdbUe_Q,3526
|
|
11
|
-
felis/db/sqltypes.py,sha256=sDzkqemYwILp8hk0yfg3H0ZK7bGnIJR9x6ntd2coASc,11248
|
|
12
|
-
felis/db/utils.py,sha256=TgNJTBv2Jt4Qq_RtOO_jWj_02tb-fEA2QeOOHYS1GyU,10177
|
|
13
|
-
felis/db/variants.py,sha256=o5m101upQQbWZD_l8qlB8gt-ZQ9-VqsWZrmxQO1eEQA,5246
|
|
14
|
-
lsst_felis-27.2024.2700.dist-info/COPYRIGHT,sha256=vJAFLFTSF1mhy9eIuA3P6R-3yxTWKQgpig88P-1IzRw,129
|
|
15
|
-
lsst_felis-27.2024.2700.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
|
16
|
-
lsst_felis-27.2024.2700.dist-info/METADATA,sha256=A5aJVx9iUOUBeR4Lxwqzpct3I1A3krP13BWPc3zMbpE,1288
|
|
17
|
-
lsst_felis-27.2024.2700.dist-info/WHEEL,sha256=y4mX-SOX4fYIkonsAGA5N0Oy-8_gI4FXw5HNI1xqvWg,91
|
|
18
|
-
lsst_felis-27.2024.2700.dist-info/entry_points.txt,sha256=Gk2XFujA_Gp52VBk45g5kim8TDoMDJFPctsMqiq72EM,40
|
|
19
|
-
lsst_felis-27.2024.2700.dist-info/top_level.txt,sha256=F4SvPip3iZRVyISi50CHhwTIAokAhSxjWiVcn4IVWRI,6
|
|
20
|
-
lsst_felis-27.2024.2700.dist-info/zip-safe,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
21
|
-
lsst_felis-27.2024.2700.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|