syncmodels 0.1.337__py2.py3-none-any.whl → 0.1.339__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 +2 -1
- syncmodels/storage.py +78 -78
- {syncmodels-0.1.337.dist-info → syncmodels-0.1.339.dist-info}/METADATA +2 -2
- {syncmodels-0.1.337.dist-info → syncmodels-0.1.339.dist-info}/RECORD +10 -10
- {syncmodels-0.1.337.dist-info → syncmodels-0.1.339.dist-info}/AUTHORS.rst +0 -0
- {syncmodels-0.1.337.dist-info → syncmodels-0.1.339.dist-info}/LICENSE +0 -0
- {syncmodels-0.1.337.dist-info → syncmodels-0.1.339.dist-info}/WHEEL +0 -0
- {syncmodels-0.1.337.dist-info → syncmodels-0.1.339.dist-info}/entry_points.txt +0 -0
- {syncmodels-0.1.337.dist-info → syncmodels-0.1.339.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
|
@@ -418,6 +418,7 @@ class iSession(iContext, iSchema, iRegistry): # , iAuthenticator):
|
|
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
@@ -360,8 +360,10 @@ class StoragePort(Storage):
|
|
360
360
|
"Returns storage info: *tables*, etc"
|
361
361
|
_uri = parse_duri(pattern)
|
362
362
|
simplified = "{fscheme}/{xhost}/{_path}".format_map(_uri)
|
363
|
-
|
364
|
-
example = self._file(
|
363
|
+
# example = self._file("example/foo/bar") # pickle
|
364
|
+
example = self.other._file(
|
365
|
+
"example/foo/bar"
|
366
|
+
) # yaml is safer when finding files
|
365
367
|
ext = os.path.splitext(example)[-1]
|
366
368
|
regexp = f"{simplified}.*{ext}$"
|
367
369
|
top = "."
|
@@ -1225,86 +1227,84 @@ class WaveStorage(iWaves, iStorage):
|
|
1225
1227
|
res2 = True
|
1226
1228
|
|
1227
1229
|
# 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)
|
1230
|
+
# long fquid version
|
1231
|
+
# data[ID_KEY] = data[ORG_KEY]
|
1232
|
+
# short version
|
1233
|
+
# data[ID_KEY] = "{thing}:{id}".format_map(_uri)
|
1234
|
+
if _uri["id"] is None:
|
1235
|
+
__id = data.get(ORG_KEY, "")
|
1236
|
+
_id = parse_duri(__id)
|
1237
|
+
if _id["id"] is None:
|
1238
|
+
_uri["id"] = __id
|
1239
|
+
else:
|
1240
|
+
_uri["id"] = _id["id"]
|
1241
|
+
data[ORG_KEY] = build_uri(**_uri)
|
1251
1242
|
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
data.
|
1243
|
+
data[ID_KEY] = "{thing}:{id}".format_map(_uri)
|
1244
|
+
query = f"{namespace}://{database}/{TUBE_SNAPSHOT}"
|
1245
|
+
# resuming_info = {k: kw[k] for k in kw.get(REVERSE_SORT_KEY, [])}
|
1246
|
+
# resuming_info = {k: kw[k] for k in kw.get(SORT_KEY) or []}
|
1247
|
+
resuming_info = {
|
1248
|
+
k: kw.get(k, data.get(k)) for k in kw.get(SORT_KEY) or []
|
1249
|
+
}
|
1250
|
+
# force to be json compatible
|
1251
|
+
resuming_info = JSONVerter.to_json(resuming_info)
|
1252
|
+
|
1253
|
+
res0 = await self.storage.put(
|
1254
|
+
query,
|
1255
|
+
data,
|
1256
|
+
)
|
1257
|
+
# 3. finally add the wave info into tube
|
1258
|
+
data.pop(MONOTONIC_KEY)
|
1258
1259
|
|
1259
1260
|
# 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
|
-
|
1261
|
+
# 2. save last Wave from this particular tube
|
1262
|
+
# AVOID_KEYS contains all keys that aren't json serializable
|
1263
|
+
# wave = {
|
1264
|
+
# k: v for k, v in kw.items() if k not in self.AVOID_KEYS
|
1265
|
+
# }
|
1266
|
+
# try to recover the 'intact' bootstrap that we've using
|
1267
|
+
for wave0 in kw.get(WAVE_LAST_KEY, []):
|
1268
|
+
wave = wave0.get("wave") # TODO: use a define
|
1279
1269
|
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
|
-
|
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
|
+
|
1279
|
+
if wave:
|
1280
|
+
# wave must be json compatible and do not use any reserved
|
1281
|
+
# keyword for storage (i.e. 'scope' in Surreal)
|
1282
|
+
query = f"{namespace}://{database}/{TUBE_WAVE}"
|
1283
|
+
|
1284
|
+
# query can't containg MONOTONIC_KEY
|
1285
|
+
wave.pop(MONOTONIC_KEY, None)
|
1286
|
+
wave.pop(WAVE_RESUMING_INFO_KEY, None)
|
1287
|
+
exists = await self.storage.query(query, **wave)
|
1288
|
+
assert len(exists) <= 1
|
1289
|
+
|
1290
|
+
if len(exists):
|
1291
|
+
# use the same record_id
|
1292
|
+
# otherwise a new record will be created
|
1293
|
+
wave = exists[0]
|
1294
|
+
# stamp current wave
|
1295
|
+
_wave = {
|
1296
|
+
**wave,
|
1297
|
+
MONOTONIC_KEY: monotonic,
|
1298
|
+
WAVE_RESUMING_INFO_KEY: resuming_info,
|
1299
|
+
}
|
1300
|
+
res1 = await self.storage.put(query, _wave)
|
1301
|
+
else:
|
1302
|
+
# wave is empty, maybe because is not a resuming crawling task
|
1303
|
+
log.debug(
|
1304
|
+
"wave is empty, maybe because is not a resuming crawling task"
|
1305
|
+
)
|
1306
|
+
# log.info("Saving: %s", data)
|
1307
|
+
res1 = True
|
1308
1308
|
|
1309
1309
|
return all([res0, res1, res2])
|
1310
1310
|
else:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: syncmodels
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.339
|
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.339
|
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=i0JzNcq2trLiNdW2FJGXvp96SPoehnj8TJU76ZrMHjM,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=8Gt2iEoMdMfv_AljsrBggKXnCKzKkAaYVWRF9PdcKh0,74825
|
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.339.dist-info/AUTHORS.rst,sha256=3ZPoqg8Aav8DSYKd0fwcwn4_5HwSiMLart0E5Un00-U,168
|
307
|
+
syncmodels-0.1.339.dist-info/LICENSE,sha256=uzMOYtIiUsnsD0xHJR7aJWJ4v_bvan0kTnvufy5eNoA,1075
|
308
|
+
syncmodels-0.1.339.dist-info/METADATA,sha256=L3I2KBAFvPiBYOM93PLqdaxUTm2djGQbKtObIh2atPU,2700
|
309
|
+
syncmodels-0.1.339.dist-info/WHEEL,sha256=SrDKpSbFN1G94qcmBqS9nyHcDMp9cUS9OC06hC0G3G0,109
|
310
|
+
syncmodels-0.1.339.dist-info/entry_points.txt,sha256=dMnigjZsHMxTwXiiZyBZdBbMYE0-hY3L5cG15EcDAzw,51
|
311
|
+
syncmodels-0.1.339.dist-info/top_level.txt,sha256=2DfQ9NuAhKMjY3BvQGVBA7GfqTm7EoHNbaehSUiqiHQ,11
|
312
|
+
syncmodels-0.1.339.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|