synapse 2.174.0__py311-none-any.whl → 2.176.0__py311-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 synapse might be problematic. Click here for more details.

synapse/cortex.py CHANGED
@@ -4027,6 +4027,7 @@ class Cortex(s_oauth.OAuthMixin, s_cell.Cell): # type: ignore
4027
4027
  self.addStormCmd(s_storm.MoveNodesCmd)
4028
4028
  self.addStormCmd(s_storm.BackgroundCmd)
4029
4029
  self.addStormCmd(s_stormlib_macro.MacroExecCmd)
4030
+ self.addStormCmd(s_stormlib_storm.StormExecCmd)
4030
4031
  self.addStormCmd(s_stormlib_stats.StatsCountByCmd)
4031
4032
  self.addStormCmd(s_stormlib_cortex.StormPoolDelCmd)
4032
4033
  self.addStormCmd(s_stormlib_cortex.StormPoolGetCmd)
synapse/daemon.py CHANGED
@@ -178,7 +178,7 @@ async def t2call(link, meth, args, kwargs):
178
178
  if isinstance(e, asyncio.CancelledError):
179
179
  logger.info('t2call task %s cancelled', meth.__name__)
180
180
  else:
181
- logger.exception('error during task %s', meth.__name__)
181
+ logger.exception(f'error during task {meth.__name__} {e}')
182
182
 
183
183
  if isinstance(valu, types.AsyncGeneratorType):
184
184
  await valu.aclose()
@@ -211,7 +211,7 @@ async def t2call(link, meth, args, kwargs):
211
211
  return
212
212
 
213
213
  except (asyncio.CancelledError, Exception) as e:
214
- logger.exception('error during task: %s', meth.__name__)
214
+ logger.exception(f'error during task: {meth.__name__} {e}')
215
215
  if not link.isfini:
216
216
  retn = s_common.retnexc(e)
217
217
  await link.tx(('t2:fini', {'retn': retn}))
@@ -380,24 +380,23 @@ class Daemon(s_base.Base):
380
380
 
381
381
  link.schedCoro(rxloop())
382
382
 
383
- async def _onLinkMesg(self, link, mesg):
383
+ async def _onLinkMesg(self, link: s_link.Link, mesg):
384
384
 
385
385
  try:
386
386
  func = self.mesgfuncs.get(mesg[0])
387
387
  if func is None:
388
- logger.exception('Dmon.onLinkMesg Invalid: %.80r' % (mesg,))
388
+ logger.error(f'Dmon.onLinkMesg Invalid mesg: mesg={s_common.trimText(repr(mesg), n=80)} '
389
+ f'link={link.getAddrInfo()}')
389
390
  return
390
391
 
391
392
  await func(link, mesg)
392
393
 
393
- except asyncio.CancelledError: # pragma: no cover # TODO: remove once >= py 3.8 only
394
- raise
395
-
396
394
  except ConnectionResetError:
397
- logger.debug('Dmon.onLinkMesg Handler: connection reset')
395
+ logger.debug(f'Dmon.onLinkMesg Handler: connection reset link={link.getAddrInfo()}')
398
396
 
399
397
  except Exception:
400
- logger.exception('Dmon.onLinkMesg Handler: %.80r' % (mesg,))
398
+ logger.exception(f'Dmon.onLinkMesg Handler: mesg={s_common.trimText(repr(mesg), n=80)} '
399
+ f'link={link.getAddrInfo()}')
401
400
 
402
401
  async def _onShareFini(self, link, mesg):
403
402
 
@@ -473,7 +472,7 @@ class Daemon(s_base.Base):
473
472
  reply[1]['sess'] = sess.iden
474
473
 
475
474
  except Exception as e:
476
- logger.exception('tele:syn error')
475
+ logger.exception(f'tele:syn error: {e} link={link.getAddrInfo()}')
477
476
  reply[1]['retn'] = s_common.retnexc(e)
478
477
 
479
478
  await link.tx(reply)
@@ -501,7 +500,7 @@ class Daemon(s_base.Base):
501
500
  typename = valu.typename
502
501
  return ('task:fini', {'task': task, 'retn': retn, 'type': typename})
503
502
 
504
- async def _onTaskV2Init(self, link, mesg):
503
+ async def _onTaskV2Init(self, link: s_link.Link, mesg):
505
504
 
506
505
  # t2:init is used by the pool sockets on the client
507
506
  name = mesg[1].get('name')
@@ -539,7 +538,7 @@ class Daemon(s_base.Base):
539
538
  sess.onfini(sessitem)
540
539
 
541
540
  except (asyncio.CancelledError, Exception) as e:
542
- logger.exception('on t2:init: %r' % (mesg,))
541
+ logger.exception(f'Error on t2:init: {s_common.trimText(repr(mesg), n=80)} link={link.getAddrInfo()}')
543
542
  if not link.isfini:
544
543
  retn = s_common.retnexc(e)
545
544
  await link.tx(('t2:fini', {'retn': retn}))
synapse/lib/ast.py CHANGED
@@ -284,7 +284,7 @@ class Search(Query):
284
284
  view = runt.snap.view
285
285
 
286
286
  if not view.core.stormiface_search:
287
- await runt.snap.warn('Storm search interface is not enabled!')
287
+ await runt.snap.warn('Storm search interface is not enabled!', log=False)
288
288
  return
289
289
 
290
290
  async def searchgenr():
@@ -2097,6 +2097,10 @@ class PivotIn(PivotOper):
2097
2097
  async for pivo in runt.snap.nodesByPropArray(prop.full, '=', valu):
2098
2098
  yield pivo, path.fork(pivo)
2099
2099
 
2100
+ async for refsbuid in runt.snap.getNdefRefs(node.buid):
2101
+ pivo = await runt.snap.getNodeByBuid(refsbuid)
2102
+ yield pivo, path.fork(pivo)
2103
+
2100
2104
  class N2WalkNPivo(PivotIn):
2101
2105
 
2102
2106
  async def run(self, runt, genr):
@@ -2385,7 +2389,7 @@ class FormPivot(PivotOper):
2385
2389
  items = e.items()
2386
2390
  mesg = items.pop('mesg', '')
2387
2391
  mesg = ': '.join((f'{e.__class__.__qualname__} [{repr(node.ndef[1])}] during pivot', mesg))
2388
- await runt.snap.warn(mesg, **items)
2392
+ await runt.snap.warn(mesg, log=False, **items)
2389
2393
 
2390
2394
  class PropPivotOut(PivotOper):
2391
2395
  '''
@@ -2424,7 +2428,7 @@ class PropPivotOut(PivotOper):
2424
2428
  if runt.model.forms.get(fname) is None:
2425
2429
  if not warned:
2426
2430
  mesg = f'The source property "{name}" array type "{fname}" is not a form. Cannot pivot.'
2427
- await runt.snap.warn(mesg)
2431
+ await runt.snap.warn(mesg, log=False)
2428
2432
  warned = True
2429
2433
  continue
2430
2434
 
@@ -2448,7 +2452,8 @@ class PropPivotOut(PivotOper):
2448
2452
  fname = prop.type.name
2449
2453
  if prop.modl.form(fname) is None:
2450
2454
  if warned is False:
2451
- await runt.snap.warn(f'The source property "{name}" type "{fname}" is not a form. Cannot pivot.')
2455
+ await runt.snap.warn(f'The source property "{name}" type "{fname}" is not a form. Cannot pivot.',
2456
+ log=False)
2452
2457
  warned = True
2453
2458
  continue
2454
2459
 
@@ -2570,7 +2575,7 @@ class PropPivot(PivotOper):
2570
2575
  items = e.items()
2571
2576
  mesg = items.pop('mesg', '')
2572
2577
  mesg = ': '.join((f'{e.__class__.__qualname__} [{repr(valu)}] during pivot', mesg))
2573
- await runt.snap.warn(mesg, **items)
2578
+ await runt.snap.warn(mesg, log=False, **items)
2574
2579
 
2575
2580
  class Value(AstNode):
2576
2581
  '''
synapse/lib/cell.py CHANGED
@@ -1100,6 +1100,7 @@ class Cell(s_nexus.Pusher, s_telepath.Aware):
1100
1100
  self.inaugural = False
1101
1101
  self.activecoros = {}
1102
1102
  self.sockaddr = None # Default value...
1103
+ self.https_listeners = []
1103
1104
  self.ahaclient = None
1104
1105
  self._checkspace = s_coro.Event()
1105
1106
  self._reloadfuncs = {} # name -> func
@@ -2822,6 +2823,8 @@ class Cell(s_nexus.Pusher, s_telepath.Aware):
2822
2823
 
2823
2824
  self.addReloadableSystem('https:certs', reload)
2824
2825
 
2826
+ self.https_listeners.append({'host': lhost, 'port': lport})
2827
+
2825
2828
  return (lhost, lport)
2826
2829
 
2827
2830
  def initSslCtx(self, certpath, keypath):
@@ -2877,18 +2880,7 @@ class Cell(s_nexus.Pusher, s_telepath.Aware):
2877
2880
 
2878
2881
  log_method(mesg, extra=extra)
2879
2882
 
2880
- async def _initCellHttp(self):
2881
-
2882
- self.httpds = []
2883
- self.sessstor = s_lmdbslab.GuidStor(self.slab, 'http:sess')
2884
-
2885
- async def fini():
2886
- [await s.fini() for s in self.sessions.values()]
2887
- for http in self.httpds:
2888
- http.stop()
2889
-
2890
- self.onfini(fini)
2891
-
2883
+ async def _getCellHttpOpts(self):
2892
2884
  # Generate/Load a Cookie Secret
2893
2885
  secpath = os.path.join(self.dirn, 'cookie.secret')
2894
2886
  if not os.path.isfile(secpath):
@@ -2898,12 +2890,26 @@ class Cell(s_nexus.Pusher, s_telepath.Aware):
2898
2890
  with s_common.getfile(secpath) as fd:
2899
2891
  secret = fd.read().decode('utf8')
2900
2892
 
2901
- opts = {
2893
+ return {
2902
2894
  'cookie_secret': secret,
2903
2895
  'log_function': self._log_web_request,
2904
2896
  'websocket_ping_interval': 10
2905
2897
  }
2906
2898
 
2899
+ async def _initCellHttp(self):
2900
+
2901
+ self.httpds = []
2902
+ self.sessstor = s_lmdbslab.GuidStor(self.slab, 'http:sess')
2903
+
2904
+ async def fini():
2905
+ [await s.fini() for s in self.sessions.values()]
2906
+ for http in self.httpds:
2907
+ http.stop()
2908
+
2909
+ self.onfini(fini)
2910
+
2911
+ opts = await self._getCellHttpOpts()
2912
+
2907
2913
  self.wapp = t_web.Application(**opts)
2908
2914
  self._initCellHttpApis()
2909
2915
 
@@ -4070,6 +4076,9 @@ class Cell(s_nexus.Pusher, s_telepath.Aware):
4070
4076
  'name': self.conf.get('aha:name'),
4071
4077
  'leader': self.conf.get('aha:leader'),
4072
4078
  'network': self.conf.get('aha:network'),
4079
+ },
4080
+ 'network': {
4081
+ 'https': self.https_listeners,
4073
4082
  }
4074
4083
  },
4075
4084
  'features': {
synapse/lib/jupyter.py CHANGED
@@ -38,6 +38,7 @@ def getDocPath(fn, root=None):
38
38
  Raises:
39
39
  ValueError if the file does not exist or directory traversal attempted..
40
40
  '''
41
+ s_common.deprdate('synapse.lib.jupyter.getDocPath', '2024-08-26')
41
42
  cwd = pathlib.Path(os.getcwd())
42
43
  if root:
43
44
  cwd = pathlib.Path(root)
@@ -84,6 +85,7 @@ def getDocData(fp, root=None):
84
85
  Raises:
85
86
  ValueError if the file does not exist or directory traversal attempted..
86
87
  '''
88
+ s_common.deprdate('synapse.lib.jupyter.getDocData', '2024-08-26')
87
89
  fpath = getDocPath(fp, root)
88
90
  if fpath.endswith('.yaml'):
89
91
  return s_common.yamlload(fpath)
@@ -103,6 +105,7 @@ def getDocData(fp, root=None):
103
105
  @contextlib.asynccontextmanager
104
106
  async def genTempCoreProxy(mods=None):
105
107
  '''Get a temporary cortex proxy.'''
108
+ s_common.deprdate('synapse.lib.jupyter.genTempCoreProxy', '2024-08-26')
106
109
  with s_common.getTempDir() as dirn:
107
110
  async with await s_cortex.Cortex.anit(dirn) as core:
108
111
  if mods:
@@ -115,6 +118,8 @@ async def genTempCoreProxy(mods=None):
115
118
 
116
119
  @contextlib.asynccontextmanager
117
120
  async def genTempStormsvcProxy(cmdrcore, svcname, svcctor, conf=None):
121
+ s_common.deprdate('synapse.lib.jupyter.genTempStormsvcProxy', '2024-08-26')
122
+
118
123
  if conf is None:
119
124
  conf = {}
120
125
 
@@ -142,12 +147,14 @@ async def genTempStormsvcProxy(cmdrcore, svcname, svcctor, conf=None):
142
147
 
143
148
  async def getItemStorm(prox, outp=None):
144
149
  '''Get a Storm CLI instance with prepopulated locs'''
150
+ s_common.deprdate('synapse.lib.jupyter.getItemStorm', '2024-08-26')
145
151
  storm = await s_t_storm.StormCli.anit(prox, outp=outp)
146
152
  storm.echoline = True
147
153
  return storm
148
154
 
149
155
  async def getItemCmdr(prox, outp=None, locs=None):
150
156
  '''Get a Cmdr instance with prepopulated locs'''
157
+ s_common.deprdate('synapse.lib.jupyter.getItemCmdr', '2024-08-26')
151
158
  cmdr = await s_cmdr.getItemCmdr(prox, outp=outp)
152
159
  cmdr.echoline = True
153
160
  if locs:
@@ -159,6 +166,7 @@ def suppress_logging(suppress):
159
166
  '''
160
167
  Context manager to suppress specific loggers.
161
168
  '''
169
+ s_common.deprdate('synapse.lib.jupyter.suppress_logging', '2024-08-26')
162
170
  logs = {}
163
171
  if not suppress:
164
172
  yield None
@@ -197,6 +205,7 @@ class StormCore(s_base.Base):
197
205
  '''
198
206
  Context manager to suppress specific loggers.
199
207
  '''
208
+ s_common.deprdate('StormCore.suppress_logging', '2024-08-26')
200
209
  with suppress_logging(suppress):
201
210
  yield None
202
211
 
@@ -204,6 +213,7 @@ class StormCore(s_base.Base):
204
213
  '''
205
214
  Run a line of text directly via storm cli.
206
215
  '''
216
+ s_common.deprdate('StormCore.runCmdLine', '2024-08-26')
207
217
  await self.stormcli.runCmdLine(text, opts=opts)
208
218
 
209
219
  async def _runStorm(self, text, opts=None, cli=False, suppress_logging=False):
@@ -240,6 +250,7 @@ class StormCore(s_base.Base):
240
250
  Returns:
241
251
  list: A list of storm messages.
242
252
  '''
253
+ s_common.deprdate('StormCore.storm', '2024-08-26')
243
254
  mesgs = await self._runStorm(text, opts, cli, suppress_logging)
244
255
  if num is not None:
245
256
  nodes = [m for m in mesgs if m[0] == 'node']
@@ -265,12 +276,14 @@ class CmdrCore(s_base.Base):
265
276
  '''
266
277
  Add feed data to the cortex.
267
278
  '''
279
+ s_common.deprdate('CmdrCore.addFeedData', '2024-08-26')
268
280
  return await self.core.addFeedData(name, items, viewiden=viewiden)
269
281
 
270
282
  async def runCmdLine(self, text):
271
283
  '''
272
284
  Run a line of text directly via cmdr.
273
285
  '''
286
+ s_common.deprdate('CmdrCore.runCmdLine', '2024-08-26')
274
287
  await self.cmdr.runCmdLine(text)
275
288
 
276
289
  @contextlib.contextmanager
@@ -278,6 +291,7 @@ class CmdrCore(s_base.Base):
278
291
  '''
279
292
  Context manager to suppress specific loggers.
280
293
  '''
294
+ s_common.deprdate('CmdrCore.suppress_logging', '2024-08-26')
281
295
  with suppress_logging(suppress):
282
296
  yield None
283
297
 
@@ -318,6 +332,7 @@ class CmdrCore(s_base.Base):
318
332
  Returns:
319
333
  list: A list of storm messages.
320
334
  '''
335
+ s_common.deprdate('CmdrCore.storm', '2024-08-26')
321
336
  mesgs = await self._runStorm(text, opts, cmdr, suppress_logging)
322
337
  if num is not None:
323
338
  nodes = [m for m in mesgs if m[0] == 'node']
@@ -342,6 +357,7 @@ class CmdrCore(s_base.Base):
342
357
  Returns:
343
358
  list: A list of packed nodes.
344
359
  '''
360
+ s_common.deprdate('CmdrCore.eval', '2024-08-26')
345
361
  mesgs = await self._runStorm(text, opts, cmdr)
346
362
  for mesg in mesgs:
347
363
  if mesg[0] == 'err': # pragma: no cover
@@ -375,6 +391,7 @@ async def getTempCoreProx(mods=None):
375
391
  Returns:
376
392
  s_telepath.Proxy
377
393
  '''
394
+ s_common.deprdate('synapse.lib.jupyter.getTempCoreProx', '2024-08-26')
378
395
  acm = genTempCoreProxy(mods)
379
396
  prox = await acm.__aenter__()
380
397
  # Use object.__setattr__ to hulk smash and avoid proxy getattr magick
@@ -399,6 +416,7 @@ async def getTempCoreStorm(mods=None, outp=None):
399
416
  Returns:
400
417
  StormCore: A StormCore instance.
401
418
  '''
419
+ s_common.deprdate('synapse.lib.jupyter.getTempCoreStorm', '2024-08-26')
402
420
  acm = genTempCoreProxy(mods)
403
421
  prox = await acm.__aenter__()
404
422
  stormcore = await StormCore.anit(prox, outp=outp)
@@ -419,6 +437,7 @@ async def getTempCoreCmdr(mods=None, outp=None):
419
437
  Returns:
420
438
  CmdrCore: A CmdrCore instance.
421
439
  '''
440
+ s_common.deprdate('synapse.lib.jupyter.getTempCoreCmdr', '2024-08-26')
422
441
  acm = genTempCoreProxy(mods)
423
442
  prox = await acm.__aenter__()
424
443
  cmdrcore = await CmdrCore.anit(prox, outp=outp)
@@ -441,6 +460,7 @@ async def getTempCoreCmdrStormsvc(svcname, svcctor, svcconf=None, outp=None):
441
460
  Returns:
442
461
  (CmdrCore, Proxy): A CmdrCore instance and proxy to the Storm service
443
462
  '''
463
+ s_common.deprdate('synapse.lib.jupyter.getTempCoreCmdrStormsvc', '2024-08-26')
444
464
  cmdrcore = await getTempCoreCmdr(outp=outp)
445
465
 
446
466
  acm = genTempStormsvcProxy(cmdrcore, svcname, svcctor, svcconf)
@@ -470,6 +490,7 @@ async def getTempCoreStormStormsvc(svcname, svcctor, svcconf=None, outp=None):
470
490
  Returns:
471
491
  (StormCore, Proxy): A StormCore instance and proxy to the Storm service
472
492
  '''
493
+ s_common.deprdate('synapse.lib.jupyter.getTempCoreStormStormsvc', '2024-08-26')
473
494
  stormcore = await getTempCoreStorm(outp=outp)
474
495
 
475
496
  acm = genTempStormsvcProxy(stormcore, svcname, svcctor, svcconf)