msfabricpysdkcore 0.1.2__tar.gz → 0.1.4__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 (64) hide show
  1. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/PKG-INFO +18 -2
  2. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/README.md +17 -1
  3. msfabricpysdkcore-0.1.4/msfabricpysdkcore/__init__.py +5 -0
  4. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/adminapi.py +10 -5
  5. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/auth.py +25 -9
  6. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/client.py +17 -6
  7. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/coreapi.py +34 -19
  8. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/deployment_pipeline.py +5 -3
  9. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/fabric_azure_client.py +8 -4
  10. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/long_running_operation.py +14 -5
  11. msfabricpysdkcore-0.1.4/msfabricpysdkcore/util/__init__.py +3 -0
  12. msfabricpysdkcore-0.1.4/msfabricpysdkcore/util/logger.py +32 -0
  13. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore.egg-info/PKG-INFO +18 -2
  14. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore.egg-info/SOURCES.txt +3 -1
  15. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/pyproject.toml +1 -1
  16. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/setup.py +1 -1
  17. msfabricpysdkcore-0.1.2/msfabricpysdkcore/__init__.py +0 -3
  18. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/LICENSE +0 -0
  19. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/admin_item.py +0 -0
  20. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/admin_workspace.py +0 -0
  21. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/capacity.py +0 -0
  22. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/domain.py +0 -0
  23. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/environment.py +0 -0
  24. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/fabric_azure_capacity.py +0 -0
  25. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/item.py +0 -0
  26. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/job_instance.py +0 -0
  27. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/lakehouse.py +0 -0
  28. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/onelakeshortcut.py +0 -0
  29. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/otheritems.py +0 -0
  30. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/spark_custom_pool.py +0 -0
  31. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/__init__.py +0 -0
  32. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_admin_apis.py +0 -0
  33. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_datapipelines.py +0 -0
  34. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_deployment_pipeline.py +0 -0
  35. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_domains.py +0 -0
  36. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_environments.py +0 -0
  37. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_evenhouses.py +0 -0
  38. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_evenstreams.py +0 -0
  39. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_external_data_shares.py +0 -0
  40. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_fabric_azure_client.py +0 -0
  41. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_git.py +0 -0
  42. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_items.py +0 -0
  43. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_items_incl_lakehouse.py +0 -0
  44. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_jobs.py +0 -0
  45. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_kql_queryset.py +0 -0
  46. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_kqldatabases.py +0 -0
  47. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_lakehouse.py +0 -0
  48. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_ml_experiments.py +0 -0
  49. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_ml_models.py +0 -0
  50. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_notebooks.py +0 -0
  51. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_one_lake_data_access_security.py +0 -0
  52. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_other_items.py +0 -0
  53. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_reports.py +0 -0
  54. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_semantic_model.py +0 -0
  55. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_shortcuts.py +0 -0
  56. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_spark.py +0 -0
  57. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_sparkjobdefinition.py +0 -0
  58. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_warehouses.py +0 -0
  59. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/tests/test_workspaces_capacities.py +0 -0
  60. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore/workspace.py +0 -0
  61. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore.egg-info/dependency_links.txt +0 -0
  62. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore.egg-info/requires.txt +0 -0
  63. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/msfabricpysdkcore.egg-info/top_level.txt +0 -0
  64. {msfabricpysdkcore-0.1.2 → msfabricpysdkcore-0.1.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: msfabricpysdkcore
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: A Python SDK for Microsoft Fabric
5
5
  Author: Andreas Rederer
6
6
  Project-URL: Homepage, https://github.com/DaSenf1860/ms-fabric-sdk-core
@@ -60,6 +60,7 @@ Currently it supports all Core APIs, Admin APIs, all item specific CRUD APIs and
60
60
  - Lakehouse operations (Load table, list tables, run table maintenance)
61
61
  - Spark Pool operations
62
62
  - [Azure Resource Management APIs for Fabric capacities](#azure-resource-management-apis-for-fabric-capacities)
63
+ - [Logging](#logging)
63
64
 
64
65
  It is planned to support also new APIs which are not released yet.
65
66
  Also we have plans to support APIs to interact with Fabric capacities on the Azure Side.
@@ -744,7 +745,7 @@ resp = fac.check_name_availability(subscription_id, "westeurope", capacity_name_
744
745
  # Create or update capacity
745
746
  resp = fac.create_or_update_capacity(subscription_id, resource_group_name, capacity_name_new,
746
747
  location="westeurope",
747
- properties_administration={"members": ['admin@MngEnvMCAP065039.onmicrosoft.com']},
748
+ properties_administration={"members": ['hfds@afasf.com']},
748
749
  sku = "F2")
749
750
 
750
751
  # Get capacity
@@ -777,3 +778,18 @@ resp = fac.suspend_capacity(subscription_id, resource_group_name, capacity_name)
777
778
  # Update capacity
778
779
  resp = fac.update_capacity(subscription_id, resource_group_name, capacity_name, sku="F4")
779
780
  ```
781
+
782
+ ### Logging
783
+
784
+ The SDK uses the Python logging module, following the logging settings of your application. You can set up logging in
785
+ your project like this:
786
+
787
+ ```python
788
+ import logging
789
+ from msfabricpysdkcore import FabricClientCore
790
+
791
+ logging.basicConfig(level=logging.DEBUG)
792
+ fc = FabricClientCore() # The client will now log
793
+ ```
794
+
795
+ You can also set the environment variable `FABRIC_SDK_DEBUG` to `1` to enable debug logging.
@@ -45,6 +45,7 @@ Currently it supports all Core APIs, Admin APIs, all item specific CRUD APIs and
45
45
  - Lakehouse operations (Load table, list tables, run table maintenance)
46
46
  - Spark Pool operations
47
47
  - [Azure Resource Management APIs for Fabric capacities](#azure-resource-management-apis-for-fabric-capacities)
48
+ - [Logging](#logging)
48
49
 
49
50
  It is planned to support also new APIs which are not released yet.
50
51
  Also we have plans to support APIs to interact with Fabric capacities on the Azure Side.
@@ -729,7 +730,7 @@ resp = fac.check_name_availability(subscription_id, "westeurope", capacity_name_
729
730
  # Create or update capacity
730
731
  resp = fac.create_or_update_capacity(subscription_id, resource_group_name, capacity_name_new,
731
732
  location="westeurope",
732
- properties_administration={"members": ['admin@MngEnvMCAP065039.onmicrosoft.com']},
733
+ properties_administration={"members": ['hfds@afasf.com']},
733
734
  sku = "F2")
734
735
 
735
736
  # Get capacity
@@ -762,3 +763,18 @@ resp = fac.suspend_capacity(subscription_id, resource_group_name, capacity_name)
762
763
  # Update capacity
763
764
  resp = fac.update_capacity(subscription_id, resource_group_name, capacity_name, sku="F4")
764
765
  ```
766
+
767
+ ### Logging
768
+
769
+ The SDK uses the Python logging module, following the logging settings of your application. You can set up logging in
770
+ your project like this:
771
+
772
+ ```python
773
+ import logging
774
+ from msfabricpysdkcore import FabricClientCore
775
+
776
+ logging.basicConfig(level=logging.DEBUG)
777
+ fc = FabricClientCore() # The client will now log
778
+ ```
779
+
780
+ You can also set the environment variable `FABRIC_SDK_DEBUG` to `1` to enable debug logging.
@@ -0,0 +1,5 @@
1
+ from .coreapi import FabricClientCore
2
+ from .adminapi import FabricClientAdmin
3
+ from .fabric_azure_client import FabricAzureClient
4
+
5
+ __all__ = ["FabricClientCore", "FabricClientAdmin", "FabricAzureClient"]
@@ -2,6 +2,7 @@ import requests
2
2
  import json
3
3
  import os
4
4
  from time import sleep
5
+ from warnings import warn
5
6
 
6
7
  from msfabricpysdkcore.client import FabricClient
7
8
 
@@ -17,7 +18,7 @@ class FabricClientAdmin(FabricClient):
17
18
  def long_running_operation(self, response_headers):
18
19
  """Check the status of a long running operation"""
19
20
  from msfabricpysdkcore.coreapi import FabricClientCore
20
- fc = FabricClientCore(tenant_id=self.tenant_id, client_id=self.client_id, client_secret=self.client_secret, silent=True)
21
+ fc = FabricClientCore(tenant_id=self.tenant_id, client_id=self.client_id, client_secret=self.client_secret)
21
22
 
22
23
  return fc.long_running_operation(response_headers)
23
24
 
@@ -171,7 +172,7 @@ class FabricClientAdmin(FabricClient):
171
172
 
172
173
  if workspace_objects:
173
174
  from msfabricpysdkcore import FabricClientCore
174
- fc = FabricClientCore(tenant_id=self.tenant_id, client_id=self.client_id, client_secret=self.client_secret, silent=True)
175
+ fc = FabricClientCore(tenant_id=self.tenant_id, client_id=self.client_id, client_secret=self.client_secret)
175
176
  workspaces = [fc.get_workspace_by_id(workspace["id"]) for workspace in workspaces]
176
177
 
177
178
  return workspaces
@@ -300,9 +301,13 @@ class FabricClientAdmin(FabricClient):
300
301
  return_format="json")
301
302
 
302
303
  if return_item == "Default":
303
- print("""Warning: Updating a domain currently will make invoke an additional API call to get the domain object.
304
- This default behaviour will change in newer versions of the SDK.
305
- To keep this behaviour, set return_item=True in the function call.""")
304
+ warn(
305
+ message="Updating a domain currently will make invoke an additional API call to get the domain "
306
+ "object. This default behaviour will change in newer versions of the SDK. To keep this "
307
+ "behaviour, set return_item=True in the function call.",
308
+ category=FutureWarning,
309
+ stacklevel=2
310
+ )
306
311
  if return_item:
307
312
  return self.get_domain_by_id(domain_id)
308
313
  return response_json
@@ -1,6 +1,10 @@
1
+ from warnings import warn
2
+
1
3
  import requests
2
4
  from abc import abstractmethod
3
5
  from azure.identity import AzureCliCredential
6
+ from msfabricpysdkcore.util import logger
7
+ import logging
4
8
  try:
5
9
  from notebookutils import mssparkutils
6
10
  except ImportError:
@@ -8,7 +12,11 @@ except ImportError:
8
12
  class FabricAuth():
9
13
  """FabricAuth class to interact with Entra ID"""
10
14
 
15
+ _logger: logging.Logger
16
+
11
17
  def __init__(self, scope):
18
+ """Initialize FabricAuth object"""
19
+ self._logger = logger.getChild(__name__)
12
20
  self.scope = scope
13
21
 
14
22
  @abstractmethod
@@ -29,12 +37,14 @@ class FabricAuth():
29
37
  class FabricAuthClient(FabricAuth):
30
38
  """FabricAuthClient class to interact with Entra ID"""
31
39
 
32
- def __init__(self, scope, silent = False):
40
+ def __init__(self, scope, silent = None):
33
41
  super().__init__(scope)
34
- if not silent:
35
- print("Using Azure CLI for authentication")
42
+ self._logger.info("Using Azure CLI for authentication")
36
43
  self.auth = AzureCliCredential()
37
44
 
45
+ if silent is not None:
46
+ warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
47
+
38
48
  def get_token(self):
39
49
  """Get token from Azure AD"""
40
50
  token = self.auth.get_token(self.scope)
@@ -43,16 +53,18 @@ class FabricAuthClient(FabricAuth):
43
53
  class FabricServicePrincipal(FabricAuth):
44
54
  """FabricServicePrincipal class to interact with Entra ID"""
45
55
 
46
- def __init__(self, tenant_id, client_id, client_secret, scope, silent = False):
56
+ def __init__(self, tenant_id, client_id, client_secret, scope, silent = None):
47
57
  super().__init__(scope)
48
58
 
49
- if not silent:
50
- print("Using Service Principal for authentication")
59
+ self._logger.info("Using Service Principal for authentication")
51
60
 
52
61
  self.tenant_id = tenant_id
53
62
  self.client_id = client_id
54
63
  self.client_secret = client_secret
55
64
 
65
+ if silent is not None:
66
+ warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
67
+
56
68
 
57
69
  def get_token(self):
58
70
  """Get token from Azure AD"""
@@ -71,10 +83,14 @@ class FabricServicePrincipal(FabricAuth):
71
83
  class FabricSparkUtilsAuthentication(FabricAuth):
72
84
  """FabricSparkUtilsAuthentication class to interact with Entra ID"""
73
85
 
74
- def __init__(self, scope, silent = False):
86
+ def __init__(self, scope, silent=None):
87
+ # super().__init__(scope)
88
+
75
89
  mssparkutils.credentials.getToken("pbi")
76
- if not silent:
77
- print("Using Synapse Spark Utils for authentication")
90
+ self._logger.info("Using Synapse Spark Utils for authentication")
91
+
92
+ if silent is not None:
93
+ warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
78
94
 
79
95
  def get_token(self):
80
96
  """Get token from Azure AD"""
@@ -1,16 +1,24 @@
1
+ import logging
1
2
  from abc import abstractmethod
2
3
  import os
4
+ from warnings import warn
3
5
  from time import sleep
4
6
  import requests
5
7
  import json
6
8
 
7
9
  from msfabricpysdkcore.auth import FabricAuthClient, FabricServicePrincipal, FabricSparkUtilsAuthentication
10
+ from msfabricpysdkcore.util import logger
8
11
 
9
12
  class FabricClient():
10
13
  """FabricClient class to interact with Fabric API"""
11
14
 
12
- def __init__(self, scope, tenant_id = None, client_id = None, client_secret = None, silent=False) -> None:
15
+ _logger: logging.Logger
16
+
17
+ def __init__(self, scope, tenant_id = None, client_id = None, client_secret = None, silent=None) -> None:
13
18
  """Initialize FabricClient object"""
19
+
20
+ self._logger = logger.getChild(__name__)
21
+
14
22
  self.tenant_id = tenant_id if tenant_id else os.getenv("FABRIC_TENANT_ID")
15
23
  self.client_id = client_id if client_id else os.getenv("FABRIC_CLIENT_ID")
16
24
  self.client_secret = client_secret if client_secret else os.getenv("FABRIC_CLIENT_SECRET")
@@ -19,15 +27,18 @@ class FabricClient():
19
27
 
20
28
  if self.client_id is None or self.client_secret is None or self.tenant_id is None:
21
29
  try:
22
- self.auth = FabricSparkUtilsAuthentication(self.scope, silent=silent)
30
+ self.auth = FabricSparkUtilsAuthentication(self.scope)
23
31
  except:
24
- self.auth = FabricAuthClient(self.scope, silent=silent)
32
+ self.auth = FabricAuthClient(self.scope)
25
33
  else:
26
34
  self.auth = FabricServicePrincipal(scope= self.scope,
27
35
  tenant_id = self.tenant_id,
28
36
  client_id = self.client_id,
29
- client_secret = self.client_secret,
30
- silent=silent)
37
+ client_secret = self.client_secret)
38
+
39
+ if silent is not None:
40
+ warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
41
+
31
42
 
32
43
  def get_token(self):
33
44
  """Get token from Entra"""
@@ -91,7 +102,7 @@ class FabricClient():
91
102
  else:
92
103
  raise ValueError("Invalid operation")
93
104
  if response.status_code == 429:
94
- print("Too many requests, waiting 10 seconds")
105
+ self._logger.info("Too many requests, waiting 10 seconds")
95
106
  sleep(10)
96
107
  continue
97
108
  elif response.status_code == 202:
@@ -1,17 +1,22 @@
1
1
  import json
2
2
  from time import sleep
3
+ from warnings import warn
3
4
 
4
5
  from msfabricpysdkcore.client import FabricClient
6
+ from msfabricpysdkcore.util import logger
7
+
5
8
 
6
9
  class FabricClientCore(FabricClient):
7
10
  """FabricClientCore class to interact with Fabric Core APIs"""
8
11
 
9
- def __init__(self, tenant_id = None, client_id = None, client_secret = None, silent=False) -> None:
12
+ def __init__(self, tenant_id = None, client_id = None, client_secret = None, silent=None) -> None:
10
13
  """Initialize FabricClientCore object"""
11
14
  super().__init__(scope="https://api.fabric.microsoft.com/.default",
12
15
  tenant_id=tenant_id,
13
16
  client_id=client_id,
14
- client_secret=client_secret, silent=silent)
17
+ client_secret=client_secret)
18
+ if silent is not None:
19
+ warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
15
20
 
16
21
  def long_running_operation(self, response_headers):
17
22
  """Check the status of a long running operation"""
@@ -110,7 +115,7 @@ class FabricClientCore(FabricClient):
110
115
  return DeploymentPipeline.from_dict(result_json, self)
111
116
 
112
117
  def get_deployment_pipeline_stages_items(self, pipeline_id, stage_id = None, stage_name = None):
113
- print("DEPRECATED: Use list_deployment_pipeline_stages_items instead")
118
+ warn("DEPRECATED: get_deployment_pipeline_stages_items. get_deployment_pipeline_stages_items. Use list_deployment_pipeline_stages_items instead", DeprecationWarning, stacklevel=2)
114
119
  return self.list_deployment_pipeline_stages_items(pipeline_id, stage_id, stage_name)
115
120
 
116
121
  def list_deployment_pipeline_stages_items(self, deployment_pipeline_id, stage_id = None, stage_name = None):
@@ -139,7 +144,7 @@ class FabricClientCore(FabricClient):
139
144
  error_message="Error getting deployment pipeline stage items", return_format="value_json", paging=True)
140
145
 
141
146
  return items
142
-
147
+
143
148
  def get_deployment_pipeline_stages(self, pipeline_id):
144
149
  """Get the stages of a deployment pipeline
145
150
  Args:
@@ -147,9 +152,9 @@ class FabricClientCore(FabricClient):
147
152
  Returns:
148
153
  list: List of DeploymentPipelineStage objects
149
154
  """
150
- print("DEPRECATED: Use list_deployment_pipeline_stages instead")
155
+ warn("DEPRECATED: get_deployment_pipeline_stages. Use list_deployment_pipeline_stages instead", DeprecationWarning, stacklevel=2)
151
156
  return self.list_deployment_pipeline_stages(pipeline_id)
152
-
157
+
153
158
  def list_deployment_pipeline_stages(self, deployment_pipeline_id):
154
159
  """Get the stages of a deployment pipeline
155
160
  Args:
@@ -528,7 +533,7 @@ class FabricClientCore(FabricClient):
528
533
 
529
534
 
530
535
  if item_dict is None or "no_operation_result" in item_dict:
531
- print("Item not returned by API, trying to get it by name")
536
+ self._logger.debug("Item not returned by API, trying to get it by name")
532
537
  item = None
533
538
  i = 0
534
539
 
@@ -553,11 +558,11 @@ class FabricClientCore(FabricClient):
553
558
  item = self.get_item_by_name(workspace_id, display_name, type)
554
559
  if item is not None:
555
560
  return item
556
- print("Item not found, waiting 5 seconds")
561
+ self._logger.debug("Item not found, waiting 5 seconds")
557
562
  sleep(5)
558
563
  i += 1
559
564
 
560
- print("Item not found after 1 minute, returning None")
565
+ self._logger.info("Item not found after 1 minute, returning None")
561
566
  return None
562
567
 
563
568
  return self.get_item_specific(workspace_id, item_dict)
@@ -709,9 +714,13 @@ class FabricClientCore(FabricClient):
709
714
  response_codes=[200, 429], error_message="Error updating item",
710
715
  return_format="json")
711
716
  if return_item == "Default":
712
- print("""Warning: Updating an item currently will make invoke an additional API call to get the item object.
713
- This default behaviour will change in newer versions of the SDK.
714
- To keep this behaviour, set return_item=True in the function call.""")
717
+ warn(
718
+ message="Updating an item currently will make invoke an additional API call to get the item object. "
719
+ "The default behaviour of returning the item object will change in newer versions of the SDK. "
720
+ "To keep this behaviour, set return_item=True in the function call.",
721
+ category=FutureWarning,
722
+ stacklevel=2
723
+ )
715
724
  if return_item:
716
725
  return self.get_item_specific(workspace_id, resp_dict)
717
726
  return resp_dict
@@ -2013,16 +2022,18 @@ class FabricClientCore(FabricClient):
2013
2022
  response = self.calling_routine(url, operation="POST", body=body, response_codes=[202, 429],
2014
2023
  error_message="Error loading table", return_format="response",
2015
2024
  wait_for_completion=False)
2016
-
2025
+
2017
2026
  if wait_for_completion:
2018
2027
  success = self.check_if_table_is_created(workspace_id = workspace_id,
2019
2028
  lakehouse_id = lakehouse_id,
2020
2029
  table_name = table_name)
2021
-
2030
+ else:
2031
+ success = None
2032
+
2022
2033
  if not success:
2023
- print("Warning: Table not created after 3 minutes")
2034
+ self._logger.warning("Table not created after 3 minutes")
2024
2035
  else:
2025
- print("Table created")
2036
+ self._logger.info("Table created")
2026
2037
  return response.status_code
2027
2038
 
2028
2039
  # mlExperiments
@@ -2561,9 +2572,13 @@ class FabricClientCore(FabricClient):
2561
2572
  error_message="Error updating workspace custom pool", return_format="json")
2562
2573
 
2563
2574
  if return_item == "Default":
2564
- print("""Warning: Updating an item currently will make invoke an additional API call to get the item object.
2565
- This default behaviour will change in newer versions of the SDK.
2566
- To keep this behaviour, set return_item=True in the function call.""")
2575
+ warn(
2576
+ message="Warning: Updating an item currently will make invoke an additional API call to get the item "
2577
+ "object. This default behaviour will change in newer versions of the SDK. To keep this "
2578
+ "behaviour, set return_item=True in the function call.",
2579
+ category=FutureWarning,
2580
+ stacklevel=2
2581
+ )
2567
2582
  if return_item:
2568
2583
  return self.get_workspace_custom_pool(workspace_id, pool_id)
2569
2584
  return response_json
@@ -1,4 +1,5 @@
1
1
  import json
2
+ from warnings import warn
2
3
 
3
4
  from msfabricpysdkcore.coreapi import FabricClientCore
4
5
 
@@ -46,7 +47,7 @@ class DeploymentPipeline:
46
47
 
47
48
 
48
49
  def get_stages(self):
49
- print("DEPRECATED: Use list_stages() instead")
50
+ warn("DEPRECATED: Use list_stages() instead", DeprecationWarning, stacklevel=2)
50
51
  return self.list_stages(self)
51
52
 
52
53
  def list_stages(self):
@@ -54,13 +55,14 @@ class DeploymentPipeline:
54
55
 
55
56
 
56
57
  def get_deployment_pipeline_stages_items(self, stage_id = None, stage_name = None):
57
- print("DEPRECATED: Use list_deployment_pipeline_stages_items() instead")
58
+ warn("DEPRECATED: get_deployment_pipeline_stages_items. Use list_deployment_pipeline_stages_items() instead", DeprecationWarning, stacklevel=2)
58
59
  return self.list_deployment_pipeline_stages_items(stage_id=stage_id, stage_name=stage_name)
59
60
 
60
61
 
61
62
  def list_deployment_pipeline_stages_items(self, stage_id = None, stage_name = None):
62
63
  return self.core_client.list_deployment_pipeline_stages_items(deployment_pipeline_id=self.id, stage_id=stage_id, stage_name=stage_name)
63
64
 
65
+
64
66
  class Deployment_Pipeline_Stage():
65
67
 
66
68
  """Class to represent a deployment pipeline stage in Microsoft Fabric"""
@@ -120,7 +122,7 @@ class Deployment_Pipeline_Stage():
120
122
  return self.__str__()
121
123
 
122
124
  def get_items(self):
123
- print("DEPRECATED: Use list_items() instead")
125
+ warn("DEPRECATED: get_items. Use list_items() instead", DeprecationWarning, stacklevel=2)
124
126
  return self.list_items()
125
127
 
126
128
  def list_items(self):
@@ -1,14 +1,18 @@
1
+ from warnings import warn
2
+
1
3
  from msfabricpysdkcore.client import FabricClient
2
4
 
3
5
 
4
6
  class FabricAzureClient(FabricClient):
5
7
 
6
- def __init__(self, tenant_id=None, client_id=None, client_secret=None, silent=False) -> None:
7
- super().__init__(scope = "https://management.azure.com/",
8
+ def __init__(self, tenant_id=None, client_id=None, client_secret=None, silent=None) -> None:
9
+ super().__init__(scope = "https://management.azure.com/.default",
8
10
  tenant_id = tenant_id,
9
11
  client_id = client_id,
10
- client_secret = client_secret,
11
- silent = silent)
12
+ client_secret = client_secret,)
13
+
14
+ if silent is not None:
15
+ warn("The 'silent' parameter is deprecated and will be removed in a future version.", DeprecationWarning, stacklevel=2)
12
16
 
13
17
 
14
18
  def check_name_availability(self, subscription_id, location, name, type = "Microsoft.Fabric/capacities"):
@@ -1,16 +1,23 @@
1
+ import logging
1
2
  from time import sleep, time
2
3
  from msfabricpysdkcore.coreapi import FabricClientCore
4
+ from msfabricpysdkcore.util import logger
5
+
3
6
 
4
7
  class LongRunningOperation:
5
8
  """Class to represent a workspace in Microsoft Fabric"""
6
9
 
10
+ _logger: logging.Logger
11
+
7
12
  def __init__(self, operation_id, core_client: FabricClientCore) -> None:
13
+ """Initialize the LongRunningOperation object"""
14
+
15
+ self._logger = logger.getChild(__name__)
8
16
  self.operation_id = operation_id
9
17
  self.core_client = core_client
10
18
 
11
19
  self.state = self.get_operation_state()["status"]
12
20
 
13
-
14
21
  def get_operation_results(self):
15
22
  return self.core_client.get_operation_results(operation_id=self.operation_id)
16
23
 
@@ -26,22 +33,24 @@ class LongRunningOperation:
26
33
  if duration > 60:
27
34
 
28
35
  if self.state == "Running":
29
- print(f"Operation did not complete after {duration} seconds")
36
+ self._logger.info(f"Operation did not complete after {duration} seconds")
30
37
  return "Running"
31
- raise Exception(f"Operation did not complete after {duration} seconds")
38
+ raise TimeoutError(f"Operation did not complete after {duration} seconds")
32
39
  sleep(3)
33
40
  return self.state
34
41
 
35
42
 
36
43
  def check_long_running_operation(headers, core_client):
37
- """Check the status of a long running operation"""
44
+ """Check the status of a long-running operation"""
38
45
  location = headers.get('Location', None)
39
46
  operation_id = headers.get('x-ms-operation-id', None)
40
47
  if location:
41
48
  operation_id = location.split("/")[-1]
42
49
 
50
+ logger_ = logger.getChild(__name__)
51
+
43
52
  if not operation_id:
44
- print("Operation initiated, no operation id found")
53
+ logger_.info("Operation initiated, no operation id found")
45
54
  return None
46
55
  lro = LongRunningOperation(operation_id=operation_id, core_client=core_client)
47
56
  lro.wait_for_completion()
@@ -0,0 +1,3 @@
1
+ from .logger import logger
2
+
3
+ __all__ = ["logger"]
@@ -0,0 +1,32 @@
1
+ import logging
2
+ import os
3
+ from warnings import simplefilter
4
+
5
+ # Initialize logger for msfabricpysdkcore
6
+ logger: logging.Logger = logging.getLogger()
7
+
8
+ _logger = logger.getChild(__name__)
9
+
10
+ # Ensure warnings are always shown
11
+ simplefilter('always', DeprecationWarning)
12
+ simplefilter('always', FutureWarning)
13
+
14
+ # Add a NullHandler by default (https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library)
15
+ logger.addHandler(logging.NullHandler())
16
+
17
+ # Add a handler to log to console if desired (based on FABRIC_SDK_DEBUG environment variable)
18
+ if os.environ.get('FABRIC_SDK_DEBUG'):
19
+ logging.captureWarnings(True)
20
+ logging.getLogger("urllib3").setLevel(logging.INFO)
21
+ logger.setLevel(logging.DEBUG)
22
+ console_handler: logging.StreamHandler = logging.StreamHandler()
23
+ console_formatter: logging.Formatter = logging.Formatter(
24
+ '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
25
+ )
26
+ console_handler.setFormatter(console_formatter)
27
+ logger.addHandler(console_handler)
28
+ _logger.debug("Fabric SDK Debug mode. Logging to console enabled.")
29
+
30
+ _logger.debug("Logger initialized")
31
+
32
+ __all__ = ["logger"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: msfabricpysdkcore
3
- Version: 0.1.2
3
+ Version: 0.1.4
4
4
  Summary: A Python SDK for Microsoft Fabric
5
5
  Author: Andreas Rederer
6
6
  Project-URL: Homepage, https://github.com/DaSenf1860/ms-fabric-sdk-core
@@ -60,6 +60,7 @@ Currently it supports all Core APIs, Admin APIs, all item specific CRUD APIs and
60
60
  - Lakehouse operations (Load table, list tables, run table maintenance)
61
61
  - Spark Pool operations
62
62
  - [Azure Resource Management APIs for Fabric capacities](#azure-resource-management-apis-for-fabric-capacities)
63
+ - [Logging](#logging)
63
64
 
64
65
  It is planned to support also new APIs which are not released yet.
65
66
  Also we have plans to support APIs to interact with Fabric capacities on the Azure Side.
@@ -744,7 +745,7 @@ resp = fac.check_name_availability(subscription_id, "westeurope", capacity_name_
744
745
  # Create or update capacity
745
746
  resp = fac.create_or_update_capacity(subscription_id, resource_group_name, capacity_name_new,
746
747
  location="westeurope",
747
- properties_administration={"members": ['admin@MngEnvMCAP065039.onmicrosoft.com']},
748
+ properties_administration={"members": ['hfds@afasf.com']},
748
749
  sku = "F2")
749
750
 
750
751
  # Get capacity
@@ -777,3 +778,18 @@ resp = fac.suspend_capacity(subscription_id, resource_group_name, capacity_name)
777
778
  # Update capacity
778
779
  resp = fac.update_capacity(subscription_id, resource_group_name, capacity_name, sku="F4")
779
780
  ```
781
+
782
+ ### Logging
783
+
784
+ The SDK uses the Python logging module, following the logging settings of your application. You can set up logging in
785
+ your project like this:
786
+
787
+ ```python
788
+ import logging
789
+ from msfabricpysdkcore import FabricClientCore
790
+
791
+ logging.basicConfig(level=logging.DEBUG)
792
+ fc = FabricClientCore() # The client will now log
793
+ ```
794
+
795
+ You can also set the environment variable `FABRIC_SDK_DEBUG` to `1` to enable debug logging.
@@ -56,4 +56,6 @@ msfabricpysdkcore/tests/test_shortcuts.py
56
56
  msfabricpysdkcore/tests/test_spark.py
57
57
  msfabricpysdkcore/tests/test_sparkjobdefinition.py
58
58
  msfabricpysdkcore/tests/test_warehouses.py
59
- msfabricpysdkcore/tests/test_workspaces_capacities.py
59
+ msfabricpysdkcore/tests/test_workspaces_capacities.py
60
+ msfabricpysdkcore/util/__init__.py
61
+ msfabricpysdkcore/util/logger.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "msfabricpysdkcore"
7
- version = "0.1.2"
7
+ version = "0.1.4"
8
8
  dynamic = ["dependencies"]
9
9
  authors = [
10
10
  { name="Andreas Rederer"},
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='msfabricpysdkcore',
5
- version='1.2',
5
+ version='1.4',
6
6
  packages=find_packages(),
7
7
  install_requires=[
8
8
  'requests>=2.30.0',
@@ -1,3 +0,0 @@
1
- from .coreapi import FabricClientCore
2
- from .adminapi import FabricClientAdmin
3
- from .fabric_azure_client import FabricAzureClient