Esempio n. 1
0
 def components():
     graph = lk.createVertices(size=1000).createRandomEdges(
         degree=2, seed=pp('${date.hashCode()}'))
     component_metrics = graph.findConnectedComponents().sql(
         pp('''
       select
       "$date" as date_id,
       max(size) as max_size,
       min(size) as min_size,
       count(*) as num_components
       from `connected_components.vertices`'''))
     return dict(metrics=component_metrics)
Esempio n. 2
0
 def components(sec_collector, table):
     graph = table.useTableAsGraph(src='src', dst='dst')
     component_metrics = graph.findConnectedComponents().sql(
         pp('''
       select
       "$date" as date_id,
       max(size) as max_size,
       min(size) as min_size,
       count(*) as num_components
       from `connected_components.vertices`'''))
     exp = component_metrics.exportToParquet(path=pp(output_folder +
                                                     '/${date}'))
     exp.register(sec_collector)
     return dict(metrics=component_metrics)
 def parametric_ws(self):
   from lynx.kite import pp, text
   lk = lynx.kite.LynxKite()
   state = lk.createExampleGraph().sql(
       pp('select name from `vertices` where age = $ap')).output(name='table')
   ws = lynx.kite.Workspace([state], name='ws params', ws_parameters=[text('ap', '18.2')])
   return ws
 def test_parametric_parameters(self):
   from lynx.kite import pp
   lk = lynx.kite.LynxKite()
   graph = lk.createExampleGraph().deriveGraphAttribute(
       output='pi', expr=pp('${2+1.14}')).get_graph()
   scalars = {s.title: lk.get_graph_attribute(s.id) for s in graph.graphAttributes}
   self.assertEqual(scalars['pi'].string, '3.14')
def save(table):
    table_with_timestamp = table.sql(
        pp('''
    select
    "$date" as date_id,
    cast(supporters as integer) as supporters,
    cast(amount as integer) as amount
    from input'''))
    return dict(hourly=table_with_timestamp)
Esempio n. 6
0
 def components(table):
     graph = table.useTableAsGraph(src='src', dst='dst')
     component_metrics = graph.findConnectedComponents().sql(
         pp('''
       select
       "$date" as date_id,
       max(size) as max_size,
       min(size) as min_size,
       count(*) as num_components
       from `connected_components.vertices`'''))
     return dict(metrics=component_metrics)
Esempio n. 7
0
 def save_graph_to_snapshot(sec, graph):
   graph.sql('select * from vertices').saveToSnapshot(path=pp('$snapshot_path')).register(sec)
Esempio n. 8
0
 def save_and_return_graph(sec, graph):
   graph.sql('select * from vertices').saveToSnapshot(path=pp('$snapshot_path')).register(sec)
   return dict(graph=graph)
Esempio n. 9
0
 def csv_exporter(sec, table):
   table.exportToCSV(path=pp('$export_path')).register(sec)
 def filter_table(table):
     query = pp(
         'select name, income from input where ${field} > ${limit}')
     out = table.sql(query)
     return dict(table=out)
 def add_ws():
     return (lk.createVertices(size='5').deriveGraphAttribute(
         output='total', expr=pp('${a.toInt+b.toInt+c.toInt}')))
 def f(t):
   return t.sql1(sql=pp('select age from vertices where name == "$name"'))
 def g(x):
   return f(x, p=pp('$p'))
 def f(x):
   return x.sql1(sql=pp('select $p from vertices'))
 def g(t):
   return f(t, query=pp('select $column from vertices limit 1'))