-
Notifications
You must be signed in to change notification settings - Fork 25
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
TDL-19835: Adding new streams and discovery mode #38
base: master
Are you sure you want to change the base?
Conversation
tap_braintree/discover.py
Outdated
@@ -0,0 +1,67 @@ | |||
from asyncio.log import logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused import statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed unused imports
tap_braintree/discover.py
Outdated
def get_abs_path(path): | ||
return os.path.join(os.path.dirname(os.path.realpath(__file__)), path) | ||
|
||
def get_schemas(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add function doc string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added doc strings for all the fuctions.
|
||
return schemas, field_metadata | ||
|
||
def discover(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add function doc string for all the functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added doc strings for all the fuctions.
|
||
return schemas, field_metadata | ||
|
||
def discover(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Divide this file into two files schema.py
and discover.py
because you are doing full refactoring.
Reference: https://github.com/singer-io/tap-github/pull/168/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seperated discover.py's code into schema.py and discover.py
tap_braintree/schemas/customers.json
Outdated
} | ||
} | ||
}, | ||
"android_pay_cards": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like all the *_cards
related fields have the same kind of schema. Can you check it once, if those are the same then use schema reference for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added reference schema in require schemas
"items": { | ||
"type": [ | ||
"null", | ||
"objects" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be object
and not objects
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected field type value
"settlement_date": { | ||
"type": [ | ||
"null", | ||
"strings" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be string
and not strings
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected field type value
tap_braintree/streams.py
Outdated
@@ -0,0 +1,366 @@ | |||
from readline import replace_history_item |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused import statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed unused imports
tap_braintree/schemas/customers.json
Outdated
"array" | ||
], | ||
"items": { | ||
"$ref": "subscription.json#/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have separate stream for subscriptions? If not then we can move subscription.json into the shared folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated customer schema
tap_braintree/schemas/disputes.json
Outdated
} | ||
} | ||
}, | ||
"transaction": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see multiple occurrences of it, can we create a reference for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added schema reference in require's schema
"object" | ||
], | ||
"properties": { | ||
"address_details": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
address_details used multiple times, we can create a reference of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed this stream, so no need to create reference schema for this
tap_braintree/streams.py
Outdated
DEFAULT_TIMESTAMP = "1970-01-01T00:00:00Z" | ||
LOGGER = singer.get_logger() | ||
|
||
SDK_CALL = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating dict, pass this in the stream object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated streams.py as per your suggestions
tap_braintree/streams.py
Outdated
replication_keys = "updated_at" | ||
key_properties = ["id"] | ||
|
||
def sync_endpoint(self, gateway, config, schema, state, selected_streams, sync_streams): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like all the classes have only 3 kinds of sync_endpoint() function. Create 3 parent classes with specific sync_endpoint() as per functionality and extend those from all the classes. Also, move common attribute variables to those parent classes.
Also move sync_without_window
, sync_with_window
and sync_full_table
method to specific classes with common name sync
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated streams.py and created 3 parent classes for sync.
setup.py
Outdated
@@ -10,7 +10,7 @@ | |||
classifiers=['Programming Language :: Python :: 3 :: Only'], | |||
py_modules=['tap_braintree'], | |||
install_requires=[ | |||
'singer-python==5.5.0', | |||
'singer-python==5.12.2', | |||
'requests==2.20.0', | |||
'braintree==3.53.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use the latest version of braintree i.e. 4.16.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated version of the Braintree
tap_braintree/discover.py
Outdated
|
||
def discover(): | ||
""" | ||
Generate catalog for call the streams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generate catalog for call the streams | |
Run the discovery mode, prepare the catalog file, and return the catalog. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated doc strings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update setup.py and include changes same as https://github.com/singer-io/tap-quickbooks/blob/master/setup.py#L31-L36
Also, please check the grammar for all the doc string.
|
||
# increment through each day (20k results max from api) | ||
for start, end in daterange(period_start, period_end): | ||
LOGGER.info("Starting discovery") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOGGER.info("Starting discovery") | |
LOGGER.info("Starting discover mode") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated logger messages
LOGGER.info("Starting discovery") | ||
catalog = discover() | ||
json.dump(catalog.to_dict(), sys.stdout, indent=2) | ||
LOGGER.info("Finished discover") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOGGER.info("Finished discover") | |
LOGGER.info("Finished discover mode") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated logger messages as per your suggestions
tap_braintree/schemas/plans.json
Outdated
"array" | ||
], | ||
"items": { | ||
"$ref": "add_on.json#/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"$ref": "add_on.json#/" | |
"$ref": "add_ons.json#/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated all schema with the correct name of the schema
tap_braintree/schemas/plans.json
Outdated
"array" | ||
], | ||
"items": { | ||
"$ref": "discount.json#/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"$ref": "discount.json#/" | |
"$ref": "discounts.json#/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated all schema with the correct name of the schema
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
References used in the streams schema are not resolved
"array" | ||
], | ||
"items": { | ||
"$ref": "add_on.json#/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"$ref": "add_on.json#/" | |
"$ref": "add_ons.json#/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated all schema with the correct name of the schema
@@ -0,0 +1,32 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update package_data
in setup.py and include a shared schema path in MANIFEST.in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added shared path in setup.py
tests/unittests/test_main.py
Outdated
if test_value[0]: | ||
call_count = mocked_discover.call_count | ||
else: | ||
call_count = mocked_sync.call_count |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use if-else in a test case to decide call_count. Create separate test cases in such scenarios. Use @parameterized.expand
for common scenarios only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seperated unit tests for sync mode and discover mode
"paypal_details": { | ||
"anyOf": [ | ||
{ | ||
"type": "object", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to remove many fields from the existing schema.
Description of change
Manual QA steps
Risks
Rollback steps