fivetran-connector-sdk 1.3.2__tar.gz → 1.3.3__tar.gz

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.
Files changed (18) hide show
  1. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/PKG-INFO +1 -1
  2. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk/__init__.py +39 -40
  3. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk.egg-info/PKG-INFO +1 -1
  4. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/README.md +0 -0
  5. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/pyproject.toml +0 -0
  6. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/setup.cfg +0 -0
  7. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk/protos/__init__.py +0 -0
  8. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk/protos/common_pb2.py +0 -0
  9. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk/protos/common_pb2.pyi +0 -0
  10. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk/protos/common_pb2_grpc.py +0 -0
  11. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk/protos/connector_sdk_pb2.py +0 -0
  12. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk/protos/connector_sdk_pb2.pyi +0 -0
  13. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk/protos/connector_sdk_pb2_grpc.py +0 -0
  14. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk.egg-info/SOURCES.txt +0 -0
  15. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk.egg-info/dependency_links.txt +0 -0
  16. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk.egg-info/entry_points.txt +0 -0
  17. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk.egg-info/requires.txt +0 -0
  18. {fivetran_connector_sdk-1.3.2 → fivetran_connector_sdk-1.3.3}/src/fivetran_connector_sdk.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fivetran_connector_sdk
3
- Version: 1.3.2
3
+ Version: 1.3.3
4
4
  Summary: Build custom connectors on Fivetran platform
5
5
  Author-email: Fivetran <developers@fivetran.com>
6
6
  Project-URL: Homepage, https://fivetran.com/docs/connectors/connector-sdk
@@ -32,13 +32,13 @@ from fivetran_connector_sdk.protos import connector_sdk_pb2_grpc
32
32
 
33
33
  # Version format: <major_version>.<minor_version>.<patch_version>
34
34
  # (where Major Version = 1 for GA, Minor Version is incremental MM from Jan 25 onwards, Patch Version is incremental within a month)
35
- __version__ = "1.3.2"
35
+ __version__ = "1.3.3"
36
36
 
37
37
  MAC_OS = "mac"
38
38
  WIN_OS = "windows"
39
39
  LINUX_OS = "linux"
40
40
 
41
- TESTER_VERSION = "0.25.0415.001"
41
+ TESTER_VERSION = "0.25.0423.001"
42
42
  TESTER_FILENAME = "run_sdk_tester.jar"
43
43
  VERSION_FILENAME = "version.txt"
44
44
  UPLOAD_FILENAME = "code.zip"
@@ -87,6 +87,7 @@ MAX_CONFIG_FIELDS = 100
87
87
  SUPPORTED_PYTHON_VERSIONS = ["3.12.8", "3.11.11", "3.10.16", "3.9.21"]
88
88
  DEFAULT_PYTHON_VERSION = "3.12.8"
89
89
  FIVETRAN_HD_AGENT_ID = "FIVETRAN_HD_AGENT_ID"
90
+ UTF_8 = "utf-8"
90
91
 
91
92
 
92
93
  class Logging:
@@ -298,7 +299,7 @@ def check_newer_version():
298
299
 
299
300
  if os.path.isfile(last_check_file_path):
300
301
  # Is it time to check again?
301
- with open(last_check_file_path, 'r') as f_in:
302
+ with open(last_check_file_path, 'r', encoding=UTF_8) as f_in:
302
303
  timestamp = int(f_in.read())
303
304
  if (int(time.time()) - timestamp) < ONE_DAY_IN_SEC:
304
305
  return
@@ -314,7 +315,7 @@ def check_newer_version():
314
315
  print_library_log(f"[notice] A new release of 'fivetran-connector-sdk' is available: {latest_version}\n" +
315
316
  f"[notice] To update, run: pip install --upgrade fivetran-connector-sdk\n")
316
317
 
317
- with open(last_check_file_path, 'w') as f_out:
318
+ with open(last_check_file_path, 'w', encoding=UTF_8) as f_out:
318
319
  f_out.write(f"{int(time.time())}")
319
320
  break
320
321
  except Exception:
@@ -363,10 +364,35 @@ def _map_data_to_columns(data: dict, columns: dict) -> dict:
363
364
  elif (key in columns) and columns[key].type != common_pb2.DataType.UNSPECIFIED:
364
365
  map_defined_data_type(columns, key, mapped_data, v)
365
366
  else:
366
- mapped_data[key] = common_pb2.ValueType(string=str(v))
367
+ map_inferred_data_type(key, mapped_data, v)
367
368
  return mapped_data
368
369
 
369
370
 
371
+ def map_inferred_data_type(k, mapped_data, v):
372
+ # We can infer type from the value
373
+ if isinstance(v, int):
374
+ if abs(v) > JAVA_LONG_MAX_VALUE:
375
+ mapped_data[k] = common_pb2.ValueType(float=v)
376
+ else:
377
+ mapped_data[k] = common_pb2.ValueType(long=v)
378
+ elif isinstance(v, float):
379
+ mapped_data[k] = common_pb2.ValueType(float=v)
380
+ elif isinstance(v, bool):
381
+ mapped_data[k] = common_pb2.ValueType(bool=v)
382
+ elif isinstance(v, bytes):
383
+ mapped_data[k] = common_pb2.ValueType(binary=v)
384
+ elif isinstance(v, list):
385
+ raise ValueError(
386
+ "Values for the columns cannot be of type 'list'. Please ensure that all values are of a supported type. Reference: https://fivetran.com/docs/connectors/connector-sdk/technical-reference#supporteddatatypes")
387
+ elif isinstance(v, dict):
388
+ mapped_data[k] = common_pb2.ValueType(json=json.dumps(v))
389
+ elif isinstance(v, str):
390
+ mapped_data[k] = common_pb2.ValueType(string=v)
391
+ else:
392
+ # Convert arbitrary objects to string
393
+ mapped_data[k] = common_pb2.ValueType(string=str(v))
394
+
395
+
370
396
  def map_defined_data_type(columns, k, mapped_data, v):
371
397
  if columns[k].type == common_pb2.DataType.BOOLEAN:
372
398
  mapped_data[k] = common_pb2.ValueType(bool=v)
@@ -425,7 +451,7 @@ def _exit_check(project_path):
425
451
  # exit() or sys.exit() in between some yields can cause the connector to be stuck without processing further upsert calls
426
452
 
427
453
  filepath = os.path.join(project_path, ROOT_FILENAME)
428
- with open(filepath, "r") as f:
454
+ with open(filepath, "r", encoding=UTF_8) as f:
429
455
  try:
430
456
  tree = ast.parse(f.read())
431
457
  for node in ast.walk(tree):
@@ -569,7 +595,7 @@ def get_available_port():
569
595
  def update_base_url_if_required():
570
596
  config_file_path = os.path.join(_tester_root_dir(), CONFIG_FILE)
571
597
  if os.path.isfile(config_file_path):
572
- with open(config_file_path, 'r') as f:
598
+ with open(config_file_path, 'r', encoding=UTF_8) as f:
573
599
  data = json.load(f)
574
600
  base_url = data.get('production_base_url')
575
601
  if base_url is not None:
@@ -719,7 +745,7 @@ class Connector(connector_sdk_pb2_grpc.ConnectorServicer):
719
745
  Returns:
720
746
  list[str]: A list of dependencies as strings.
721
747
  """
722
- with open(file_path, 'r') as f:
748
+ with open(file_path, 'r', encoding=UTF_8) as f:
723
749
  return f.read().splitlines()
724
750
 
725
751
  @staticmethod
@@ -850,7 +876,7 @@ class Connector(connector_sdk_pb2_grpc.ConnectorServicer):
850
876
  if force:
851
877
  requirements = tmp_requirements
852
878
 
853
- with open(REQUIREMENTS_TXT, "w") as file:
879
+ with open(REQUIREMENTS_TXT, "w", encoding=UTF_8) as file:
854
880
  file.write("\n".join(requirements.values()))
855
881
  print_library_log(f"`{REQUIREMENTS_TXT}` has been updated successfully")
856
882
 
@@ -883,7 +909,7 @@ class Connector(connector_sdk_pb2_grpc.ConnectorServicer):
883
909
  if os.path.exists(REQUIREMENTS_TXT):
884
910
  requirements = self.fetch_requirements_as_dict(self, os.path.join(project_path, 'requirements.txt'))
885
911
  else:
886
- with open(REQUIREMENTS_TXT, 'w'):
912
+ with open(REQUIREMENTS_TXT, 'w', encoding=UTF_8):
887
913
  pass
888
914
  requirements = {}
889
915
  print_library_log("Adding `requirements.txt` file to your project folder.", Logging.Level.WARNING)
@@ -929,8 +955,6 @@ class Connector(connector_sdk_pb2_grpc.ConnectorServicer):
929
955
  self.validate_requirements_file(args.project_path, True, args.force)
930
956
 
931
957
  group_id, group_name = self.__get_group_info(group, deploy_key)
932
- if hd_agent_id is None:
933
- hd_agent_id = self.__get_hd_agent_id(group_id, deploy_key)
934
958
  connection_id, service = self.__get_connection_id(connection, group, group_id, deploy_key) or (None, None)
935
959
 
936
960
  if connection_id:
@@ -1272,31 +1296,6 @@ class Connector(connector_sdk_pb2_grpc.ConnectorServicer):
1272
1296
  return LINUX_OS
1273
1297
  raise ValueError(f"Unrecognized OS: {os_sysname}")
1274
1298
 
1275
-
1276
- @staticmethod
1277
- def __get_hd_agent_id(destination_id: str, deploy_key: str) -> str:
1278
- """Retrieves the destination information for the specified destination ID and deployment key.
1279
-
1280
- Args:
1281
- destination_id (str): The destination ID.
1282
- deploy_key (str): The deployment key.
1283
-
1284
- Returns:
1285
- str: The hybrid_deployment_agent_id if HD enabled destination else returns None
1286
- """
1287
- destinations_url = f"{PRODUCTION_BASE_URL}/v1/destinations/{destination_id}"
1288
-
1289
- headers = {"Authorization": f"Basic {deploy_key}"}
1290
- resp = rq.get(destinations_url, headers=headers)
1291
-
1292
- if not resp.ok:
1293
- print_library_log(
1294
- f"The request failed with status code: {resp.status_code}. Please ensure you're using a valid base64-encoded API key and try again.", Logging.Level.SEVERE)
1295
- os._exit(1)
1296
-
1297
- data = resp.json().get("data", {})
1298
- return data.get("hybrid_deployment_agent_id")
1299
-
1300
1299
  @staticmethod
1301
1300
  def __get_group_info(group: str, deploy_key: str) -> tuple[str, str]:
1302
1301
  """Retrieves the group information for the specified group and deployment key.
@@ -1413,7 +1412,7 @@ class Connector(connector_sdk_pb2_grpc.ConnectorServicer):
1413
1412
  version_file = os.path.join(tester_root_dir, VERSION_FILENAME)
1414
1413
  if os.path.isfile(version_file):
1415
1414
  # Check version number & update if different
1416
- with open(version_file, 'r') as fi:
1415
+ with open(version_file, 'r', encoding=UTF_8) as fi:
1417
1416
  current_version = fi.readline()
1418
1417
 
1419
1418
  if current_version != TESTER_VERSION:
@@ -1912,7 +1911,7 @@ def validate_and_load_configuration(args, configuration):
1912
1911
  if configuration:
1913
1912
  json_filepath = os.path.join(args.project_path, args.configuration)
1914
1913
  if os.path.isfile(json_filepath):
1915
- with open(json_filepath, 'r') as fi:
1914
+ with open(json_filepath, 'r', encoding=UTF_8) as fi:
1916
1915
  configuration = json.load(fi)
1917
1916
  if len(configuration) > MAX_CONFIG_FIELDS:
1918
1917
  raise ValueError(f"Configuration field count exceeds maximum of {MAX_CONFIG_FIELDS}. Reduce the field count.")
@@ -1936,7 +1935,7 @@ def validate_and_load_state(args, state):
1936
1935
 
1937
1936
  if os.path.exists(json_filepath):
1938
1937
  if os.path.isfile(json_filepath):
1939
- with open(json_filepath, 'r') as fi:
1938
+ with open(json_filepath, 'r', encoding=UTF_8) as fi:
1940
1939
  state = json.load(fi)
1941
1940
  elif state.lstrip().startswith("{"):
1942
1941
  state = json.loads(state)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fivetran_connector_sdk
3
- Version: 1.3.2
3
+ Version: 1.3.3
4
4
  Summary: Build custom connectors on Fivetran platform
5
5
  Author-email: Fivetran <developers@fivetran.com>
6
6
  Project-URL: Homepage, https://fivetran.com/docs/connectors/connector-sdk