lsst-felis 27.2024.1800__tar.gz → 27.2024.2000__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 (32) hide show
  1. {lsst_felis-27.2024.1800/python/lsst_felis.egg-info → lsst_felis-27.2024.2000}/PKG-INFO +1 -1
  2. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/felis/datamodel.py +24 -5
  3. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/felis/metadata.py +1 -1
  4. lsst_felis-27.2024.2000/python/felis/version.py +2 -0
  5. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000/python/lsst_felis.egg-info}/PKG-INFO +1 -1
  6. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/tests/test_datamodel.py +5 -5
  7. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/tests/test_validation.py +3 -0
  8. lsst_felis-27.2024.1800/python/felis/version.py +0 -2
  9. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/COPYRIGHT +0 -0
  10. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/LICENSE +0 -0
  11. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/README.rst +0 -0
  12. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/pyproject.toml +0 -0
  13. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/felis/__init__.py +0 -0
  14. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/felis/cli.py +0 -0
  15. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/felis/db/__init__.py +0 -0
  16. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/felis/db/_variants.py +0 -0
  17. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/felis/db/sqltypes.py +0 -0
  18. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/felis/py.typed +0 -0
  19. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/felis/tap.py +0 -0
  20. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/felis/types.py +0 -0
  21. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/felis/validation.py +0 -0
  22. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/lsst_felis.egg-info/SOURCES.txt +0 -0
  23. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/lsst_felis.egg-info/dependency_links.txt +0 -0
  24. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/lsst_felis.egg-info/entry_points.txt +0 -0
  25. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/lsst_felis.egg-info/requires.txt +0 -0
  26. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/lsst_felis.egg-info/top_level.txt +0 -0
  27. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/python/lsst_felis.egg-info/zip-safe +0 -0
  28. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/setup.cfg +0 -0
  29. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/tests/test_cli.py +0 -0
  30. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/tests/test_datatypes.py +0 -0
  31. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/tests/test_metadata.py +0 -0
  32. {lsst_felis-27.2024.1800 → lsst_felis-27.2024.2000}/tests/test_tap.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lsst-felis
3
- Version: 27.2024.1800
3
+ Version: 27.2024.2000
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+)
@@ -178,7 +178,7 @@ class Column(BaseObject):
178
178
  datatype: DataType
179
179
  """The datatype of the column."""
180
180
 
181
- length: int | None = None
181
+ length: int | None = Field(None, gt=0)
182
182
  """The length of the column."""
183
183
 
184
184
  nullable: bool = True
@@ -276,6 +276,28 @@ class Column(BaseObject):
276
276
 
277
277
  return values
278
278
 
279
+ @model_validator(mode="before")
280
+ @classmethod
281
+ def check_length(cls, values: dict[str, Any]) -> dict[str, Any]:
282
+ """Check that a valid length is provided for sized types."""
283
+ datatype = values.get("datatype")
284
+ if datatype is None:
285
+ # Skip this validation if datatype is not provided
286
+ return values
287
+ length = values.get("length")
288
+ felis_type = FelisType.felis_type(datatype)
289
+ if felis_type.is_sized and length is None:
290
+ raise ValueError(
291
+ f"Length must be provided for type '{datatype}'"
292
+ + (f" in column '{values['@id']}'" if "@id" in values else "")
293
+ )
294
+ elif not felis_type.is_sized and length is not None:
295
+ logger.warning(
296
+ f"The datatype '{datatype}' does not support a specified length"
297
+ + (f" in column '{values['@id']}'" if "@id" in values else "")
298
+ )
299
+ return values
300
+
279
301
  @model_validator(mode="after")
280
302
  def check_datatypes(self, info: ValidationInfo) -> Column:
281
303
  """Check for redundant datatypes on columns."""
@@ -291,10 +313,7 @@ class Column(BaseObject):
291
313
  datatype_func = get_type_func(datatype)
292
314
  felis_type = FelisType.felis_type(datatype)
293
315
  if felis_type.is_sized:
294
- if length is not None:
295
- datatype_obj = datatype_func(length)
296
- else:
297
- raise ValueError(f"Length must be provided for sized type '{datatype}' in column '{self.id}'")
316
+ datatype_obj = datatype_func(length)
298
317
  else:
299
318
  datatype_obj = datatype_func()
300
319
 
@@ -342,7 +342,7 @@ class MetaDataBuilder:
342
342
  """
343
343
  args: dict[str, Any] = {
344
344
  "name": constraint_obj.name or None,
345
- "info": constraint_obj.description or None,
345
+ "comment": constraint_obj.description or None,
346
346
  "deferrable": constraint_obj.deferrable or None,
347
347
  "initially": constraint_obj.initially or None,
348
348
  }
@@ -0,0 +1,2 @@
1
+ __all__ = ["__version__"]
2
+ __version__ = "27.2024.2000"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lsst-felis
3
- Version: 27.2024.1800
3
+ Version: 27.2024.2000
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+)
@@ -73,13 +73,13 @@ class ColumnTestCase(unittest.TestCase):
73
73
 
74
74
  # Setting name, id, and datatype should not throw an exception and
75
75
  # should load data correctly.
76
- col = Column(name="testColumn", id="#test_id", datatype="string")
76
+ col = Column(name="testColumn", id="#test_id", datatype="string", length=256)
77
77
  self.assertEqual(col.name, "testColumn", "name should be 'testColumn'")
78
78
  self.assertEqual(col.id, "#test_id", "id should be '#test_id'")
79
79
  self.assertEqual(col.datatype, DataType.string, "datatype should be 'DataType.string'")
80
80
 
81
81
  # Creating from data dictionary should work and load data correctly.
82
- data = {"name": "testColumn", "id": "#test_id", "datatype": "string"}
82
+ data = {"name": "testColumn", "id": "#test_id", "datatype": "string", "length": 256}
83
83
  col = Column(**data)
84
84
  self.assertEqual(col.name, "testColumn", "name should be 'testColumn'")
85
85
  self.assertEqual(col.id, "#test_id", "id should be '#test_id'")
@@ -422,7 +422,7 @@ class TableTestCase(unittest.TestCase):
422
422
  with self.assertRaises(ValidationError):
423
423
  Index(name="testTable", id="#test_id")
424
424
 
425
- testCol = Column(name="testColumn", id="#test_id", datatype="string")
425
+ testCol = Column(name="testColumn", id="#test_id", datatype="string", length=256)
426
426
 
427
427
  # Setting name, id, and columns should not throw an exception and
428
428
  # should load data correctly.
@@ -453,7 +453,7 @@ class SchemaTestCase(unittest.TestCase):
453
453
  with self.assertRaises(ValidationError):
454
454
  Schema(name="testSchema", id="#test_id")
455
455
 
456
- test_col = Column(name="testColumn", id="#test_col_id", datatype="string")
456
+ test_col = Column(name="testColumn", id="#test_col_id", datatype="string", length=256)
457
457
  test_tbl = Table(name="testTable", id="#test_tbl_id", columns=[test_col])
458
458
 
459
459
  # Setting name, id, and columns should not throw an exception and
@@ -491,7 +491,7 @@ class SchemaTestCase(unittest.TestCase):
491
491
 
492
492
  def test_schema_object_ids(self) -> None:
493
493
  """Test that the id_map is properly populated."""
494
- test_col = Column(name="testColumn", id="#test_col_id", datatype="string")
494
+ test_col = Column(name="testColumn", id="#test_col_id", datatype="string", length=256)
495
495
  test_tbl = Table(name="testTable", id="#test_table_id", columns=[test_col])
496
496
  sch = Schema(name="testSchema", id="#test_schema_id", tables=[test_tbl])
497
497
 
@@ -58,6 +58,7 @@ class RSPSchemaTestCase(unittest.TestCase):
58
58
  "@id": "#test_col_id",
59
59
  "datatype": "string",
60
60
  "description": "test column",
61
+ "length": 256,
61
62
  "tap:principal": 1,
62
63
  }
63
64
  )
@@ -191,6 +192,7 @@ class RSPSchemaTestCase(unittest.TestCase):
191
192
  "datatype": "string",
192
193
  "description": "test column",
193
194
  "tap:principal": 1,
195
+ "length": 256,
194
196
  }
195
197
  )
196
198
  ],
@@ -210,6 +212,7 @@ class RSPSchemaTestCase(unittest.TestCase):
210
212
  "datatype": "string",
211
213
  "description": "test column",
212
214
  "tap:principal": 1,
215
+ "length": 256,
213
216
  }
214
217
  )
215
218
  ],
@@ -1,2 +0,0 @@
1
- __all__ = ["__version__"]
2
- __version__ = "27.2024.1800"