dqlmagic 1.3.1__tar.gz → 1.3.2__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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: dqlmagic
3
- Version: 1.3.1
3
+ Version: 1.3.2
4
4
  Summary: IPython magic function for Dynatrace Query Language (DQL)
5
5
  Home-page: https://github.com/dtPaTh/Dqlmagic
6
6
  Author: Patrick Thurner
@@ -1,4 +1,4 @@
1
- __version__='1.3.1'
1
+ __version__='1.3.2'
2
2
 
3
3
  from .dqlmagic import DQLmagic
4
4
 
@@ -113,14 +113,16 @@ class DQLmagic(Magics):
113
113
  jdata = json.loads(res)
114
114
  records = jdata["result"]["records"]
115
115
 
116
- if self.shell.user_ns and cell is not None:
116
+ if getattr(self, "shell", None) is not None and getattr(self.shell, "user_ns", None) is not None and cell is not None:
117
117
  if line and not line.isspace():
118
118
  self.shell.user_ns.update({line: records})
119
119
  else:
120
120
  self.shell.user_ns.update({"_dql_result": records})
121
121
 
122
- if records:
123
- return str(len(records))+" records returned"
122
+ if isinstance(records, (list, tuple, set, dict)):
123
+ return str(len(records)) + " records returned"
124
+ else:
125
+ return "0 records returned"
124
126
  else:
125
127
  return records
126
128
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: dqlmagic
3
- Version: 1.3.1
3
+ Version: 1.3.2
4
4
  Summary: IPython magic function for Dynatrace Query Language (DQL)
5
5
  Home-page: https://github.com/dtPaTh/Dqlmagic
6
6
  Author: Patrick Thurner
@@ -1,3 +1,3 @@
1
- [build-system]
2
- requires = ["setuptools"]
3
- build-backend = "setuptools.build_meta"
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
@@ -1,89 +1,89 @@
1
- # Dqlmagic
2
-
3
- An IPython magic function allowing to use DQL in your notebooks.
4
-
5
- Dynatrace Query Language (DQL) is a powerful tool to explore your data and discover patterns, identify anomalies and outliers, create statistical modeling, and more based on data stored in Dynatrace Grail storage.
6
-
7
- Dqlmagic makes DQL queries available to be used in jupyter notebooks.
8
-
9
- ## Available magic functions
10
-
11
- ### %%dql or %dql
12
- Executes a DQL query and returns the queried records as json array.
13
-
14
- ### Example 1
15
- Query in code-cell..
16
- ```
17
- %%dql
18
- fetch logs
19
- | limit 10
20
- ```
21
- .. and use result in another code cell:
22
- ```
23
- import pandas as pd
24
-
25
- #put result into a dataframe
26
- df = pd.DataFrame(_dql_result)
27
- df.head()
28
- ```
29
- **Note:**
30
- By default ``%%dql`` writes into ``_dql_result``. You can optionally customize the target objects name to configure an alternative name like this:
31
- ```
32
- %%dql my_result
33
- fetch logs | limit 10
34
- ```
35
-
36
- ### Example 2 - Inline Query
37
- ```
38
- import pandas as pd
39
-
40
- res = %dql fetch logs | limit 10
41
- df = pd.DataFrame(res)
42
- df.head()
43
- ```
44
-
45
- ### %dql_raw and %%dql_raw
46
- Same as ```%dql``` or ```%%dql```, but returns instead of the result records the full API response json
47
-
48
- ### %auth_grail <config_prefix>
49
- Inline function connecting to the grail cluster.
50
-
51
- Reads connection parameters from .env file:
52
- ```
53
- dt_oauth_url="https://sso.dynatrace.com/sso/oauth2/token"
54
-
55
- dt_oauth_clientid="<YOUR-CLIENT-ID>"
56
- dt_oauth_clientsecret="<YOUR-CLIENT-SECRET>"
57
- dt_oauth_scope="<YOUR-ACCESS-SCOPE>"
58
-
59
- dt_tenant="<YOUR-TENANT-ID>"
60
- grail_apiurl="https://<YOUR-TENANT-ID>.live.dynatrace.com/api/v2/dql/query"
61
- ```
62
-
63
- The ```<config_prefix>``` is **optional** to be used if you have multiple configs stored in your .env file like e.g.
64
-
65
- ```
66
- dt_config_prefix="DEV"
67
-
68
- DEV_dt_oauth_url="https://sso.dynatrace.com/sso/oauth2/token"
69
- DEV_dt_oauth_clientid="<YOUR-DEV-CLIENT-ID>"
70
- DEV_dt_oauth_clientsecret="<YOUR-DEV-CLIENT-SECRET>"
71
- DEV_dt_oauth_scope="<YOUR-DEV-ACCESS-SCOPE>"
72
- DEV_dt_tenant="<YOUR-DEV-TENANT-ID>"
73
- DEV_grail_apiurl="https://<YOUR-DEV-TENANT-ID>.apps.dynatracelabs.com/platform/storage/query/v1/"
74
-
75
- PROD_dt_oauth_url="https://sso.dynatrace.com/sso/oauth2/token"
76
- PROD_dt_oauth_clientid="<YOUR-PROD-CLIENT-ID>"
77
- PROD_dt_oauth_clientsecret="<YOUR-PROD-CLIENT-SECRET>"
78
- PROD_dt_oauth_scope="<YOUR-PROD-ACCESS-SCOPE>"
79
- PROD_dt_tenant="<YOUR-PROD-TENANT-ID>"
80
- PROD_grail_apiurl="https://<YOUR-PROD-TENANT-ID>.apps.dynatracelabs.com/platform/storage/query/v1/"
81
-
82
- ```
83
-
84
- With the parameter ```dt_config_prefix```, you set the default config prefix used, if %auth_grail parameter ```<config_prefix>``` is not provided.
85
-
86
- For more details on how to setup API oauth clients in Dynatrace see [Configure and manage account API OAuth clients
87
- ](https://www.dynatrace.com/support/help/how-to-use-dynatrace/account-management/identity-access-management/account-api-oauth)
88
-
1
+ # Dqlmagic
2
+
3
+ An IPython magic function allowing to use DQL in your notebooks.
4
+
5
+ Dynatrace Query Language (DQL) is a powerful tool to explore your data and discover patterns, identify anomalies and outliers, create statistical modeling, and more based on data stored in Dynatrace Grail storage.
6
+
7
+ Dqlmagic makes DQL queries available to be used in jupyter notebooks.
8
+
9
+ ## Available magic functions
10
+
11
+ ### %%dql or %dql
12
+ Executes a DQL query and returns the queried records as json array.
13
+
14
+ ### Example 1
15
+ Query in code-cell..
16
+ ```
17
+ %%dql
18
+ fetch logs
19
+ | limit 10
20
+ ```
21
+ .. and use result in another code cell:
22
+ ```
23
+ import pandas as pd
24
+
25
+ #put result into a dataframe
26
+ df = pd.DataFrame(_dql_result)
27
+ df.head()
28
+ ```
29
+ **Note:**
30
+ By default ``%%dql`` writes into ``_dql_result``. You can optionally customize the target objects name to configure an alternative name like this:
31
+ ```
32
+ %%dql my_result
33
+ fetch logs | limit 10
34
+ ```
35
+
36
+ ### Example 2 - Inline Query
37
+ ```
38
+ import pandas as pd
39
+
40
+ res = %dql fetch logs | limit 10
41
+ df = pd.DataFrame(res)
42
+ df.head()
43
+ ```
44
+
45
+ ### %dql_raw and %%dql_raw
46
+ Same as ```%dql``` or ```%%dql```, but returns instead of the result records the full API response json
47
+
48
+ ### %auth_grail <config_prefix>
49
+ Inline function connecting to the grail cluster.
50
+
51
+ Reads connection parameters from .env file:
52
+ ```
53
+ dt_oauth_url="https://sso.dynatrace.com/sso/oauth2/token"
54
+
55
+ dt_oauth_clientid="<YOUR-CLIENT-ID>"
56
+ dt_oauth_clientsecret="<YOUR-CLIENT-SECRET>"
57
+ dt_oauth_scope="<YOUR-ACCESS-SCOPE>"
58
+
59
+ dt_tenant="<YOUR-TENANT-ID>"
60
+ grail_apiurl="https://<YOUR-TENANT-ID>.live.dynatrace.com/api/v2/dql/query"
61
+ ```
62
+
63
+ The ```<config_prefix>``` is **optional** to be used if you have multiple configs stored in your .env file like e.g.
64
+
65
+ ```
66
+ dt_config_prefix="DEV"
67
+
68
+ DEV_dt_oauth_url="https://sso.dynatrace.com/sso/oauth2/token"
69
+ DEV_dt_oauth_clientid="<YOUR-DEV-CLIENT-ID>"
70
+ DEV_dt_oauth_clientsecret="<YOUR-DEV-CLIENT-SECRET>"
71
+ DEV_dt_oauth_scope="<YOUR-DEV-ACCESS-SCOPE>"
72
+ DEV_dt_tenant="<YOUR-DEV-TENANT-ID>"
73
+ DEV_grail_apiurl="https://<YOUR-DEV-TENANT-ID>.apps.dynatracelabs.com/platform/storage/query/v1/"
74
+
75
+ PROD_dt_oauth_url="https://sso.dynatrace.com/sso/oauth2/token"
76
+ PROD_dt_oauth_clientid="<YOUR-PROD-CLIENT-ID>"
77
+ PROD_dt_oauth_clientsecret="<YOUR-PROD-CLIENT-SECRET>"
78
+ PROD_dt_oauth_scope="<YOUR-PROD-ACCESS-SCOPE>"
79
+ PROD_dt_tenant="<YOUR-PROD-TENANT-ID>"
80
+ PROD_grail_apiurl="https://<YOUR-PROD-TENANT-ID>.apps.dynatracelabs.com/platform/storage/query/v1/"
81
+
82
+ ```
83
+
84
+ With the parameter ```dt_config_prefix```, you set the default config prefix used, if %auth_grail parameter ```<config_prefix>``` is not provided.
85
+
86
+ For more details on how to setup API oauth clients in Dynatrace see [Configure and manage account API OAuth clients
87
+ ](https://www.dynatrace.com/support/help/how-to-use-dynatrace/account-management/identity-access-management/account-api-oauth)
88
+
89
89
  For more details on .env file see [How to NOT embedded credential in Jupyter notebook](https://yuthakarn.medium.com/how-to-not-show-credential-in-jupyter-notebook-c349f9278466) or [python-dotenv](https://pypi.org/project/python-dotenv/)
File without changes
File without changes