syncmodels 0.1.336__py2.py3-none-any.whl → 0.1.338__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 +1 -1
- syncmodels/session/__init__.py +3 -2
- syncmodels/storage.py +74 -76
- {syncmodels-0.1.336.dist-info → syncmodels-0.1.338.dist-info}/METADATA +2 -2
- {syncmodels-0.1.336.dist-info → syncmodels-0.1.338.dist-info}/RECORD +10 -10
- {syncmodels-0.1.336.dist-info → syncmodels-0.1.338.dist-info}/AUTHORS.rst +0 -0
- {syncmodels-0.1.336.dist-info → syncmodels-0.1.338.dist-info}/LICENSE +0 -0
- {syncmodels-0.1.336.dist-info → syncmodels-0.1.338.dist-info}/WHEEL +0 -0
- {syncmodels-0.1.336.dist-info → syncmodels-0.1.338.dist-info}/entry_points.txt +0 -0
- {syncmodels-0.1.336.dist-info → syncmodels-0.1.338.dist-info}/top_level.txt +0 -0
syncmodels/__init__.py
CHANGED
syncmodels/session/__init__.py
CHANGED
@@ -399,7 +399,7 @@ class iSession(iContext, iSchema, iRegistry): # , iAuthenticator):
|
|
399
399
|
if resuming_info := _wave.get(WAVE_RESUMING_INFO_KEY):
|
400
400
|
assert (
|
401
401
|
len(resuming_info) == 1
|
402
|
-
), "multiples resuming keys are not
|
402
|
+
), "multiples resuming keys are not allowed (review storage.put())"
|
403
403
|
key, value = resuming_info.popitem()
|
404
404
|
params[MONOTONIC_SINCE_KEY] = key
|
405
405
|
params[MONOTONIC_SINCE_VALUE] = value
|
@@ -416,8 +416,9 @@ class iSession(iContext, iSchema, iRegistry): # , iAuthenticator):
|
|
416
416
|
call_kw[self.QUERY_BODY_KEY] = self._prepare_body(body)
|
417
417
|
else:
|
418
418
|
call_kw[self.QUERY_BODY_KEY] = body
|
419
|
-
|
419
|
+
elif self.PARAMS_KEY:
|
420
420
|
call_kw[self.PARAMS_KEY] = params
|
421
|
+
|
421
422
|
return call_kw
|
422
423
|
|
423
424
|
|
syncmodels/storage.py
CHANGED
@@ -1225,86 +1225,84 @@ class WaveStorage(iWaves, iStorage):
|
|
1225
1225
|
res2 = True
|
1226
1226
|
|
1227
1227
|
# save Snapshot of the object
|
1228
|
-
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
data[ORG_KEY] = build_uri(**_uri)
|
1241
|
-
|
1242
|
-
data[ID_KEY] = "{thing}:{id}".format_map(_uri)
|
1243
|
-
query = f"{namespace}://{database}/{TUBE_SNAPSHOT}"
|
1244
|
-
# resuming_info = {k: kw[k] for k in kw.get(REVERSE_SORT_KEY, [])}
|
1245
|
-
# resuming_info = {k: kw[k] for k in kw.get(SORT_KEY) or []}
|
1246
|
-
resuming_info = {
|
1247
|
-
k: kw.get(k, data.get(k)) for k in kw.get(SORT_KEY) or []
|
1248
|
-
}
|
1249
|
-
# force to be json compatible
|
1250
|
-
resuming_info = JSONVerter.to_json(resuming_info)
|
1228
|
+
# long fquid version
|
1229
|
+
# data[ID_KEY] = data[ORG_KEY]
|
1230
|
+
# short version
|
1231
|
+
# data[ID_KEY] = "{thing}:{id}".format_map(_uri)
|
1232
|
+
if _uri["id"] is None:
|
1233
|
+
__id = data.get(ORG_KEY, "")
|
1234
|
+
_id = parse_duri(__id)
|
1235
|
+
if _id["id"] is None:
|
1236
|
+
_uri["id"] = __id
|
1237
|
+
else:
|
1238
|
+
_uri["id"] = _id["id"]
|
1239
|
+
data[ORG_KEY] = build_uri(**_uri)
|
1251
1240
|
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
data.
|
1241
|
+
data[ID_KEY] = "{thing}:{id}".format_map(_uri)
|
1242
|
+
query = f"{namespace}://{database}/{TUBE_SNAPSHOT}"
|
1243
|
+
# resuming_info = {k: kw[k] for k in kw.get(REVERSE_SORT_KEY, [])}
|
1244
|
+
# resuming_info = {k: kw[k] for k in kw.get(SORT_KEY) or []}
|
1245
|
+
resuming_info = {
|
1246
|
+
k: kw.get(k, data.get(k)) for k in kw.get(SORT_KEY) or []
|
1247
|
+
}
|
1248
|
+
# force to be json compatible
|
1249
|
+
resuming_info = JSONVerter.to_json(resuming_info)
|
1250
|
+
|
1251
|
+
res0 = await self.storage.put(
|
1252
|
+
query,
|
1253
|
+
data,
|
1254
|
+
)
|
1255
|
+
# 3. finally add the wave info into tube
|
1256
|
+
data.pop(MONOTONIC_KEY)
|
1258
1257
|
|
1259
1258
|
# update the TUBE_WAVE due the insertion of this object
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
wave = wave0.get("wave") # TODO: use a define
|
1269
|
-
if wave:
|
1270
|
-
break
|
1271
|
-
else:
|
1272
|
-
# otherwise, its the 1st time and we need to create the 1st
|
1273
|
-
# bootstrap-wave info
|
1274
|
-
wave_keys = set(kw.get(WAVE_INFO_KEY, []))
|
1275
|
-
wave_keys.update([KIND_KEY, PREFIX_URL, PARAMS_KEY])
|
1276
|
-
# task = kw[TASK_KEY]
|
1277
|
-
wave = {k: kw[k] for k in wave_keys.intersection(kw)}
|
1278
|
-
|
1259
|
+
# 2. save last Wave from this particular tube
|
1260
|
+
# AVOID_KEYS contains all keys that aren't json serializable
|
1261
|
+
# wave = {
|
1262
|
+
# k: v for k, v in kw.items() if k not in self.AVOID_KEYS
|
1263
|
+
# }
|
1264
|
+
# try to recover the 'intact' bootstrap that we've using
|
1265
|
+
for wave0 in kw.get(WAVE_LAST_KEY, []):
|
1266
|
+
wave = wave0.get("wave") # TODO: use a define
|
1279
1267
|
if wave:
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
#
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1268
|
+
break
|
1269
|
+
else:
|
1270
|
+
# otherwise, its the 1st time and we need to create the 1st
|
1271
|
+
# bootstrap-wave info
|
1272
|
+
wave_keys = set(kw.get(WAVE_INFO_KEY, []))
|
1273
|
+
wave_keys.update([KIND_KEY, PREFIX_URL, PARAMS_KEY])
|
1274
|
+
# task = kw[TASK_KEY]
|
1275
|
+
wave = {k: kw[k] for k in wave_keys.intersection(kw)}
|
1276
|
+
|
1277
|
+
if wave:
|
1278
|
+
# wave must be json compatible and do not use any reserved
|
1279
|
+
# keyword for storage (i.e. 'scope' in Surreal)
|
1280
|
+
query = f"{namespace}://{database}/{TUBE_WAVE}"
|
1281
|
+
|
1282
|
+
# query can't containg MONOTONIC_KEY
|
1283
|
+
wave.pop(MONOTONIC_KEY, None)
|
1284
|
+
wave.pop(WAVE_RESUMING_INFO_KEY, None)
|
1285
|
+
exists = await self.storage.query(query, **wave)
|
1286
|
+
assert len(exists) <= 1
|
1287
|
+
|
1288
|
+
if len(exists):
|
1289
|
+
# use the same record_id
|
1290
|
+
# otherwise a new record will be created
|
1291
|
+
wave = exists[0]
|
1292
|
+
# stamp current wave
|
1293
|
+
_wave = {
|
1294
|
+
**wave,
|
1295
|
+
MONOTONIC_KEY: monotonic,
|
1296
|
+
WAVE_RESUMING_INFO_KEY: resuming_info,
|
1297
|
+
}
|
1298
|
+
res1 = await self.storage.put(query, _wave)
|
1299
|
+
else:
|
1300
|
+
# wave is empty, maybe because is not a resuming crawling task
|
1301
|
+
log.debug(
|
1302
|
+
"wave is empty, maybe because is not a resuming crawling task"
|
1303
|
+
)
|
1304
|
+
# log.info("Saving: %s", data)
|
1305
|
+
res1 = True
|
1308
1306
|
|
1309
1307
|
return all([res0, res1, res2])
|
1310
1308
|
else:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: syncmodels
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.338
|
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.
|
21
|
+
Requires-Dist: agptools>=0.1.338
|
22
22
|
Requires-Dist: aiocache
|
23
23
|
Requires-Dist: aiohttp
|
24
24
|
Requires-Dist: Click
|
@@ -1,4 +1,4 @@
|
|
1
|
-
syncmodels/__init__.py,sha256=
|
1
|
+
syncmodels/__init__.py,sha256=IHNYa8suqew_JE1aEQu5M9rU0XB_Ef21fZtioO0ACxo,142
|
2
2
|
syncmodels/context.py,sha256=k1Gs_ip9BfyRFpyRnzqYvRDKo0sYBqJsh6z9sWln9oE,451
|
3
3
|
syncmodels/crawler.py,sha256=DAD2tL93iG-LjNQRCg2h_snusjGhQyhdZyMPOCEyvNU,94499
|
4
4
|
syncmodels/crud.py,sha256=oZIcwEKR2i-lesEF_059Y4yThohd9m7gs6R6xYgLH-I,15351
|
@@ -11,7 +11,7 @@ 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
13
|
syncmodels/schema.py,sha256=uinUt8Asq_x7xa6MKWVXNyoWO6gKocjGPppjimaXzEU,2492
|
14
|
-
syncmodels/storage.py,sha256=
|
14
|
+
syncmodels/storage.py,sha256=NSjr3KRcwo1VXaQ9OwZ6IKwjBQC-AvmEzc5w_T0ejP4,74703
|
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
|
@@ -297,16 +297,16 @@ syncmodels/model/schema_org/webpage.py,sha256=-bqKOpEs_2lW7qrey2nHtvOZ9xbmmwcviN
|
|
297
297
|
syncmodels/model/schema_org/webpageelement.py,sha256=brXfhU3l3FBXpy8qnR1Ve-EckjHW8VGoyR2IsnT7t2Y,1104
|
298
298
|
syncmodels/model/schema_org/website.py,sha256=48Rox27BbFIg1u3wDlOtX-lLCPoFgvvrCw5Hrdf6uRU,912
|
299
299
|
syncmodels/model/schema_org/xpathtype.py,sha256=D8gKiCrGSSuUVYw7BIWmOIUbKATfv2IpbkV1B2TmjC0,484
|
300
|
-
syncmodels/session/__init__.py,sha256=
|
300
|
+
syncmodels/session/__init__.py,sha256=pjn-IOG3IZmnHZEvkDIAG8YtElHk3aYi13f2uBUZDHs,15581
|
301
301
|
syncmodels/session/http.py,sha256=tf7z0ccAEYoCOZT4Ukv3NBXz9hUO3vs2s9bm491pCj8,1480
|
302
302
|
syncmodels/session/postgresql.py,sha256=ZMIu1Rv93pKfvFlovFBmWArzlrT2xaQWNYGZT_LW61k,175
|
303
303
|
syncmodels/session/sql.py,sha256=17C8EHn_1twHezhMlD5esMvx4m0iIrnD7JK-TuBswgU,6573
|
304
304
|
syncmodels/session/sqlite.py,sha256=nCDjopLiBpX1F10qkKoARM7JrVdIpJ1WdGOduFVxaiA,2080
|
305
305
|
syncmodels/source/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
306
|
-
syncmodels-0.1.
|
307
|
-
syncmodels-0.1.
|
308
|
-
syncmodels-0.1.
|
309
|
-
syncmodels-0.1.
|
310
|
-
syncmodels-0.1.
|
311
|
-
syncmodels-0.1.
|
312
|
-
syncmodels-0.1.
|
306
|
+
syncmodels-0.1.338.dist-info/AUTHORS.rst,sha256=3ZPoqg8Aav8DSYKd0fwcwn4_5HwSiMLart0E5Un00-U,168
|
307
|
+
syncmodels-0.1.338.dist-info/LICENSE,sha256=uzMOYtIiUsnsD0xHJR7aJWJ4v_bvan0kTnvufy5eNoA,1075
|
308
|
+
syncmodels-0.1.338.dist-info/METADATA,sha256=ysnQ84n_dQ61YNQBqIlMCcJ6Y_4tIlc6iYZiE9S0GHg,2700
|
309
|
+
syncmodels-0.1.338.dist-info/WHEEL,sha256=SrDKpSbFN1G94qcmBqS9nyHcDMp9cUS9OC06hC0G3G0,109
|
310
|
+
syncmodels-0.1.338.dist-info/entry_points.txt,sha256=dMnigjZsHMxTwXiiZyBZdBbMYE0-hY3L5cG15EcDAzw,51
|
311
|
+
syncmodels-0.1.338.dist-info/top_level.txt,sha256=2DfQ9NuAhKMjY3BvQGVBA7GfqTm7EoHNbaehSUiqiHQ,11
|
312
|
+
syncmodels-0.1.338.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|