MCPcopy
hub / github.com/Kanaries/pygwalker / run

Method run

pygwalker/services/upload_data.py:36–74  ·  view source on GitHub ↗
(
        self,
        *,
        data_source_id: str,
        gid: int,
        tunnel_id: str,
        records: List[Dict[str, Any]],
        sample_data_count: int,
        slot_count: int = 2
    )

Source from the content-addressed store, hash-verified

34class BatchUploadDatasToolOnJupyter:
35 """Upload data in batches."""
36 def run(
37 self,
38 *,
39 data_source_id: str,
40 gid: int,
41 tunnel_id: str,
42 records: List[Dict[str, Any]],
43 sample_data_count: int,
44 slot_count: int = 2
45 ) -> None:
46 chunk = 1 << 12
47 cur_slot = 0
48 display_slots = [_rand_slot_id() for _ in range(slot_count)]
49
50 time.sleep(1)
51 for i in range(sample_data_count, len(records), chunk):
52 data = records[i: min(i+chunk, len(records))]
53 msg = {
54 'action': 'postData',
55 'tunnelId': tunnel_id,
56 'dataSourceId': data_source_id,
57 'data': data,
58 "total": len(records),
59 "curIndex": i,
60 }
61 _send_upload_data_msg(gid, msg, display_slots[cur_slot])
62 cur_slot += 1
63 cur_slot %= slot_count
64
65 finish_msg = {
66 'action': 'finishData',
67 'tunnelId': tunnel_id,
68 'dataSourceId': data_source_id,
69 }
70 time.sleep(1)
71 _send_upload_data_msg(gid, finish_msg, display_slots[cur_slot])
72
73 for slot_id in display_slots:
74 display_html("", slot_id=slot_id)
75
76
77class BatchUploadDatasToolOnWidgets:

Callers 3

display_on_jupyterMethod · 0.95
reuqest_data_callbackMethod · 0.45
marimo_demo.pyFile · 0.45

Calls 3

display_htmlFunction · 0.90
_rand_slot_idFunction · 0.85
_send_upload_data_msgFunction · 0.85

Tested by

no test coverage detected