syncmodels 0.1.343__py2.py3-none-any.whl → 0.1.345__py2.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.
syncmodels/__init__.py CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  __author__ = """Asterio Gonzalez"""
4
4
  __email__ = "asterio.gonzalez@gmail.com"
5
- __version__ = "0.1.343"
5
+ __version__ = "0.1.345"
@@ -35,8 +35,8 @@ class SortKeyFinder:
35
35
  # )
36
36
  DATE_KEYS = [
37
37
  # ".*date", # keys that does not belongs to Pydantic models
38
- # "id",
39
- # "record_id",
38
+ "id",
39
+ "record_id",
40
40
  "time",
41
41
  "year",
42
42
  "ts",
syncmodels/schema.py CHANGED
@@ -7,8 +7,13 @@ def most_common(sample):
7
7
  for value in sample:
8
8
  stats[value] = stats.get(value, 0) + 1
9
9
 
10
- stats = [(v, k) for k, v in stats.items()]
10
+ # types can't compare themselves, so add a trick with str(k)
11
+ stats = [(v, str(k), k) for k, v in stats.items()]
12
+
11
13
  stats.sort(reverse=True)
14
+
15
+ # remove str(k)
16
+ stats = [(a, c) for (a, _, c) in stats]
12
17
  return stats
13
18
 
14
19
 
@@ -57,6 +62,8 @@ class iSchema:
57
62
  d_fields = {}
58
63
  for row in data:
59
64
  for i, value in enumerate(row):
65
+ if value is None:
66
+ continue
60
67
  name = names[i]
61
68
  type_ = value.__class__
62
69
  d_fields.setdefault(name, []).append(type_)
@@ -75,8 +82,11 @@ class iSchema:
75
82
  # direct search has failed
76
83
  # try to guess the column by value class
77
84
  for key, klass in d_fields.items():
78
- if issubclass(klass, (datetime,)):
79
- return key
85
+ try:
86
+ if issubclass(klass, (datetime,)):
87
+ return key
88
+ except Exception as why:
89
+ pass
80
90
 
81
91
  monotonic_since_key = best()
82
92
  return names, types, d_fields, monotonic_since_key
syncmodels/storage.py CHANGED
@@ -1025,20 +1025,24 @@ class WaveStorage(iWaves, iStorage):
1025
1025
 
1026
1026
  # TODO: try to create only a single query
1027
1027
  # TODO: review different structures case
1028
- similar_bp = {
1029
- LIMIT_KEY: kw.get(
1030
- LIMIT_KEY, 25 # TODO: agp: set in definition?
1031
- ), # TODO: this is temporal, ideally None
1032
- # ORDER_KEY: MONOTONIC_KEY,
1033
- # DIRECTION_KEY: DIRECTION_DESC,
1034
- ORG_KEY: uid,
1035
- **data_sort_blueprint, # implies sv = True
1036
- }
1037
- similar = await self.storage.query(
1038
- query,
1039
- **similar_bp,
1040
- **data_sort_bp,
1041
- )
1028
+ if is_sort_key_id(sort_keys):
1029
+ # using record_id style doesn't require search for similars object
1030
+ similar = []
1031
+ else:
1032
+ similar_bp = {
1033
+ LIMIT_KEY: kw.get(
1034
+ LIMIT_KEY, 25 # TODO: agp: set in definition?
1035
+ ), # TODO: this is temporal, ideally None
1036
+ # ORDER_KEY: MONOTONIC_KEY,
1037
+ # DIRECTION_KEY: DIRECTION_DESC,
1038
+ ORG_KEY: uid,
1039
+ **data_sort_blueprint, # implies sv = True
1040
+ }
1041
+ similar = await self.storage.query(
1042
+ query,
1043
+ **similar_bp,
1044
+ **data_sort_bp,
1045
+ )
1042
1046
  t1 = time.time()
1043
1047
  _elapsed = t1 - t0
1044
1048
  existing = identical + similar
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: syncmodels
3
- Version: 0.1.343
3
+ Version: 0.1.345
4
4
  Summary: Synchronizable Models
5
5
  Home-page: https://github.com/asterio.gonzalez/syncmodels
6
6
  Author: Asterio Gonzalez
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.11
18
18
  Requires-Python: >=3.6
19
19
  License-File: LICENSE
20
20
  License-File: AUTHORS.rst
21
- Requires-Dist: agptools>=0.1.343
21
+ Requires-Dist: agptools>=0.1.345
22
22
  Requires-Dist: aiocache
23
23
  Requires-Dist: aiohttp
24
24
  Requires-Dist: Click
@@ -1,4 +1,4 @@
1
- syncmodels/__init__.py,sha256=Mpde6Eca9MTKd_YLLbuJt4XCAjhQkFJWIMHIgyNtej0,142
1
+ syncmodels/__init__.py,sha256=97auPMo5GK08H9FvKR4gS9kncSRmilKyekZWQqVvVzU,142
2
2
  syncmodels/context.py,sha256=k1Gs_ip9BfyRFpyRnzqYvRDKo0sYBqJsh6z9sWln9oE,451
3
3
  syncmodels/crawler.py,sha256=lx0IU586JD0qcdozWiv0y7970CkUEg3SzFB6gOYDS6I,94540
4
4
  syncmodels/crud.py,sha256=oZIcwEKR2i-lesEF_059Y4yThohd9m7gs6R6xYgLH-I,15351
@@ -10,8 +10,8 @@ syncmodels/parallel.py,sha256=Ll8HmyFF9v9fIofqqSgfhyTlklvb77mTtNdG5Y9lqdQ,7145
10
10
  syncmodels/registry.py,sha256=YaQtgbSwa0je1MpCcVHALI3_b85vrddyOlhsnrUcKZs,8224
11
11
  syncmodels/requests.py,sha256=wWoC5hPDm1iBM_zrlyKRauzhXgdKR3pT5RqyC-5UZhQ,538
12
12
  syncmodels/runner.py,sha256=IHDKuQ3yJ1DN9wktMiIrerPepYX61tc3AzbFfuUqEFw,5454
13
- syncmodels/schema.py,sha256=uinUt8Asq_x7xa6MKWVXNyoWO6gKocjGPppjimaXzEU,2492
14
- syncmodels/storage.py,sha256=GLEDryiBkgN9SgtvcqBRxP_22T00gGkIbiZqM6AqKDI,76158
13
+ syncmodels/schema.py,sha256=n5Kkq5bxwzBkLomVtUzq3cwNpVjV0HNLxj-wavlYIbQ,2789
14
+ syncmodels/storage.py,sha256=x01TmpETMrHvQvliL3TXfUp18RKr6Huz6DmrRZWD1DU,76418
15
15
  syncmodels/syncmodels.py,sha256=jcUxVbv1hrx5hI81VCO1onIM6WyORTqJVPwIqlPocOc,10596
16
16
  syncmodels/timequeue.py,sha256=YRd3ULRaIhoszaBsYhfr0epMqAbL6-NwVEtScjUYttM,595
17
17
  syncmodels/wave.py,sha256=Gra22BLiA9z2nF-6diXpjAc4GZv9nebmyvHxdAfXec4,7764
@@ -24,7 +24,7 @@ syncmodels/cli/surreal.py,sha256=eL7pDicLo0_68JhpCZacde6DOVcfHE_UEzczvgDuvAc,106
24
24
  syncmodels/cli/wingdbstub.py,sha256=q4z-RqHN1ttzNtiLYTzqQG2ZYZ6W3NOnEd2E5NGhfao,17165
25
25
  syncmodels/cli/workspace.py,sha256=wajZnxf567nYoQysTEgxrDAp8ZBU8zSuoP4KyZtqvdc,2461
26
26
  syncmodels/helpers/__init__.py,sha256=qZet64gMJNAAqzUdEqCV5WDk5D2Dbw1Kxlt9Jo6x3m4,23
27
- syncmodels/helpers/crawler.py,sha256=ptqj4g96nQfQIvdp18HRDovnWfB0RJXtTBzHQsNPrM8,4844
27
+ syncmodels/helpers/crawler.py,sha256=UNa_Sgmq8M1X3oQlVUalo-2fAePWsLlhJx1BViIO3fo,4840
28
28
  syncmodels/helpers/explorer.py,sha256=-Dol3z1pALCMI9OPSvVbROaTzLjbUpS0suJ82Z6Rmb4,7447
29
29
  syncmodels/helpers/faker.py,sha256=tPtibNh28KoHb9kcwE9WaPdPrSrN6xMbCv5HhNFEVG0,1222
30
30
  syncmodels/helpers/general.py,sha256=UAcSfrvsaT15iJuxsR3WMk51UjpLLGDf14xmpBojndg,6160
@@ -303,10 +303,10 @@ syncmodels/session/postgresql.py,sha256=ZMIu1Rv93pKfvFlovFBmWArzlrT2xaQWNYGZT_LW
303
303
  syncmodels/session/sql.py,sha256=auZ_3RZTSWViED4UrExYaes42Y2bTZKixEsfOpa_zaU,7036
304
304
  syncmodels/session/sqlite.py,sha256=nCDjopLiBpX1F10qkKoARM7JrVdIpJ1WdGOduFVxaiA,2080
305
305
  syncmodels/source/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
306
- syncmodels-0.1.343.dist-info/AUTHORS.rst,sha256=3ZPoqg8Aav8DSYKd0fwcwn4_5HwSiMLart0E5Un00-U,168
307
- syncmodels-0.1.343.dist-info/LICENSE,sha256=uzMOYtIiUsnsD0xHJR7aJWJ4v_bvan0kTnvufy5eNoA,1075
308
- syncmodels-0.1.343.dist-info/METADATA,sha256=sXMUvCabKs5rQ2jAfNc1Vgp6XBoQbcpPCXhRq4rQ9a8,2700
309
- syncmodels-0.1.343.dist-info/WHEEL,sha256=SrDKpSbFN1G94qcmBqS9nyHcDMp9cUS9OC06hC0G3G0,109
310
- syncmodels-0.1.343.dist-info/entry_points.txt,sha256=dMnigjZsHMxTwXiiZyBZdBbMYE0-hY3L5cG15EcDAzw,51
311
- syncmodels-0.1.343.dist-info/top_level.txt,sha256=2DfQ9NuAhKMjY3BvQGVBA7GfqTm7EoHNbaehSUiqiHQ,11
312
- syncmodels-0.1.343.dist-info/RECORD,,
306
+ syncmodels-0.1.345.dist-info/AUTHORS.rst,sha256=3ZPoqg8Aav8DSYKd0fwcwn4_5HwSiMLart0E5Un00-U,168
307
+ syncmodels-0.1.345.dist-info/LICENSE,sha256=uzMOYtIiUsnsD0xHJR7aJWJ4v_bvan0kTnvufy5eNoA,1075
308
+ syncmodels-0.1.345.dist-info/METADATA,sha256=1qq6L-7xrXhXrHll1btsJpYQlyYveDgz564yJvivZlY,2700
309
+ syncmodels-0.1.345.dist-info/WHEEL,sha256=SrDKpSbFN1G94qcmBqS9nyHcDMp9cUS9OC06hC0G3G0,109
310
+ syncmodels-0.1.345.dist-info/entry_points.txt,sha256=dMnigjZsHMxTwXiiZyBZdBbMYE0-hY3L5cG15EcDAzw,51
311
+ syncmodels-0.1.345.dist-info/top_level.txt,sha256=2DfQ9NuAhKMjY3BvQGVBA7GfqTm7EoHNbaehSUiqiHQ,11
312
+ syncmodels-0.1.345.dist-info/RECORD,,