Skip to content

Commit 5eecffe

Browse files
committed
update plugin-pb-python
1 parent 89d3334 commit 5eecffe

File tree

11 files changed

+51
-2
lines changed

11 files changed

+51
-2
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
from .memdb import MemDB
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
from cloudquery.sdk import plugin
3+
from cloudquery.sdk import message
4+
from cloudquery.sdk import schema
5+
from typing import List, Generator, Any, Dict
6+
import pyarrow as pa
7+
8+
NAME = "memdb"
9+
VERSION = "development"
10+
11+
class MemDB(plugin.Plugin):
12+
def __init__(self) -> None:
13+
super().__init__(NAME, VERSION)
14+
self._tables: List[schema.Table] = []
15+
self._memory_db : Dict[str, pa.record] = {
16+
"test_table": pa.record_batch([pa.array([1, 2, 3])], names=["test_column"])
17+
}
18+
19+
def get_tables(self, options : plugin.TableOptions = None) -> List[plugin.Table]:
20+
return self._tables
21+
22+
def sync(self, options: plugin.SyncOptions) -> Generator[message.SyncMessage, None, None]:
23+
for table, record in self._memory_db.items():
24+
yield message.SyncInsertMessage(record)
25+

cloudquery/sdk/plugin/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .plugin import Plugin, Table, TableOptions, SyncOptions

cloudquery/sdk/serve/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .plugin import PluginCommand

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
grpcio==1.56.2
22
grpcio-tools==1.56.2
3-
plugin-pb-python==0.0.11
3+
plugin-pb-python==0.0.12
44
protobuf==4.23.4
55
pyarrow==12.0.1
66
pytest==7.4.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
description = "CloudQuery Plugin SDK for Python"
1111

1212
dependencies = [
13-
"plugin-pb-python==0.0.11",
13+
"plugin-pb-python==0.0.12",
1414
"pyarrow==12.0.1",
1515
"Jinja2==3.1.2",
1616
]

tests/internal/__init__.py

Whitespace-only changes.

tests/internal/memdb/__init__.py

Whitespace-only changes.

tests/internal/memdb/memdb.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
from cloudquery.sdk.internal import memdb
3+
from cloudquery.sdk.plugin import SyncOptions
4+
5+
def test_memdb():
6+
p = memdb.MemDB()
7+
p.init(None)
8+
msgs = []
9+
for msg in p.sync(SyncOptions()):
10+
msgs.append(msg)
11+
assert len(msgs) == 1

tests/serve/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)