thds.core 1.33.20250401153221__py3-none-any.whl → 1.33.20250407135817__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 thds.core might be problematic. Click here for more details.

thds/core/calgitver.py CHANGED
@@ -13,13 +13,14 @@
13
13
 
14
14
  import os
15
15
  import re
16
+ from functools import lru_cache
16
17
 
17
18
  from . import git
18
19
 
19
20
  SHORT_HASH = 7
20
21
 
21
22
 
22
- def calgitver() -> str:
23
+ def uncached() -> str:
23
24
  """This is the 'proper', deterministic CalGitVer - unlike the nondeterministic
24
25
  meta.make_calgitver when the repo is dirty. It does allow for the possibility of
25
26
  override via environment variable, which is intended to support nonlocal runtime
@@ -51,13 +52,21 @@ def calgitver() -> str:
51
52
  )
52
53
 
53
54
 
55
+ cached = lru_cache(maxsize=1)(uncached)
56
+ calgitver = cached
57
+
58
+
59
+ def is_clean(cgv: str) -> bool:
60
+ return bool(cgv and not cgv.endswith("-dirty"))
61
+
62
+
54
63
  def clean_calgitver() -> str:
55
64
  """Only allow CalGitVer computed from a clean repository.
56
65
 
57
66
  Particularly useful for strict production environments.
58
67
  """
59
68
  cgv = calgitver()
60
- if cgv.endswith("-dirty"):
69
+ if not is_clean(cgv):
61
70
  raise ValueError(f"CalGitVer {cgv} was computed from a dirty repository!")
62
71
  return cgv
63
72
 
@@ -9,7 +9,7 @@ from thds.core.log import getLogger
9
9
  from thds.core.types import StrOrPath
10
10
 
11
11
  from .connect import row_connect
12
- from .meta import column_names, primary_key_cols
12
+ from .meta import column_names, get_tables, primary_key_cols
13
13
  from .read import matching
14
14
  from .types import T, TableSource
15
15
 
@@ -109,6 +109,10 @@ def autometa_factory(
109
109
  def _get_table_meta():
110
110
  db_path, table_name = src()
111
111
  conn = row_connect(db_path)
112
+ # test if table even exists:
113
+ if table_name not in get_tables(conn):
114
+ raise ValueError(f"Table {table_name} not found in {db_path}")
115
+
112
116
  pk_cols = set(primary_key_cols(table_name, conn))
113
117
  if not pk_cols:
114
118
  raise BadPrimaryKey(f"Found no primary key cols for table {table_name}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: thds.core
3
- Version: 1.33.20250401153221
3
+ Version: 1.33.20250407135817
4
4
  Summary: Core utilities.
5
5
  Author-email: Trilliant Health <info@trillianthealth.com>
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
1
  thds/core/__init__.py,sha256=Z-gAb4uuzXoFANJhJLaSZdfLuHaAGOcrf_6qwcue9Qo,938
2
2
  thds/core/ansi_esc.py,sha256=QZ3CptZbX4N_hyP2IgqfTbNt9tBPaqy7ReTMQIzGbrc,870
3
3
  thds/core/cache.py,sha256=nL0oAyZrhPqyBBLevnOWSWVoEBrftaG3aE6Qq6tvmAA,7153
4
- thds/core/calgitver.py,sha256=HklIz-SczK92Vm2rXtTSDiVxAcxUW_GPVCRRGt4BmBA,2324
4
+ thds/core/calgitver.py,sha256=6ioH5MGE65l_Dp924oD5CWrLyxKgmhtn46YwGxFpHfM,2497
5
5
  thds/core/cm.py,sha256=WZB8eQU0DaBYj9s97nc3PuCtai9guovfyiQH68zhLzY,1086
6
6
  thds/core/concurrency.py,sha256=NQunF_tJ_z8cfVyhzkTPlb-nZrgu-vIk9_3XffgscKQ,3520
7
7
  thds/core/config.py,sha256=VWymw6pqPRvX7wwsJ0Y-D2gLoCclAHhARmTnuUw7kb0,10014
@@ -63,12 +63,12 @@ thds/core/sqlite/merge.py,sha256=NxettDMJ_mcrWfteQn_ERY7MUB5ETR-yJLKg7uvF6zA,377
63
63
  thds/core/sqlite/meta.py,sha256=4P65PAmCjagHYO1Z6nWM-wkjEWv3hxw5qVa4cIpcH_8,5859
64
64
  thds/core/sqlite/read.py,sha256=5pWvrbed3XNWgSy-79-8ONWkkt4jWbTzFNW6SnOrdYQ,2576
65
65
  thds/core/sqlite/sqlmap.py,sha256=YzLsTXwvEWcPI_KmFjA4tKfPoSP3gpHThyIthmPVyK0,6778
66
- thds/core/sqlite/structured.py,sha256=swCbDoyVT6cE7Kl79Wh_rg5Z1-yrUDJbiVJF4bjsetU,4641
66
+ thds/core/sqlite/structured.py,sha256=SvZ67KcVcVdmpR52JSd52vMTW2ALUXmlHEeD-VrzWVs,4825
67
67
  thds/core/sqlite/types.py,sha256=oUkfoKRYNGDPZRk29s09rc9ha3SCk2SKr_K6WKebBFs,1308
68
68
  thds/core/sqlite/upsert.py,sha256=BmKK6fsGVedt43iY-Lp7dnAu8aJ1e9CYlPVEQR2pMj4,5827
69
69
  thds/core/sqlite/write.py,sha256=z0219vDkQDCnsV0WLvsj94keItr7H4j7Y_evbcoBrWU,3458
70
- thds_core-1.33.20250401153221.dist-info/METADATA,sha256=TLIJmjDKE3DVcwLq7neu1mTLBm5kbiijFoJgKbXVrMs,2277
71
- thds_core-1.33.20250401153221.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
72
- thds_core-1.33.20250401153221.dist-info/entry_points.txt,sha256=bOCOVhKZv7azF3FvaWX6uxE6yrjK6FcjqhtxXvLiFY8,161
73
- thds_core-1.33.20250401153221.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
74
- thds_core-1.33.20250401153221.dist-info/RECORD,,
70
+ thds_core-1.33.20250407135817.dist-info/METADATA,sha256=AtcZ3ExrHnPxQLisIbBRNx5ymVWm989culGlInD0e4I,2277
71
+ thds_core-1.33.20250407135817.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
72
+ thds_core-1.33.20250407135817.dist-info/entry_points.txt,sha256=bOCOVhKZv7azF3FvaWX6uxE6yrjK6FcjqhtxXvLiFY8,161
73
+ thds_core-1.33.20250407135817.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
74
+ thds_core-1.33.20250407135817.dist-info/RECORD,,