Skip to content

Commit cbdb897

Browse files
Source Hubspot: revert v0.1.78 (#15144)
* Revert "Source Hubspot: implement new stream to read associations in incremental mode (#15099)" This reverts commit dd109de. * #359 rollback * hubspot: upd changelog * auto-bump connector version [ci skip] Co-authored-by: Octavia Squidington III <[email protected]>
1 parent 9b0ed96 commit cbdb897

File tree

9 files changed

+11
-146
lines changed

9 files changed

+11
-146
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@
414414
- name: HubSpot
415415
sourceDefinitionId: 36c891d9-4bd9-43ac-bad2-10e12756272c
416416
dockerRepository: airbyte/source-hubspot
417-
dockerImageTag: 0.1.78
417+
dockerImageTag: 0.1.79
418418
documentationUrl: https://docs.airbyte.io/integrations/sources/hubspot
419419
icon: hubspot.svg
420420
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3705,7 +3705,7 @@
37053705
supportsNormalization: false
37063706
supportsDBT: false
37073707
supported_destination_sync_modes: []
3708-
- dockerImage: "airbyte/source-hubspot:0.1.78"
3708+
- dockerImage: "airbyte/source-hubspot:0.1.79"
37093709
spec:
37103710
documentationUrl: "https://docs.airbyte.io/integrations/sources/hubspot"
37113711
connectionSpecification:

airbyte-integrations/connectors/source-hubspot/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ COPY source_hubspot ./source_hubspot
3434
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
3535
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
3636

37-
LABEL io.airbyte.version=0.1.78
37+
LABEL io.airbyte.version=0.1.79
3838
LABEL io.airbyte.name=airbyte/source-hubspot

airbyte-integrations/connectors/source-hubspot/integration_tests/conftest.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

airbyte-integrations/connectors/source-hubspot/integration_tests/test_associations.py

Lines changed: 0 additions & 55 deletions
This file was deleted.

airbyte-integrations/connectors/source-hubspot/source_hubspot/source.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def get_api(config: Mapping[str, Any]) -> API:
8282
return API(credentials=credentials)
8383

8484
def get_common_params(self, config) -> Mapping[str, Any]:
85-
start_date = config["start_date"]
85+
start_date = config.get("start_date")
8686
credentials = config["credentials"]
8787
api = self.get_api(config=config)
8888
common_params = dict(api=api, start_date=start_date, credentials=credentials)

airbyte-integrations/connectors/source-hubspot/source_hubspot/streams.py

Lines changed: 5 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -245,15 +245,12 @@ def _property_wrapper(self) -> IURLPropertyRepresentation:
245245
return APIv1Property(properties)
246246
return APIv3Property(properties)
247247

248-
def __init__(self, api: API, start_date: Union[str, pendulum.datetime], credentials: Mapping[str, Any] = None, **kwargs):
248+
def __init__(self, api: API, start_date: str = None, credentials: Mapping[str, Any] = None, **kwargs):
249249
super().__init__(**kwargs)
250250
self._api: API = api
251-
self._credentials = credentials
251+
self._start_date = pendulum.parse(start_date)
252252

253-
self._start_date = start_date
254-
if isinstance(self._start_date, str):
255-
self._start_date = pendulum.parse(self._start_date)
256-
if self._credentials["credentials_title"] == API_KEY_CREDENTIALS:
253+
if credentials["credentials_title"] == API_KEY_CREDENTIALS:
257254
self._session.params["hapikey"] = credentials.get("api_key")
258255

259256
def backoff_time(self, response: requests.Response) -> Optional[float]:
@@ -645,51 +642,6 @@ def _flat_associations(self, records: Iterable[MutableMapping]) -> Iterable[Muta
645642
yield record
646643

647644

648-
class AssociationsStream(Stream):
649-
"""
650-
Designed to read associations of CRM objects during incremental syncs, since Search API does not support
651-
retrieving associations.
652-
"""
653-
654-
http_method = "POST"
655-
filter_old_records = False
656-
657-
def __init__(self, parent_stream: Stream, identifiers: Iterable[Union[int, str]], *args, **kwargs):
658-
super().__init__(*args, **kwargs)
659-
self.parent_stream = parent_stream
660-
self.identifiers = identifiers
661-
662-
@property
663-
def url(self):
664-
"""
665-
although it is not used, it needs to be implemented because it is an abstract property
666-
"""
667-
return ""
668-
669-
def path(
670-
self,
671-
*,
672-
stream_state: Mapping[str, Any] = None,
673-
stream_slice: Mapping[str, Any] = None,
674-
next_page_token: Mapping[str, Any] = None,
675-
) -> str:
676-
return f"/crm/v4/associations/{self.parent_stream.entity}/{stream_slice}/batch/read"
677-
678-
def scopes(self) -> Set[str]:
679-
return self.parent_stream.scopes
680-
681-
def stream_slices(self, sync_mode: SyncMode, cursor_field: List[str] = None, stream_state: Mapping[str, Any] = None) -> Iterable[str]:
682-
return self.parent_stream.associations
683-
684-
def request_body_json(
685-
self,
686-
stream_state: Mapping[str, Any],
687-
stream_slice: Mapping[str, Any] = None,
688-
next_page_token: Mapping[str, Any] = None,
689-
) -> Optional[Mapping]:
690-
return {"inputs": [{"id": str(id_)} for id_ in self.identifiers]}
691-
692-
693645
class IncrementalStream(Stream, ABC):
694646
"""Stream that supports state and incremental read"""
695647

@@ -855,24 +807,6 @@ def _process_search(
855807

856808
return list(stream_records.values()), raw_response
857809

858-
def _read_associations(self, records: Iterable) -> Iterable[Mapping[str, Any]]:
859-
records_by_pk = {record[self.primary_key]: record for record in records}
860-
identifiers = list(map(lambda x: x[self.primary_key], records))
861-
associations_stream = AssociationsStream(
862-
api=self._api, start_date=self._start_date, credentials=self._credentials, parent_stream=self, identifiers=identifiers
863-
)
864-
slices = associations_stream.stream_slices(sync_mode=SyncMode.full_refresh)
865-
866-
for _slice in slices:
867-
logger.debug(f"Reading {_slice} associations of {self.entity}")
868-
associations = associations_stream.read_records(stream_slice=_slice, sync_mode=SyncMode.full_refresh)
869-
for group in associations:
870-
current_record = records_by_pk[group["from"]["id"]]
871-
associations_list = current_record.get(_slice, [])
872-
associations_list.extend(association["toObjectId"] for association in group["to"])
873-
current_record[_slice] = associations_list
874-
return records_by_pk.values()
875-
876810
def read_records(
877811
self,
878812
sync_mode: SyncMode,
@@ -892,15 +826,15 @@ def read_records(
892826
stream_state=stream_state,
893827
stream_slice=stream_slice,
894828
)
895-
records = self._read_associations(records)
829+
896830
else:
897831
records, raw_response = self._read_stream_records(
898832
stream_slice=stream_slice,
899833
stream_state=stream_state,
900834
next_page_token=next_page_token,
901835
)
902-
records = self._flat_associations(records)
903836
records = self._filter_old_records(records)
837+
records = self._flat_associations(records)
904838

905839
for record in records:
906840
cursor = self._field_to_datetime(record[self.updated_at_field])

airbyte-integrations/connectors/source-hubspot/unit_tests/test_source.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_check_connection_empty_config(config):
5050
def test_check_connection_invalid_config(config):
5151
config.pop("start_date")
5252

53-
with pytest.raises(KeyError):
53+
with pytest.raises(TypeError):
5454
SourceHubspot().check_connection(logger, config=config)
5555

5656

@@ -406,8 +406,6 @@ def test_search_based_stream_should_not_attempt_to_get_more_than_10k_records(req
406406
requests_mock.register_uri("POST", test_stream.url, responses)
407407
test_stream._sync_mode = None
408408
requests_mock.register_uri("GET", "/properties/v2/company/properties", properties_response)
409-
requests_mock.register_uri("POST", "/crm/v4/associations/company/contacts/batch/read", [{"status_code": 200, "json": {"results": []}}])
410-
411409
records, _ = read_incremental(test_stream, {})
412410
# The stream should not attempt to get more than 10K records.
413411
# Instead, it should use the new state to start a new search query.

docs/integrations/sources/hubspot.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ Now that you have set up the HubSpot source connector, check out the following H
129129

130130
| Version | Date | Pull Request | Subject |
131131
|:--------|:-----------|:---------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------|
132+
| 0.1.79 | 2022-07-28 | [15144](https://github.com/airbytehq/airbyte/pull/15144) | Revert v0.1.78 due to permission issues |
132133
| 0.1.78 | 2022-07-28 | [15099](https://github.com/airbytehq/airbyte/pull/15099) | Fix to fetch associations when using incremental mode |
133134
| 0.1.77 | 2022-07-26 | [15035](https://github.com/airbytehq/airbyte/pull/15035) | Make PropertyHistory stream read historic data not limited to 30 days |
134135
| 0.1.76 | 2022-07-25 | [14999](https://github.com/airbytehq/airbyte/pull/14999) | Partially revert changes made in v0.1.75 |

0 commit comments

Comments
 (0)