ingestr 0.13.28__py3-none-any.whl → 0.13.29__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ingestr might be problematic. Click here for more details.

ingestr/main.py CHANGED
@@ -302,6 +302,13 @@ def ingest(
302
302
  envvar=["COLUMNS", "INGESTR_COLUMNS"],
303
303
  ),
304
304
  ] = None, # type: ignore
305
+ yield_limit: Annotated[
306
+ Optional[int],
307
+ typer.Option(
308
+ help="Limit the number of pages yielded from the source",
309
+ envvar=["YIELD_LIMIT", "INGESTR_YIELD_LIMIT"],
310
+ ),
311
+ ] = None, # type: ignore
305
312
  ):
306
313
  import hashlib
307
314
  import tempfile
@@ -556,6 +563,9 @@ def ingest(
556
563
  if factory.source_scheme.startswith("mysql"):
557
564
  resource.for_each(dlt_source, lambda x: x.add_map(handle_mysql_empty_dates))
558
565
 
566
+ if yield_limit:
567
+ resource.for_each(dlt_source, lambda x: x.add_limit(yield_limit))
568
+
559
569
  def col_h(x):
560
570
  if column_hints:
561
571
  x.apply_hints(columns=column_hints)
ingestr/src/buildinfo.py CHANGED
@@ -1 +1 @@
1
- version = "v0.13.28"
1
+ version = "v0.13.29"
@@ -169,7 +169,7 @@ def hubspot(
169
169
  api_key: str = api_key,
170
170
  ) -> Iterator[TDataItems]:
171
171
  """Hubspot schemas resource"""
172
- yield from fetch_data(CRM_SCHEMAS_ENDPOINT, api_key,resource_name="schemas")
172
+ yield from fetch_data(CRM_SCHEMAS_ENDPOINT, api_key, resource_name="schemas")
173
173
 
174
174
  @dlt.resource(name="quotes", write_disposition="replace")
175
175
  def quotes(
@@ -192,8 +192,7 @@ def hubspot(
192
192
  api_key: str = api_key,
193
193
  custom_object_name: str = custom_object,
194
194
  ) -> Iterator[TDataItems]:
195
-
196
- get_custom_object = schemas(api_key)
195
+ get_custom_object = schemas(api_key)
197
196
  object_type_id = None
198
197
  for custom_object in get_custom_object:
199
198
  if custom_object["name"] == custom_object_name.capitalize():
@@ -201,18 +200,18 @@ def hubspot(
201
200
  break
202
201
  if object_type_id is None:
203
202
  raise ValueError(f"There is no such custom object as {custom_object_name}")
204
- custom_object_properties= f"crm/v3/properties/{object_type_id}"
205
-
203
+ custom_object_properties = f"crm/v3/properties/{object_type_id}"
204
+
206
205
  props_pages = fetch_data(custom_object_properties, api_key)
207
206
  props = []
208
207
  for page in props_pages:
209
208
  props.extend([prop["name"] for prop in page])
210
209
  props = ",".join(sorted(list(set(props))))
211
-
212
- custom_object_endpoint= f"crm/v3/objects/{object_type_id}/?properties={props}"
213
-
210
+
211
+ custom_object_endpoint = f"crm/v3/objects/{object_type_id}/?properties={props}"
212
+
214
213
  """Hubspot custom object details resource"""
215
- yield from fetch_data(custom_object_endpoint, api_key,resource_name="custom")
214
+ yield from fetch_data(custom_object_endpoint, api_key, resource_name="custom")
216
215
 
217
216
  return companies, contacts, deals, tickets, products, quotes, schemas, custom
218
217
 
@@ -90,7 +90,10 @@ def fetch_property_history(
90
90
 
91
91
 
92
92
  def fetch_data(
93
- endpoint: str, api_key: str, params: Optional[Dict[str, Any]] = None,resource_name: str = None
93
+ endpoint: str,
94
+ api_key: str,
95
+ params: Optional[Dict[str, Any]] = None,
96
+ resource_name: str = None,
94
97
  ) -> Iterator[List[Dict[str, Any]]]:
95
98
  """
96
99
  Fetch data from HUBSPOT endpoint using a specified API key and yield the properties of each result.
@@ -133,15 +136,17 @@ def fetch_data(
133
136
  _objects: List[Dict[str, Any]] = []
134
137
  for _result in _data["results"]:
135
138
  if resource_name == "schemas":
136
- _objects.append({
137
- "name": _result["labels"].get("singular", ""),
138
- "objectTypeId": _result.get("objectTypeId", ""),
139
- "id": _result.get("id", ""),
140
- "fullyQualifiedName": _result.get("fullyQualifiedName", ""),
141
- "properties": _result.get("properties", ""),
142
- "createdAt": _result.get("createdAt", ""),
143
- "updatedAt": _result.get("updatedAt", "")
144
- })
139
+ _objects.append(
140
+ {
141
+ "name": _result["labels"].get("singular", ""),
142
+ "objectTypeId": _result.get("objectTypeId", ""),
143
+ "id": _result.get("id", ""),
144
+ "fullyQualifiedName": _result.get("fullyQualifiedName", ""),
145
+ "properties": _result.get("properties", ""),
146
+ "createdAt": _result.get("createdAt", ""),
147
+ "updatedAt": _result.get("updatedAt", ""),
148
+ }
149
+ )
145
150
  elif resource_name == "custom":
146
151
  _objects.append(
147
152
  _result.get("properties", ""),
@@ -157,9 +162,11 @@ def fetch_data(
157
162
  {
158
163
  "value": _obj["hs_object_id"],
159
164
  f"{association}_id": __r["id"],
160
- }
161
- for __r in _result["associations"][association]["results"]
162
- ]
165
+ }
166
+ for __r in _result["associations"][association][
167
+ "results"
168
+ ]
169
+ ]
163
170
 
164
171
  # remove duplicates from list of dicts
165
172
  __values = [
@@ -5,15 +5,21 @@ from dlt.common import pendulum
5
5
  STARTDATE = pendulum.datetime(year=2000, month=1, day=1)
6
6
 
7
7
  CRM_CONTACTS_ENDPOINT = (
8
- "/crm/v3/objects/contacts?associations=deals,products,tickets,quotes"
8
+ "/crm/v3/objects/contacts?associations=companies,deals,products,tickets,quotes"
9
9
  )
10
- CRM_COMPANIES_ENDPOINT = (
11
- "/crm/v3/objects/companies?associations=contacts,deals,products,tickets,quotes"
10
+ CRM_COMPANIES_ENDPOINT = "/crm/v3/objects/companies?associations=products"
11
+ CRM_DEALS_ENDPOINT = (
12
+ "/crm/v3/objects/deals?associations=companies,contacts,products,tickets,quotes"
13
+ )
14
+ CRM_PRODUCTS_ENDPOINT = (
15
+ "/crm/v3/objects/products?associations=companies,contacts,deals,tickets,quotes"
16
+ )
17
+ CRM_TICKETS_ENDPOINT = (
18
+ "/crm/v3/objects/tickets?associations=companies,contacts,deals,products,quotes"
19
+ )
20
+ CRM_QUOTES_ENDPOINT = (
21
+ "/crm/v3/objects/quotes?associations=companies,contacts,deals,products,tickets"
12
22
  )
13
- CRM_DEALS_ENDPOINT = "/crm/v3/objects/deals"
14
- CRM_PRODUCTS_ENDPOINT = "/crm/v3/objects/products"
15
- CRM_TICKETS_ENDPOINT = "/crm/v3/objects/tickets"
16
- CRM_QUOTES_ENDPOINT = "/crm/v3/objects/quotes"
17
23
  CRM_SCHEMAS_ENDPOINT = "/crm/v3/schemas"
18
24
 
19
25
  CRM_OBJECT_ENDPOINTS = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ingestr
3
- Version: 0.13.28
3
+ Version: 0.13.29
4
4
  Summary: ingestr is a command-line application that ingests data from various sources and stores them in any database.
5
5
  Project-URL: Homepage, https://github.com/bruin-data/ingestr
6
6
  Project-URL: Issues, https://github.com/bruin-data/ingestr/issues
@@ -1,8 +1,8 @@
1
1
  ingestr/conftest.py,sha256=Q03FIJIZpLBbpj55cfCHIKEjc1FCvWJhMF2cidUJKQU,1748
2
- ingestr/main.py,sha256=wvbRCJ2--M0Zw2cYtSH874TxTtlD0wadHREeLG3anOY,25618
2
+ ingestr/main.py,sha256=Vt5NFN59BUlkYrOwiF9xF5MCFYp9r-aVSnQ99f1ypRE,25964
3
3
  ingestr/src/.gitignore,sha256=8cX1AZTSI0TcdZFGTmS_oyBjpfCzhOEt0DdAo2dFIY8,203
4
4
  ingestr/src/blob.py,sha256=onMe5ZHxPXTdcB_s2oGNdMo-XQJ3ajwOsWE9eSTGFmc,1495
5
- ingestr/src/buildinfo.py,sha256=oC8nu6AzLZ_pxgRfz88wvC4OwlhMFeJZSkZgNXnuiSA,21
5
+ ingestr/src/buildinfo.py,sha256=fraAO4VHAeBDwo-MJW7EhZKMHMio-7qqLE2lULqrTHA,21
6
6
  ingestr/src/destinations.py,sha256=vrGij4qMPCdXTMIimROWBJFqzOqCM4DFmgyubgSHejA,11279
7
7
  ingestr/src/errors.py,sha256=Ufs4_DfE77_E3vnA1fOQdi6cmuLVNm7_SbFLkL1XPGk,686
8
8
  ingestr/src/factory.py,sha256=659h_sVRBhtPv2dvtOK8tf3PtUhlK3KsWLrb20_iQKw,5333
@@ -61,9 +61,9 @@ ingestr/src/google_sheets/helpers/api_calls.py,sha256=RiVfdacbaneszhmuhYilkJnkc9
61
61
  ingestr/src/google_sheets/helpers/data_processing.py,sha256=RNt2MYfdJhk4bRahnQVezpNg2x9z0vx60YFq2ukZ8vI,11004
62
62
  ingestr/src/gorgias/__init__.py,sha256=_mFkMYwlY5OKEY0o_FK1OKol03A-8uk7bm1cKlmt5cs,21432
63
63
  ingestr/src/gorgias/helpers.py,sha256=DamuijnvhGY9hysQO4txrVMf4izkGbh5qfBKImdOINE,5427
64
- ingestr/src/hubspot/__init__.py,sha256=seijVlwBXE3-5SRtLjfJwbk1ZvckUj0IYBL0w69k464,10983
65
- ingestr/src/hubspot/helpers.py,sha256=jwWQy0AjVaMq4B033dAiQh2oehhYdFWLkynA43QsQzM,7573
66
- ingestr/src/hubspot/settings.py,sha256=hXnIhE4_FlhtgUiCjMLGGZJ_lBlBQJ0YWi6lHJ6Q3WU,2234
64
+ ingestr/src/hubspot/__init__.py,sha256=rSYmN8h6qqxhWCW6elD-pC7iqHXlIofb1F9wvTzziUE,10962
65
+ ingestr/src/hubspot/helpers.py,sha256=fscilfO_K7HS2XQxzf7MeZwVXLTP0WdqnV-NhdeqQAA,7748
66
+ ingestr/src/hubspot/settings.py,sha256=i73MkSiJfRLMFLfiJgYdhp-rhymHTfoqFzZ4uOJdFJM,2456
67
67
  ingestr/src/kafka/__init__.py,sha256=wMCXdiraeKd1Kssi9WcVCGZaNGm2tJEtnNyuB4aR5_k,3541
68
68
  ingestr/src/kafka/helpers.py,sha256=V9WcVn3PKnEpggArHda4vnAcaV8VDuh__dSmRviJb5Y,7502
69
69
  ingestr/src/kinesis/__init__.py,sha256=u5ThH1y8uObZKXgIo71em1UnX6MsVHWOjcf1jKqKbE8,6205
@@ -121,8 +121,8 @@ ingestr/testdata/delete_insert_part2.csv,sha256=B_KUzpzbNdDY_n7wWop1mT2cz36TmayS
121
121
  ingestr/testdata/merge_expected.csv,sha256=DReHqWGnQMsf2PBv_Q2pfjsgvikYFnf1zYcQZ7ZqYN0,276
122
122
  ingestr/testdata/merge_part1.csv,sha256=Pw8Z9IDKcNU0qQHx1z6BUf4rF_-SxKGFOvymCt4OY9I,185
123
123
  ingestr/testdata/merge_part2.csv,sha256=T_GiWxA81SN63_tMOIuemcvboEFeAmbKc7xRXvL9esw,287
124
- ingestr-0.13.28.dist-info/METADATA,sha256=-jYfvk0dlu8EvEDi2df5163aCHLX-JTkru0dmQroa0M,13659
125
- ingestr-0.13.28.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
126
- ingestr-0.13.28.dist-info/entry_points.txt,sha256=oPJy0KBnPWYjDtP1k8qwAihcTLHSZokSQvRAw_wtfJM,46
127
- ingestr-0.13.28.dist-info/licenses/LICENSE.md,sha256=cW8wIhn8HFE-KLStDF9jHQ1O_ARWP3kTpk_-eOccL24,1075
128
- ingestr-0.13.28.dist-info/RECORD,,
124
+ ingestr-0.13.29.dist-info/METADATA,sha256=bHCOtgvVHv64YRJ9hylunKHeARE2caXv7SuBfD9x1fc,13659
125
+ ingestr-0.13.29.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
126
+ ingestr-0.13.29.dist-info/entry_points.txt,sha256=oPJy0KBnPWYjDtP1k8qwAihcTLHSZokSQvRAw_wtfJM,46
127
+ ingestr-0.13.29.dist-info/licenses/LICENSE.md,sha256=cW8wIhn8HFE-KLStDF9jHQ1O_ARWP3kTpk_-eOccL24,1075
128
+ ingestr-0.13.29.dist-info/RECORD,,