Skip to content

fix: Fix JSON and UUID type checking, add JSON test, consolidate setup.py #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions cloudquery/sdk/scalar/scalar_factory.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import pyarrow as pa
from .scalar import ScalarInvalidTypeError

from cloudquery.sdk.types import UUIDType, JSONType
from .binary import Binary
from .bool import Bool
from .date32 import Date32
from .date64 import Date64
from .float import Float
from .int import Int
from .list import List
from .scalar import ScalarInvalidTypeError
from .string import String
from .timestamp import Timestamp
from .uint import Uint
from .uuid import UUID
from cloudquery.sdk.types import UUIDType, JSONType


class ScalarFactory:
Expand Down Expand Up @@ -85,9 +86,9 @@ def new_scalar(self, dt: pa.DataType):
# return ()
elif dt_id == pa.types.lib.Type_TIMESTAMP:
return Timestamp()
elif dt == UUIDType:
elif dt == UUIDType():
return UUID()
elif dt == JSONType:
elif dt == JSONType():
return String()
else:
raise ScalarInvalidTypeError("Invalid type {} for scalar".format(dt))
19 changes: 12 additions & 7 deletions cloudquery/sdk/scheduler/scheduler.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
from typing import List, Generator, Any
import queue
import time
import structlog
import time
import traceback
from concurrent import futures
from enum import Enum
from cloudquery.sdk.schema import Table, Resource
from typing import Generator
from typing import List, Generator, Any

from cloudquery.sdk.message import (
SyncMessage,
SyncInsertMessage,
SyncMigrateTableMessage,
)
from concurrent import futures
from typing import Generator
from cloudquery.sdk.schema import Table, Resource
from .table_resolver import TableResolver
import traceback

QUEUE_PER_WORKER = 100

Expand Down Expand Up @@ -103,11 +104,13 @@ def resolve_table(
)
total_resources = 0
for item in resolver.resolve(client, parent_item):
print("item", item)
try:
resource = self.resolve_resource(
resolver, client, parent_item, item
)
except Exception as e:
print("exception", e)
self._logger.error(
"failed to resolve resource",
table=resolver.table.name,
Expand Down Expand Up @@ -181,6 +184,7 @@ def sync(
finished_table_resolvers = 0
while True:
message = res.get()
print("got message", message)
if type(message) == TableResolverStarted:
total_table_resolvers += message.count
if total_table_resolvers == finished_table_resolvers:
Expand All @@ -192,4 +196,5 @@ def sync(
break
continue
yield message
thread.shutdown()
print("shutting down thread")
thread.shutdown(wait=True)
22 changes: 1 addition & 21 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
cloudquery-plugin-pb==0.0.14
exceptiongroup==1.1.2
black==23.7.0
grpcio==1.56.2
grpcio-tools==1.56.2
iniconfig==2.0.0
Jinja2==3.1.2
MarkupSafe==2.1.3
numpy==1.25.1
packaging==23.1
pandas==2.0.3
pluggy==1.2.0
protobuf==4.23.4
pyarrow==12.0.1
pytest==7.4.0
python-dateutil==2.8.2
pytz==2023.3
six==1.16.0
structlog==23.1.0
tomli==2.0.1
tzdata==2023.3
.
19 changes: 18 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,26 @@

dependencies = [
"cloudquery-plugin-pb==0.0.14",
"pyarrow==12.0.1",
"exceptiongroup==1.1.2",
"black==23.7.0",
"grpcio==1.56.2",
"grpcio-tools==1.56.2",
"iniconfig==2.0.0",
"Jinja2==3.1.2",
"MarkupSafe==2.1.3",
"numpy==1.25.1",
"packaging==23.1",
"pandas==2.0.3",
"pluggy==1.2.0",
"protobuf==4.23.4",
"pyarrow==12.0.1",
"pytest==7.4.0",
"python-dateutil==2.8.2",
"pytz==2023.3",
"six==1.16.0",
"structlog==23.1.0",
"tomli==2.0.1",
"tzdata==2023.3",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved all the requirements into setup.py, and changed requirements.txt to ., so that they are the same. We can change this again later, but this should ensure that the package and dev requirements are the same for now. Only thing is that we probably don't need black here

]
url = "https://github.com/cloudquery/plugin-sdk-python"

Expand Down
Empty file added tests/types/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions tests/types/json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from cloudquery.sdk.types import JSONType


def test_json_type():
j = JSONType()
# test equality
assert j == JSONType()