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

🎉 New source: Native Hubspot connector #2215

Merged
merged 44 commits into from
Mar 20, 2021
Merged

Conversation

eugene-kulak
Copy link
Contributor

@eugene-kulak eugene-kulak commented Feb 25, 2021

What

closes #2195
closes #2215

How

Describe the solution

Pre-merge Checklist

  • Run integration tests
  • Publish Docker images

Recommended reading order

  1. test.java
  2. component.ts
  3. the rest

TODOs:

  • Use interval
  • check if pagination is possible on contacts by company stream

@eugene-kulak eugene-kulak changed the base branch from master to ykurochkin/hubspot-create-native-connector-with-schema-folder-populated February 25, 2021 20:20
@eugene-kulak eugene-kulak linked an issue Feb 25, 2021 that may be closed by this pull request
3 tasks
@eugene-kulak eugene-kulak self-assigned this Feb 25, 2021
@eugene-kulak
Copy link
Contributor Author

eugene-kulak commented Feb 26, 2021

/test connector=source-hubspot

🕑 source-hubspot https://github.com/airbytehq/airbyte/actions/runs/602034821
❌ source-hubspot https://github.com/airbytehq/airbyte/actions/runs/602034821

@eugene-kulak
Copy link
Contributor Author

eugene-kulak commented Feb 26, 2021

/test connector=source-hubspot

🕑 source-hubspot https://github.com/airbytehq/airbyte/actions/runs/602065374
❌ source-hubspot https://github.com/airbytehq/airbyte/actions/runs/602065374

Copy link
Contributor

@sherifnada sherifnada left a comment

Choose a reason for hiding this comment

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

Looks good so far, I really like the breakdown of classes between API, StreamAPI, and CRMObjects 🚀

@@ -78,8 +78,13 @@
dockerRepository: airbyte/source-facebook-marketing
dockerImageTag: 0.1.3
documentationUrl: https://hub.docker.com/r/airbyte/source-facebook-marketing
- sourceDefinitionId: 57eb1576-8f52-463d-beb6-2e107cdf571d
- sourceDefinitionId: 36c891d9-4bd9-43ac-bad2-10e12756272c
Copy link
Contributor

Choose a reason for hiding this comment

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

We should only make the new version available once incremental is complete. We can then also completely remove the old hubspot connector (rather than rename it).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

my intention was to add a completely new connector, then release it and drop the one that based on singer. But maybe accidentally renamed the old instead, not sure, need to check

Copy link
Contributor

Choose a reason for hiding this comment

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

Important thing is not to have 2 hubspot connectors in Airbyte at the same time. the user only cares about syncing data from hubspot, Singer vs. native is an implementation detail

Copy link
Contributor

Choose a reason for hiding this comment

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

clear, I have removed the old connector

return {}

props = {}
data = self._api.get(f"/properties/v2/{self.entity}/properties")
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add context on what this is doing as a comment?

I've looked at the API docs for a bit and it's not obvious to me what this is doing. it seems like it's adding the type of the property based on dynamically getting it from the Hubspot API? is this related to this ticket? why wouldn't we know the type of the property ahead of time?

This is bringing me to a different point: can you clarify as a docstring at the top of this class what the different APIs we are using are, and point to the API docs? This will enable me as the reader to know exactly which API docs to look at (Hubspot has multiple)

Copy link
Contributor Author

@eugene-kulak eugene-kulak Feb 27, 2021

Choose a reason for hiding this comment

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

most objects in Hubspot have attributes located in the properties field, there are two types:

  • default (built-in, depends on the version of API)
  • custom (user-defined)

because the exact list and types are dynamic we retrieve them at runtime. Technically we don't need to know type of attribute here, but for building a schema object we will need it (#2219 )

good idea about adding docs, will polish the PR soon

entity = None

more_key = None
data_path = "results"
Copy link
Contributor

Choose a reason for hiding this comment

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

data_path is a bit misleading as a name since it's a single key, not a path in the JSON. Can we use something like data_field?

page_filter = "offset"
page_field = "offset"

chunk_size = 1000 * 60 * 60 * 24 # TODO: use interval
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm adding all TODOs to a checklist in the PR description so we don't miss these before merging

params = {
"archived": str(self._include_archived_only).lower(),
}
for record in self.read(partial(self._api.get, url=self.url), params):
Copy link
Contributor

Choose a reason for hiding this comment

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

yield from?

if response.get(self.data_path) is None:
raise RuntimeError("Unexpected API response: {} not in {}".format(self.data_path, response.keys()))

for row in response[self.data_path]:
Copy link
Contributor

Choose a reason for hiding this comment

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

yield from?

url = "/crm/v3/objects/quotes"


class TicketsAPI(CRMObjectsAPI):
Copy link
Contributor

Choose a reason for hiding this comment

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

why does every class have API in the name? Shouldn't it just be the API class and then everything else is a stream?


def _contacts_by_company(self, company_id):
url = "/companies/v2/companies/{pk}/vids".format(pk=company_id)
# FIXME: check if pagination is possible
Copy link
Contributor

Choose a reason for hiding this comment

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

added to todo list

* Campaigns
* Companies
* Contact Lists
* Contacts
Copy link
Contributor

Choose a reason for hiding this comment

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

can you link to these in the docs? You don't have to link to each one individually, you can just link to one page at the top containing all of themnm

if data.get(path) is None:
raise RuntimeError("Unexpected API response: {} not in {}".format(path, data.keys()))

for row in data[path]:
Copy link
Contributor

Choose a reason for hiding this comment

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

is the point of this stream to be a join table between contacts and companies? can't we put this information in the contacts stream as a field?

@keu
Copy link
Contributor

keu commented Mar 12, 2021

/test connector=source-hubspot

🕑 source-hubspot https://github.com/airbytehq/airbyte/actions/runs/647324504
❌ source-hubspot https://github.com/airbytehq/airbyte/actions/runs/647324504

]

TEST_REQUIREMENTS = [
"airbyte-python-test",
Copy link
Contributor

Choose a reason for hiding this comment

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

airbyte-python-test is not needed

@@ -34,5 +50,5 @@ The connector is restricted by normal Hubspot [rate limitations](https://legacyd

* For api key auth, in Hubspot, for the account to go settings -> integrations \(under the account banner\) -> api key. If you already have an api key you can use that. Otherwise generated a new one.
Copy link
Contributor

Choose a reason for hiding this comment

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

As far as I can tell, this connector/airbyte would need to implement oauth for a client to be able to obtain oauth credentials. Since we don't do this yet, can you remove the oauth section from the docs and create an issue to support it once we have oauth? blocked on this issue: #768

Copy link
Contributor

Choose a reason for hiding this comment

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

ok #2449

eugene-kulak and others added 2 commits March 13, 2021 00:45
* add incremental

* add incremental

* polishing

* update docs

* fix docstring

* clean up

* fix incremental bookmark access

* fix incremental tests

* clean up

* add custom test for incremental, improve logging

* format

* Update airbyte-integrations/connectors/source-hubspot/source_hubspot/api.py

Co-authored-by: Eugene Kulak <kulak.eugene@gmail.com>
Co-authored-by: Sherif A. Nada <snadalive@gmail.com>
@keu keu linked an issue Mar 19, 2021 that may be closed by this pull request
@keu keu changed the title Source Hubspot: native client should support all streams in full sync mode Source Hubspot: native client Mar 19, 2021
* fix error reporting and add unit tests

* fix test and refactor cursor fields

* format

Co-authored-by: Eugene Kulak <kulak.eugene@gmail.com>
@keu
Copy link
Contributor

keu commented Mar 19, 2021

/test connector=source-hubspot

🕑 source-hubspot https://github.com/airbytehq/airbyte/actions/runs/669319473
❌ source-hubspot https://github.com/airbytehq/airbyte/actions/runs/669319473

@keu keu changed the title Source Hubspot: native client 🎉 New source: Native Hubspot connector Mar 19, 2021
@keu keu changed the title 🎉 New source: Native Hubspot connector 🎉 New source: Native Hubspot connector Mar 19, 2021
@keu keu changed the base branch from ykurochkin/hubspot-create-native-connector-with-schema-folder-populated to master March 19, 2021 22:26
@keu
Copy link
Contributor

keu commented Mar 19, 2021

/test connector=source-hubspot

🕑 source-hubspot https://github.com/airbytehq/airbyte/actions/runs/669438507
❌ source-hubspot https://github.com/airbytehq/airbyte/actions/runs/669438507

@keu
Copy link
Contributor

keu commented Mar 20, 2021

/test connector=source-hubspot

🕑 source-hubspot https://github.com/airbytehq/airbyte/actions/runs/670098223
✅ source-hubspot https://github.com/airbytehq/airbyte/actions/runs/670098223

@keu
Copy link
Contributor

keu commented Mar 20, 2021

/publish connector=source-hubspot

❌ source-hubspot https://github.com/airbytehq/airbyte/actions/runs/670128390

@keu
Copy link
Contributor

keu commented Mar 20, 2021

/publish connector=connectors/source-hubspot

🕑 connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/670129400
✅ connectors/source-hubspot https://github.com/airbytehq/airbyte/actions/runs/670129400

@keu keu merged commit 0b9b038 into master Mar 20, 2021
@keu keu deleted the keu/source-hubspot-native branch March 20, 2021 09:18
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.

Source Hubspot: native client should support all streams in full sync mode Airbyte Native Hubspot connector
4 participants