databricks-modules-vy 1.1.23__tar.gz → 1.2.1__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 (23) hide show
  1. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/PKG-INFO +1 -1
  2. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/sharepoint.py +30 -2
  3. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy.egg-info/PKG-INFO +1 -1
  4. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/pyproject.toml +1 -1
  5. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/LICENSE +0 -0
  6. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/__init__.py +0 -0
  7. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/data_product.py +0 -0
  8. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/data_quality_tests.py +0 -0
  9. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/dataframe.py +0 -0
  10. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/extend_class.py +0 -0
  11. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/glue.py +0 -0
  12. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/logging.py +0 -0
  13. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/oracle.py +0 -0
  14. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/qlik.py +0 -0
  15. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/s3.py +0 -0
  16. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/service_platform.py +0 -0
  17. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/snaplogic.py +0 -0
  18. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/styringsinfo_postgres.py +0 -0
  19. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy/unity_catalog.py +0 -0
  20. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy.egg-info/SOURCES.txt +0 -0
  21. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy.egg-info/dependency_links.txt +0 -0
  22. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/databricks_modules_vy.egg-info/top_level.txt +0 -0
  23. {databricks_modules_vy-1.1.23 → databricks_modules_vy-1.2.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: databricks_modules_vy
3
- Version: 1.1.23
3
+ Version: 1.2.1
4
4
  Summary: Databricks modules for Vy
5
5
  Author-email: Sindre Kjetså <sindre.kjetsa@vy.no>
6
6
  Project-URL: Homepage, https://github.com/nsbno/
@@ -21,10 +21,17 @@ dbutils = DBUtils(spark)
21
21
  def _get_sharepoint_ctx(site_name="VyMasterdata") -> ClientContext:
22
22
  sharepoint_url = dbutils.secrets.get("SHAREPOINT", "url")
23
23
  site_url = f"{sharepoint_url}/sites/{site_name}"
24
+ tenant = dbutils.secrets.get("SHAREPOINT", "tenant")
24
25
  client_id = dbutils.secrets.get("SHAREPOINT", "app_id")
25
- client_secret = dbutils.secrets.get("SHAREPOINT", "app_secret")
26
+ thumbprint = dbutils.secrets.get("SHAREPOINT", "cert_thumbprint")
27
+ private_key = dbutils.secrets.get("SHAREPOINT", "cert_private_key")
26
28
 
27
- return ClientContext(site_url).with_client_credentials(client_id, client_secret)
29
+ return ClientContext(site_url).with_client_certificate(
30
+ tenant=tenant,
31
+ client_id=client_id,
32
+ thumbprint=thumbprint,
33
+ private_key=private_key,
34
+ )
28
35
 
29
36
 
30
37
  def _execute_query_with_backoff(
@@ -276,6 +283,27 @@ def df_from_sharepoint_csv_utf8(
276
283
  return df
277
284
 
278
285
 
286
+ def df_from_sharepoint_excel(item_path, site_name="VyMasterdata", **kwargs) -> DataFrame:
287
+ """Gets the bytes from an excel file in sharepoint and converts it to a spark dataframe.
288
+
289
+ Requires the 'openpyxl' package, install it with '%pip install openpyxl'.
290
+
291
+ Args:
292
+ item_path (str) : path relative to the site the file is located. Initiate the path with '/'
293
+ site_name (str) : name of site to fetch the file from
294
+ **kwargs : additional keyword arguments passed directly to pd.read_excel
295
+ Returns:
296
+ (spark.DataFrame) dataframe of the excel sheet
297
+ """
298
+ file_bytesio = _get_file_bytes_from_sharepoint(item_path, site_name)
299
+ dp = pd.read_excel(io=file_bytesio, **kwargs)
300
+ dp = dp.replace([np.nan], [None])
301
+
302
+ df = spark.createDataFrame(dp)
303
+
304
+ return df
305
+
306
+
279
307
  # # Functions for traversing and extracting files and folders from a site # #
280
308
  def get_files_in_folder(relative_path_to_folder, site_name="VyMasterdata"):
281
309
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: databricks_modules_vy
3
- Version: 1.1.23
3
+ Version: 1.2.1
4
4
  Summary: Databricks modules for Vy
5
5
  Author-email: Sindre Kjetså <sindre.kjetsa@vy.no>
6
6
  Project-URL: Homepage, https://github.com/nsbno/
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "databricks_modules_vy"
3
- version = "1.1.23"
3
+ version = "1.2.1"
4
4
  authors = [
5
5
  { name="Sindre Kjetså", email="sindre.kjetsa@vy.no" },
6
6
  ]