Skip to content
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-26228 New Stream addition #95

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Conversation

somethingmorerelevant
Copy link
Member

Description of change

  • Adds Support for the following streams

    • Describe Leads (Provides Metadata about the lead's fields)

      • Type: Full Table
      • Primary Keys: id
    • Program Tags (Provides tags associated with a program)

      • Type: Full Table
      • Primary Keys: None
      • Parent Child Hierarchy with program's stream
      • Implements activate version messages.
    • Tag Types (Provides Master table for tags)

      • Type: Full Table
      • Primary Keys: None
      • Implements activate version messages.

Manual QA steps

  • Execute Sync and Discovery mode locally.

Risks

  • Low (Since the changes have been tested through PR Alpha)

Rollback steps

  • revert this branch

@somethingmorerelevant somethingmorerelevant marked this pull request as ready for review July 22, 2024 08:17
CHANGELOG.md Outdated
@@ -1,5 +1,8 @@
# Changelog

## 2.6.2

Choose a reason for hiding this comment

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

It should be minor version.

tap_marketo/sync.py Outdated Show resolved Hide resolved
Comment on lines +466 to +471
if stream_version is None:
stream_version = int(time.time() * 1000)
singer.log_info("Using new activate version %s", stream_version)
else:
singer.log_info("Using interupted activate version %s", stream_version)
return stream_version

Choose a reason for hiding this comment

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

Suggested change
if stream_version is None:
stream_version = int(time.time() * 1000)
singer.log_info("Using new activate version %s", stream_version)
else:
singer.log_info("Using interupted activate version %s", stream_version)
return stream_version
if stream_version:
singer.log_info("Using interupted activate version %s", stream_version)
else:
stream_version = int(time.time() * 1000)
singer.log_info("Using new activate version %s", stream_version)
return stream_version

Copy link
Member Author

Choose a reason for hiding this comment

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

since this condition is simplified and the changes are tested and validated, changing the sequence of the condition will not have any significant impact.
i would suggest against this change, unless this implementation is causing any adverse impact.

data = client.request("GET", endpoint, endpoint_name="programs", params=params)
if "warnings" in data and NO_ASSET_MSG in data["warnings"]:
break
if "errors" in data and data["errors"] != []:

Choose a reason for hiding this comment

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

Any specific reason, we are checking data["errors"] != []? Can we use simplified condition like below,

Suggested change
if "errors" in data and data["errors"] != []:
if "errors" in data and data["errors"]:

Comment on lines 487 to 488
if "warnings" in data and NO_ASSET_MSG in data["warnings"]:
break

Choose a reason for hiding this comment

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

Should we log these warnings as well like errors?

Choose a reason for hiding this comment

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

Same suggestion on L#581-L#582.

Copy link
Member Author

Choose a reason for hiding this comment

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

those are not actual warnings, it just means that we have reached the end of the list and there are no more objects to iterate.


def sync_program_tags(client, state, stream):
singer.write_schema(stream["tap_stream_id"], stream["schema"], stream["key_properties"])
first_run = check_if_first_sync(state, stream["tap_stream_id"])

Choose a reason for hiding this comment

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

To clearly convey that this is boolean variable, we should use name like is_first_run or is_initail_sync.

Copy link

@RushiT0122 RushiT0122 Jul 29, 2024

Choose a reason for hiding this comment

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

Same suggestion on L#560.

Comment on lines 522 to 526
if last_synced_program:
for indx, prog in enumerate(program_ids):
if prog == last_synced_program:
start = indx
singer.log_info("Last Sync was interupted at index: %s program: %s",indx, prog)

Choose a reason for hiding this comment

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

Suggested change
if last_synced_program:
for indx, prog in enumerate(program_ids):
if prog == last_synced_program:
start = indx
singer.log_info("Last Sync was interupted at index: %s program: %s",indx, prog)
if last_synced_program_id:
for index, program_id in enumerate(program_ids):
if program_id == last_synced_program_id:
start = index
singer.log_info("Last Sync was interupted at index: %s program: %s", index, program_id)

Copy link

@RushiT0122 RushiT0122 left a comment

Choose a reason for hiding this comment

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

Provided some suggestions in-line. In addtion to that please capitalise the new comments and docstrings added.

Comment on lines 211 to 214
if key_props:
mdata = metadata.write(mdata, (), 'table-key-properties', key_props)
else:
mdata = metadata.write(mdata, (), 'table-key-properties', [])
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if key_props:
mdata = metadata.write(mdata, (), 'table-key-properties', key_props)
else:
mdata = metadata.write(mdata, (), 'table-key-properties', [])
if not key_props:
key_props = []
mdata = metadata.write(mdata, (), 'table-key-properties', key_props)

Comment on lines 485 to 488
while True:
data = client.request("GET", endpoint, endpoint_name="programs", params=params)
if "warnings" in data and NO_ASSET_MSG in data["warnings"]:
break
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid using while True with a break, instead create a has_more_data flag and iterate using that.

Comment on lines 459 to 463
"""
checks if the sync was interupted in-between an extraction
if interupted returns the previous activate version number used
else returns a new activate version
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

This docstring appears to be wrong

Comment on lines 511 to 515
state = bookmarks.write_bookmark(state, stream["tap_stream_id"],INITAL_SYNC_KEY, True)
singer.write_state(state)

state = bookmarks.write_bookmark(state, stream["tap_stream_id"], ACTIVATE_VERSION_KEY, stream_version)
singer.write_state(state)
Copy link
Contributor

Choose a reason for hiding this comment

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

We do not need to be writing state twice consecutively here

Copy link
Member Author

Choose a reason for hiding this comment

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

Not necessary, since both statements are consecutive.
However this block will be executed only once (i.e the first sync), hence i made the state to be explicitly written in the same block.

Comment on lines 579 to 582
while True:
data = client.request("GET", endpoint, params=params)
if "warnings" in data and NO_ASSET_MSG in data["warnings"]:
break
Copy link
Contributor

Choose a reason for hiding this comment

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

Again avoid using while True with a break

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants