polly-python 3.1.0__tar.gz → 3.2.0__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 (70) hide show
  1. {polly_python-3.1.0/polly_python.egg-info → polly_python-3.2.0}/PKG-INFO +5 -4
  2. {polly_python-3.1.0 → polly_python-3.2.0}/README.md +2 -2
  3. polly_python-3.2.0/polly/__init__.py +1 -0
  4. {polly_python-3.1.0 → polly_python-3.2.0}/polly/errors.py +12 -8
  5. {polly_python-3.1.0 → polly_python-3.2.0}/polly/polly_kg.py +14 -12
  6. {polly_python-3.1.0 → polly_python-3.2.0/polly_python.egg-info}/PKG-INFO +5 -4
  7. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_kg.py +79 -76
  8. polly_python-3.1.0/polly/__init__.py +0 -1
  9. {polly_python-3.1.0 → polly_python-3.2.0}/LICENSE.md +0 -0
  10. {polly_python-3.1.0 → polly_python-3.2.0}/MANIFEST.in +0 -0
  11. {polly_python-3.1.0 → polly_python-3.2.0}/polly/analyze.py +0 -0
  12. {polly_python-3.1.0 → polly_python-3.2.0}/polly/application_error_info.py +0 -0
  13. {polly_python-3.1.0 → polly_python-3.2.0}/polly/atlas.py +0 -0
  14. {polly_python-3.1.0 → polly_python-3.2.0}/polly/auth.py +0 -0
  15. {polly_python-3.1.0 → polly_python-3.2.0}/polly/constants.py +0 -0
  16. {polly_python-3.1.0 → polly_python-3.2.0}/polly/curation.py +0 -0
  17. {polly_python-3.1.0 → polly_python-3.2.0}/polly/data_management.py +0 -0
  18. {polly_python-3.1.0 → polly_python-3.2.0}/polly/help.py +0 -0
  19. {polly_python-3.1.0 → polly_python-3.2.0}/polly/helpers.py +0 -0
  20. {polly_python-3.1.0 → polly_python-3.2.0}/polly/http_response_codes.py +0 -0
  21. {polly_python-3.1.0 → polly_python-3.2.0}/polly/index_schema_level_conversion_const.py +0 -0
  22. {polly_python-3.1.0 → polly_python-3.2.0}/polly/jobs.py +0 -0
  23. {polly_python-3.1.0 → polly_python-3.2.0}/polly/omixatlas.py +0 -0
  24. {polly_python-3.1.0 → polly_python-3.2.0}/polly/omixatlas_hlpr.py +0 -0
  25. {polly_python-3.1.0 → polly_python-3.2.0}/polly/pipelines.py +0 -0
  26. {polly_python-3.1.0 → polly_python-3.2.0}/polly/s3_utils.py +0 -0
  27. {polly_python-3.1.0 → polly_python-3.2.0}/polly/session.py +0 -0
  28. {polly_python-3.1.0 → polly_python-3.2.0}/polly/threading_utils.py +0 -0
  29. {polly_python-3.1.0 → polly_python-3.2.0}/polly/tracking.py +0 -0
  30. {polly_python-3.1.0 → polly_python-3.2.0}/polly/validation.py +0 -0
  31. {polly_python-3.1.0 → polly_python-3.2.0}/polly/validation_hlpr.py +0 -0
  32. {polly_python-3.1.0 → polly_python-3.2.0}/polly/workspaces.py +0 -0
  33. {polly_python-3.1.0 → polly_python-3.2.0}/polly_interfaces/IFiles.py +0 -0
  34. {polly_python-3.1.0 → polly_python-3.2.0}/polly_interfaces/IReporting.py +0 -0
  35. {polly_python-3.1.0 → polly_python-3.2.0}/polly_interfaces/ISchema.py +0 -0
  36. {polly_python-3.1.0 → polly_python-3.2.0}/polly_interfaces/__init__.py +0 -0
  37. {polly_python-3.1.0 → polly_python-3.2.0}/polly_python.egg-info/SOURCES.txt +0 -0
  38. {polly_python-3.1.0 → polly_python-3.2.0}/polly_python.egg-info/dependency_links.txt +0 -0
  39. {polly_python-3.1.0 → polly_python-3.2.0}/polly_python.egg-info/requires.txt +0 -0
  40. {polly_python-3.1.0 → polly_python-3.2.0}/polly_python.egg-info/top_level.txt +0 -0
  41. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/__init__.py +0 -0
  42. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/dataset.py +0 -0
  43. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/files/__init__.py +0 -0
  44. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/files/files.py +0 -0
  45. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/files/files_hlpr.py +0 -0
  46. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/polly_services_hlpr.py +0 -0
  47. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/reporting/__init__.py +0 -0
  48. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/reporting/reporting.py +0 -0
  49. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/reporting/reporting_hlpr.py +0 -0
  50. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/schema/__init__.py +0 -0
  51. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/schema/schema.py +0 -0
  52. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/schema/schema_const.py +0 -0
  53. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/schema/schema_hlpr.py +0 -0
  54. {polly_python-3.1.0 → polly_python-3.2.0}/polly_services/schema/validate_schema_hlpr.py +0 -0
  55. {polly_python-3.1.0 → polly_python-3.2.0}/pyproject.toml +0 -0
  56. {polly_python-3.1.0 → polly_python-3.2.0}/setup.cfg +0 -0
  57. {polly_python-3.1.0 → polly_python-3.2.0}/setup.py +0 -0
  58. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_constants.py +0 -0
  59. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_curation.py +0 -0
  60. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_data_management.py +0 -0
  61. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_help.py +0 -0
  62. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_helpers.py +0 -0
  63. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_jobs.py +0 -0
  64. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_omixatlas.py +0 -0
  65. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_pipelines.py +0 -0
  66. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_s3_utils.py +0 -0
  67. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_schema_ux.py +0 -0
  68. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_threading_utils.py +0 -0
  69. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_validation.py +0 -0
  70. {polly_python-3.1.0 → polly_python-3.2.0}/tests/test_workspaces.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: polly_python
3
- Version: 3.1.0
3
+ Version: 3.2.0
4
4
  Summary: Polly SDK
5
5
  Home-page: https://github.com/ElucidataInc/polly-python
6
6
  Project-URL: Documentation, https://docs.elucidata.io
@@ -31,6 +31,7 @@ Provides-Extra: testing
31
31
  Requires-Dist: black; extra == "testing"
32
32
  Requires-Dist: flake8; extra == "testing"
33
33
  Requires-Dist: pytest; extra == "testing"
34
+ Dynamic: license-file
34
35
 
35
36
  [![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)
36
37
  ![code-coverage](https://github.com/ElucidataInc/polly-python-code/blob/badges_do_not_delete/badges/badge.svg)
@@ -72,5 +73,5 @@ pip install polly-python
72
73
  If you have questions, suggestions or problems, feel free to open an issue [here](https://github.com/ElucidataInc/polly-python/issues).
73
74
 
74
75
  You can contact us at:
75
- * sabu.george@elucidata.io
76
- * yogesh.lakhotia@elucidata.io
76
+ * kapil.kumar@elucidata.io
77
+ * jainik.dedhia@elucidata.io
@@ -38,5 +38,5 @@ pip install polly-python
38
38
  If you have questions, suggestions or problems, feel free to open an issue [here](https://github.com/ElucidataInc/polly-python/issues).
39
39
 
40
40
  You can contact us at:
41
- * sabu.george@elucidata.io
42
- * yogesh.lakhotia@elucidata.io
41
+ * kapil.kumar@elucidata.io
42
+ * jainik.dedhia@elucidata.io
@@ -0,0 +1 @@
1
+ __version__ = "3.2.0"
@@ -281,12 +281,13 @@ class DatatypeNotFoundException(Exception):
281
281
 
282
282
 
283
283
  def error_handler(response):
284
- if has_error_message(response):
285
- title, detail = extract_json_api_error(response)
284
+ is_error, jsonResponse = has_error_message(response)
285
+ if is_error:
286
+ title, detail = extract_json_api_error(jsonResponse)
286
287
  if title == app_err_info.REPOSITORY_LOCKED:
287
288
  detail = app_err_info.REPOSITORY_LOCKED_DETAIL
288
289
  raise RequestException(title, detail)
289
- elif response.status_code == 401:
290
+ elif jsonResponse.status_code == 401:
290
291
  raise UnauthorizedException
291
292
 
292
293
  response.raise_for_status()
@@ -296,16 +297,19 @@ def has_error_message(response):
296
297
  try:
297
298
  for key in response.json().keys():
298
299
  if key in {"error", "errors"}:
299
- return True
300
- return False
300
+ return True, response.json()
301
+ for key in response.json()["data"].keys():
302
+ if key in {"error", "errors"}:
303
+ return True, response.json()["data"]
304
+ return False, response
301
305
  except Exception:
302
- return False
306
+ return False, response
303
307
 
304
308
 
305
309
  def extract_json_api_error(response):
306
- error = response.json().get("error")
310
+ error = response.get("error")
307
311
  if error is None:
308
- error = response.json().get("errors")[0]
312
+ error = response.get("errors")[0]
309
313
  if "title" in error:
310
314
  title = error.get("title")
311
315
  if "detail" in error:
@@ -44,7 +44,7 @@ class PollyKG:
44
44
  )
45
45
  self.session = Polly.get_session(token, env=env)
46
46
  self.polly_kg_endpoint = (
47
- f"https://apis.{self.session.env}.elucidata.io/polly-kg"
47
+ f"https://sarovar.{self.session.env}.elucidata.io/polly_kg"
48
48
  )
49
49
  if self.session.env == "polly":
50
50
  self.env_string = "prod"
@@ -72,9 +72,9 @@ class PollyKG:
72
72
  """
73
73
  try:
74
74
  response = self.session.get(f"{self.polly_kg_endpoint}/status")
75
- response.raise_for_status()
76
- print(response.json())
77
- return response.json()
75
+ error_handler(response)
76
+ print(response.json().get("data"))
77
+ return response.json().get("data")
78
78
  except requests.exceptions.HTTPError as http_err:
79
79
  if http_err.response.status_code == 404:
80
80
  raise ResourceNotFoundError("Graph not found.")
@@ -106,8 +106,8 @@ class PollyKG:
106
106
  try:
107
107
  response = self.session.get(f"{self.polly_kg_endpoint}/summary")
108
108
  error_handler(response)
109
- print(response.json())
110
- return response.json()
109
+ print(response.json().get("data"))
110
+ return response.json().get("data")
111
111
  except requests.exceptions.HTTPError as http_err:
112
112
  if http_err.response.status_code == 404:
113
113
  raise ResourceNotFoundError("Graph summary not found.")
@@ -142,14 +142,16 @@ class PollyKG:
142
142
  if not query or query == "":
143
143
  raise InvalidParameterException("query")
144
144
 
145
- payload = {"query_content": query}
145
+ payload = {
146
+ "data": {"type": "opencypher", "attributes": {"query_content": query}}
147
+ }
146
148
 
147
149
  try:
148
150
  response = self.session.post(
149
- f"{self.polly_kg_endpoint}/opencypher/query", data=json.dumps(payload)
151
+ f"{self.polly_kg_endpoint}/opencypher/query/", data=json.dumps(payload)
150
152
  )
151
153
  error_handler(response)
152
- return response.json()["results"]
154
+ return response.json()["data"]["results"]
153
155
  except requests.exceptions.HTTPError as http_err:
154
156
  if (
155
157
  http_err.response.status_code == 408
@@ -188,14 +190,14 @@ class PollyKG:
188
190
  if not query or query == "":
189
191
  raise InvalidParameterException("query")
190
192
 
191
- payload = {"query_content": query}
193
+ payload = {"data": {"type": "gremlin", "attributes": {"query_content": query}}}
192
194
 
193
195
  try:
194
196
  response = self.session.post(
195
- f"{self.polly_kg_endpoint}/gremlin/query", data=json.dumps(payload)
197
+ f"{self.polly_kg_endpoint}/gremlin/query/", data=json.dumps(payload)
196
198
  )
197
199
  error_handler(response)
198
- return response.json()["result"]
200
+ return response.json()["data"]["result"]
199
201
  except requests.exceptions.HTTPError as http_err:
200
202
  if (
201
203
  http_err.response.status_code == 408
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: polly_python
3
- Version: 3.1.0
3
+ Version: 3.2.0
4
4
  Summary: Polly SDK
5
5
  Home-page: https://github.com/ElucidataInc/polly-python
6
6
  Project-URL: Documentation, https://docs.elucidata.io
@@ -31,6 +31,7 @@ Provides-Extra: testing
31
31
  Requires-Dist: black; extra == "testing"
32
32
  Requires-Dist: flake8; extra == "testing"
33
33
  Requires-Dist: pytest; extra == "testing"
34
+ Dynamic: license-file
34
35
 
35
36
  [![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)
36
37
  ![code-coverage](https://github.com/ElucidataInc/polly-python-code/blob/badges_do_not_delete/badges/badge.svg)
@@ -72,5 +73,5 @@ pip install polly-python
72
73
  If you have questions, suggestions or problems, feel free to open an issue [here](https://github.com/ElucidataInc/polly-python/issues).
73
74
 
74
75
  You can contact us at:
75
- * sabu.george@elucidata.io
76
- * yogesh.lakhotia@elucidata.io
76
+ * kapil.kumar@elucidata.io
77
+ * jainik.dedhia@elucidata.io
@@ -2,28 +2,27 @@
2
2
  from polly.polly_kg import PollyKG
3
3
  import pytest
4
4
 
5
- # import os
5
+ import os
6
6
  from polly.errors import InvalidParameterException, RequestException
7
7
 
8
- # import polly
9
- import test_constants as test_const
10
-
11
8
  key = "POLLY_API_KEY"
12
- token = "Zjc2ZGM2YmVjNzo6ZmY2OTk0ZGVhZWQ3YWE3ZGU2OTExMTZlYTE0ZDgxMGVkZGEzYmNlZA=="
13
- response_json = test_const.WORKSPACE_RESPONSE_JSON
9
+ token = os.getenv(key)
10
+
11
+ test_key = "TEST_POLLY_API_KEY"
12
+ testpolly_token = os.getenv(test_key)
14
13
 
15
14
 
16
15
  def test_obj_initialised():
17
- assert PollyKG(token, env="testpolly") is not None
16
+ assert PollyKG(testpolly_token, env="testpolly") is not None
18
17
 
19
18
 
20
19
  def test_get_engine_status():
21
- obj = PollyKG(token, env="testpolly")
20
+ obj = PollyKG(testpolly_token, env="testpolly")
22
21
  assert dict(obj.get_engine_status()) is not None
23
22
 
24
23
 
25
24
  def test_get_graph_summary():
26
- obj = PollyKG(token, env="testpolly")
25
+ obj = PollyKG(testpolly_token, env="testpolly")
27
26
  response = obj.get_graph_summary()
28
27
 
29
28
  assert response is not None
@@ -35,53 +34,55 @@ def test_get_graph_summary():
35
34
  def test_run_gremlin_query_success(mocker):
36
35
  # Mocked response from API
37
36
  mocked_response = {
38
- "requestId": "ab81155d-9f64-4717-a1e3-4e70bf5e6dff",
39
- "status": {
40
- "message": "",
41
- "code": 200,
42
- "attributes": {"@type": "g:Map", "@value": []},
43
- },
44
- "result": {
45
- "data": {
46
- "@type": "g:List",
47
- "@value": [
48
- {
49
- "@type": "g:Map",
50
- "@value": [
51
- "id",
52
- "9796",
53
- "properties",
54
- {
55
- "@type": "g:Map",
56
- "@value": [
57
- "name",
58
- {"@type": "g:List", "@value": ["PHYHIP"]},
59
- ],
60
- },
61
- ],
62
- },
63
- {
64
- "@type": "g:Map",
65
- "@value": [
66
- "id",
67
- "5297",
68
- "properties",
69
- {
70
- "@type": "g:Map",
71
- "@value": [
72
- "name",
73
- {"@type": "g:List", "@value": ["PI4KA"]},
74
- ],
75
- },
76
- ],
77
- },
78
- ],
37
+ "data": {
38
+ "requestId": "ab81155d-9f64-4717-a1e3-4e70bf5e6dff",
39
+ "status": {
40
+ "message": "",
41
+ "code": 200,
42
+ "attributes": {"@type": "g:Map", "@value": []},
79
43
  },
80
- "meta": {"@type": "g:Map", "@value": []},
81
- },
44
+ "result": {
45
+ "data": {
46
+ "@type": "g:List",
47
+ "@value": [
48
+ {
49
+ "@type": "g:Map",
50
+ "@value": [
51
+ "id",
52
+ "9796",
53
+ "properties",
54
+ {
55
+ "@type": "g:Map",
56
+ "@value": [
57
+ "name",
58
+ {"@type": "g:List", "@value": ["PHYHIP"]},
59
+ ],
60
+ },
61
+ ],
62
+ },
63
+ {
64
+ "@type": "g:Map",
65
+ "@value": [
66
+ "id",
67
+ "5297",
68
+ "properties",
69
+ {
70
+ "@type": "g:Map",
71
+ "@value": [
72
+ "name",
73
+ {"@type": "g:List", "@value": ["PI4KA"]},
74
+ ],
75
+ },
76
+ ],
77
+ },
78
+ ],
79
+ },
80
+ "meta": {"@type": "g:Map", "@value": []},
81
+ },
82
+ }
82
83
  }
83
84
 
84
- obj = PollyKG(token, env="testpolly")
85
+ obj = PollyKG(testpolly_token, env="testpolly")
85
86
 
86
87
  # Test invalid query (empty query should raise an exception)
87
88
  with pytest.raises(
@@ -149,32 +150,34 @@ def test_run_gremlin_query_success(mocker):
149
150
  def test_run_opencypher_query_success(mocker):
150
151
  # Mocked response from API
151
152
  mocked_response = {
152
- "ResponseMetadata": {
153
- "HTTPStatusCode": 200,
154
- "HTTPHeaders": {
155
- "transfer-encoding": "chunked",
156
- "content-type": "application/json;charset=UTF-8",
153
+ "data": {
154
+ "ResponseMetadata": {
155
+ "HTTPStatusCode": 200,
156
+ "HTTPHeaders": {
157
+ "transfer-encoding": "chunked",
158
+ "content-type": "application/json;charset=UTF-8",
159
+ },
160
+ "RetryAttempts": 0,
157
161
  },
158
- "RetryAttempts": 0,
159
- },
160
- "results": [
161
- {
162
- "node": {
163
- "~id": "5555",
164
- "~entityType": "node",
165
- "~labels": ["Gene"],
166
- "~properties": {
167
- "EnsemblGeneID": "EEEEEEEEEEEEEEEE",
168
- "Symbol": "PPPPPPPPP",
169
- "LocusTag": "-",
170
- "Synonyms": "CCCCCCCCC",
171
- },
162
+ "results": [
163
+ {
164
+ "node": {
165
+ "~id": "5555",
166
+ "~entityType": "node",
167
+ "~labels": ["Gene"],
168
+ "~properties": {
169
+ "EnsemblGeneID": "EEEEEEEEEEEEEEEE",
170
+ "Symbol": "PPPPPPPPP",
171
+ "LocusTag": "-",
172
+ "Synonyms": "CCCCCCCCC",
173
+ },
174
+ }
172
175
  }
173
- }
174
- ],
176
+ ],
177
+ }
175
178
  }
176
179
 
177
- obj = PollyKG(token, env="testpolly")
180
+ obj = PollyKG(testpolly_token, env="testpolly")
178
181
 
179
182
  # Test invalid query (empty query should raise an exception)
180
183
  with pytest.raises(
@@ -196,6 +199,6 @@ def test_run_opencypher_query_success(mocker):
196
199
  result = obj.run_opencypher_query(query)
197
200
 
198
201
  # Expected result from mocked response
199
- expected_result = mocked_response["results"]
202
+ expected_result = mocked_response["data"]["results"]
200
203
 
201
204
  assert result == expected_result
@@ -1 +0,0 @@
1
- __version__ = "3.1.0"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes