chainalysis 0.2__tar.gz → 0.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.

Potentially problematic release.


This version of chainalysis might be problematic. Click here for more details.

Files changed (35) hide show
  1. {chainalysis-0.2 → chainalysis-0.4}/PKG-INFO +2 -2
  2. {chainalysis-0.2 → chainalysis-0.4}/README.md +1 -1
  3. {chainalysis-0.2 → chainalysis-0.4}/pyproject.toml +1 -1
  4. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/sql/analytical.py +18 -13
  5. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/sql/transactional.py +7 -6
  6. {chainalysis-0.2 → chainalysis-0.4}/src/test/analytical/tests.py +57 -13
  7. {chainalysis-0.2 → chainalysis-0.4}/src/test/e2e/analytical_e2e_test.py +18 -1
  8. {chainalysis-0.2 → chainalysis-0.4}/.github/workflow.yml +0 -0
  9. {chainalysis-0.2 → chainalysis-0.4}/.gitignore +0 -0
  10. {chainalysis-0.2 → chainalysis-0.4}/.pre-commit-config.yaml +0 -0
  11. {chainalysis-0.2 → chainalysis-0.4}/.vscode/settings.json +0 -0
  12. {chainalysis-0.2 → chainalysis-0.4}/LICENCE +0 -0
  13. {chainalysis-0.2 → chainalysis-0.4}/Makefile +0 -0
  14. {chainalysis-0.2 → chainalysis-0.4}/__init__.py +0 -0
  15. {chainalysis-0.2 → chainalysis-0.4}/requirements.txt +0 -0
  16. {chainalysis-0.2 → chainalysis-0.4}/src/__init__.py +0 -0
  17. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/__init__.py +0 -0
  18. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/constants.py +0 -0
  19. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/data_solutions.py +0 -0
  20. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/sql/__init__.py +0 -0
  21. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/sql/sql.py +0 -0
  22. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/util_functions/check_list_type.py +0 -0
  23. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/util_functions/exceptions.py +0 -0
  24. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/util_functions/requests.py +0 -0
  25. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/utils/__init__.py +0 -0
  26. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/utils/stringify.py +0 -0
  27. {chainalysis-0.2 → chainalysis-0.4}/src/chainalysis/utils/utils.py +0 -0
  28. {chainalysis-0.2 → chainalysis-0.4}/src/test/__init__.py +0 -0
  29. {chainalysis-0.2 → chainalysis-0.4}/src/test/_requests/__init__.py +0 -0
  30. {chainalysis-0.2 → chainalysis-0.4}/src/test/_requests/tests.py +0 -0
  31. {chainalysis-0.2 → chainalysis-0.4}/src/test/analytical/__init__.py +0 -0
  32. {chainalysis-0.2 → chainalysis-0.4}/src/test/transactional/__init__.py +0 -0
  33. {chainalysis-0.2 → chainalysis-0.4}/src/test/transactional/tests.py +0 -0
  34. {chainalysis-0.2 → chainalysis-0.4}/src/test/utils/__init__.py +0 -0
  35. {chainalysis-0.2 → chainalysis-0.4}/src/test/utils/tests.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: chainalysis
3
- Version: 0.2
3
+ Version: 0.4
4
4
  Summary: SDK functions for users to query Data Solutions databases.
5
5
  Project-URL: Homepage, https://github.com/TransposeData/chainalysis-data-solutions-python-sdk
6
6
  Author-email: "Rah Tarar (musa-tarar)" <musa.nishat@chainalysis.com>, "Kurt Bugbee (krtbgb)" <kurt.bugbee@chainalysis.com>
@@ -27,7 +27,7 @@ See the latest documentation on all available classes and methods at our wiki pa
27
27
  To install the SDK, run the following command in bash.
28
28
 
29
29
  ```bash
30
- pip install chainalysis==0.2
30
+ pip install --upgrade chainalysis
31
31
  ```
32
32
 
33
33
  ## Getting Started
@@ -9,7 +9,7 @@ See the latest documentation on all available classes and methods at our wiki pa
9
9
  To install the SDK, run the following command in bash.
10
10
 
11
11
  ```bash
12
- pip install chainalysis==0.2
12
+ pip install --upgrade chainalysis
13
13
  ```
14
14
 
15
15
  ## Getting Started
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
6
6
 
7
7
  [project]
8
8
  name = "chainalysis"
9
- version = "0.2"
9
+ version = "0.4"
10
10
  authors = [
11
11
  { name = "Rah Tarar (musa-tarar)", email = "musa.nishat@chainalysis.com" },
12
12
  { name = "Kurt Bugbee (krtbgb)", email = "kurt.bugbee@chainalysis.com" },
@@ -29,18 +29,6 @@ class Analytical:
29
29
  """
30
30
 
31
31
  self.api_key = api_key
32
- self._status_code = 0
33
- self.results = []
34
- self._stats = {}
35
- self.json_response = {}
36
- self.dataframe_data = None
37
- self._status = "error"
38
- self.error_message = ""
39
- self.error_details = ""
40
- self.next_url = None
41
- self._total_pages = 0
42
- self.query_id = None
43
- self.exception = UnhandledException()
44
32
 
45
33
  def __call__(
46
34
  self,
@@ -66,7 +54,7 @@ class Analytical:
66
54
  :type query: str
67
55
  :param parameters: A dictionary of parameters to be used in the query.
68
56
  :type parameters: dict[str], optional
69
- :param polling_interval_sec: The interval in seconds between status checks.
57
+ :param polling_interval_sec: The interval in seconds between status checks. The minimum value is 5 seconds.
70
58
  :type polling_interval_sec: int, optional
71
59
  :param autopaginate: Whether to automatically full results instead of individual pages.
72
60
  :type autopaginate: bool, optional
@@ -74,6 +62,22 @@ class Analytical:
74
62
  :rtype: Analytical
75
63
  """
76
64
 
65
+ self._status_code = 0
66
+ self.results = []
67
+ self._stats = {}
68
+ self.json_response = {}
69
+ self.dataframe_data = None
70
+ self._status = "error"
71
+ self.error_message = ""
72
+ self.error_details = ""
73
+ self.next_url = None
74
+ self._total_pages = 0
75
+ self.query_id = None
76
+ self.exception = UnhandledException()
77
+
78
+ if polling_interval_sec < 5:
79
+ polling_interval_sec = 5
80
+
77
81
  query_execution_url = (
78
82
  f"{BASE_URL['base_url']}/{ANALYTICAL_ENDPOINTS['async_query_execution']}"
79
83
  )
@@ -143,6 +147,7 @@ class Analytical:
143
147
  current_page += 1
144
148
  else:
145
149
  raise _next_page.exception
150
+ pbar.update(1) # Update the progress bar to 100%
146
151
  self.results = results
147
152
  self.next_url = None
148
153
  except DataSolutionsSDKException as e:
@@ -26,12 +26,6 @@ class Transactional:
26
26
  :type api_key: str
27
27
  """
28
28
  self.api_key = api_key
29
- self._status_code = 0
30
- self.results = {}
31
- self._stats = {}
32
- self.json_response = {}
33
- self._status = "error"
34
- self.dataframe_data = None
35
29
 
36
30
  def __call__(
37
31
  self, query: str, parameters: dict[str, str] = {}, options: dict[str, str] = {}
@@ -49,6 +43,13 @@ class Transactional:
49
43
  :rtype: Transactional
50
44
  """
51
45
 
46
+ self._status_code = 0
47
+ self.results = {}
48
+ self._stats = {}
49
+ self.json_response = {}
50
+ self._status = "error"
51
+ self.dataframe_data = None
52
+
52
53
  query_execution_url = (
53
54
  f"{BASE_URL['base_url']}/{TRANSACTIONAL_ENDPOINTS['query_execution']}"
54
55
  )
@@ -129,8 +129,9 @@ mocked_async_query_error_status = {
129
129
 
130
130
 
131
131
  class AnalyticalTests(unittest.TestCase):
132
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
132
133
  @patch("chainalysis.sql.analytical.issue_request")
133
- def test_successful_query(self, mocked_issue_request: Mock):
134
+ def test_successful_query(self, mocked_issue_request: Mock, mocked_sleep: Mock):
134
135
  ds = DataSolutionsClient(
135
136
  api_key="",
136
137
  )
@@ -145,7 +146,11 @@ class AnalyticalTests(unittest.TestCase):
145
146
  third_successful_response,
146
147
  )
147
148
 
148
- query_result = ds.sql.analytical("", polling_interval_sec=0, autopaginate=False)
149
+ query_result = ds.sql.analytical(
150
+ "", polling_interval_sec=10, autopaginate=False
151
+ )
152
+
153
+ mocked_sleep.assert_called_with(10)
149
154
 
150
155
  self.assertEqual(
151
156
  query_result.query_id,
@@ -182,8 +187,9 @@ class AnalyticalTests(unittest.TestCase):
182
187
  200,
183
188
  )
184
189
 
190
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
185
191
  @patch("chainalysis.sql.analytical.issue_request")
186
- def test_missing_query_id(self, mocked_issue_request: Mock):
192
+ def test_missing_query_id(self, mocked_issue_request: Mock, mocked_sleep: Mock):
187
193
  ds = DataSolutionsClient(
188
194
  api_key="",
189
195
  )
@@ -193,8 +199,9 @@ class AnalyticalTests(unittest.TestCase):
193
199
  with self.assertRaises(DataSolutionsAPIException):
194
200
  ds.sql.analytical("", polling_interval_sec=0)
195
201
 
202
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
196
203
  @patch("chainalysis.sql.analytical.issue_request")
197
- def test_first_api_exception(self, mocked_issue_request: Mock):
204
+ def test_first_api_exception(self, mocked_issue_request: Mock, mocked_sleep: Mock):
198
205
  ds = DataSolutionsClient(
199
206
  api_key="",
200
207
  )
@@ -207,8 +214,9 @@ class AnalyticalTests(unittest.TestCase):
207
214
  polling_interval_sec=0,
208
215
  )
209
216
 
217
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
210
218
  @patch("chainalysis.sql.analytical.issue_request")
211
- def test_second_api_exception(self, mocked_issue_request: Mock):
219
+ def test_second_api_exception(self, mocked_issue_request: Mock, mocked_sleep: Mock):
212
220
  ds = DataSolutionsClient(
213
221
  api_key="",
214
222
  )
@@ -233,8 +241,11 @@ class AnalyticalTests(unittest.TestCase):
233
241
  with self.assertRaises(DataSolutionsAPIException):
234
242
  query_result.stats()
235
243
 
244
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
236
245
  @patch("chainalysis.sql.analytical.issue_request")
237
- def test_interval_server_exception(self, mocked_issue_request: Mock):
246
+ def test_interval_server_exception(
247
+ self, mocked_issue_request: Mock, mocked_sleep: Mock
248
+ ):
238
249
  ds = DataSolutionsClient(
239
250
  api_key="",
240
251
  )
@@ -259,8 +270,9 @@ class AnalyticalTests(unittest.TestCase):
259
270
  with self.assertRaises(InternalServerException):
260
271
  query_result.stats()
261
272
 
273
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
262
274
  @patch("chainalysis.sql.analytical.issue_request")
263
- def test_unhandled_exception(self, mocked_issue_request: Mock):
275
+ def test_unhandled_exception(self, mocked_issue_request: Mock, mocked_sleep: Mock):
264
276
  ds = DataSolutionsClient(
265
277
  api_key="",
266
278
  )
@@ -285,8 +297,11 @@ class AnalyticalTests(unittest.TestCase):
285
297
  with self.assertRaises(UnhandledException):
286
298
  query_result.stats()
287
299
 
300
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
288
301
  @patch("chainalysis.sql.analytical.issue_request")
289
- def test_get_next_page_successful(self, mocked_issue_request: Mock):
302
+ def test_get_next_page_successful(
303
+ self, mocked_issue_request: Mock, mocked_sleep: Mock
304
+ ):
290
305
  ds = DataSolutionsClient(
291
306
  api_key="",
292
307
  )
@@ -326,8 +341,9 @@ class AnalyticalTests(unittest.TestCase):
326
341
  final_successful_response["next"],
327
342
  )
328
343
 
344
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
329
345
  @patch("chainalysis.sql.analytical.issue_request")
330
- def test_get_next_page_error(self, mocked_issue_request: Mock):
346
+ def test_get_next_page_error(self, mocked_issue_request: Mock, mocked_sleep: Mock):
331
347
  ds = DataSolutionsClient(
332
348
  api_key="",
333
349
  )
@@ -361,8 +377,11 @@ class AnalyticalTests(unittest.TestCase):
361
377
  "error",
362
378
  )
363
379
 
380
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
364
381
  @patch("chainalysis.sql.analytical.issue_request")
365
- def test_get_next_page_with_no_next_page_error(self, mocked_issue_request: Mock):
382
+ def test_get_next_page_with_no_next_page_error(
383
+ self, mocked_issue_request: Mock, mocked_sleep: Mock
384
+ ):
366
385
  ds = DataSolutionsClient(
367
386
  api_key="",
368
387
  )
@@ -387,8 +406,9 @@ class AnalyticalTests(unittest.TestCase):
387
406
  with self.assertRaises(BadRequest):
388
407
  first_query_result.next_page()
389
408
 
409
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
390
410
  @patch("chainalysis.sql.analytical.issue_request")
391
- def test_auto_pagination(self, mocked_issue_request: Mock):
411
+ def test_auto_pagination(self, mocked_issue_request: Mock, mocked_sleep: Mock):
392
412
  """
393
413
  Test that the Analytical class can execute a query with autopagination.
394
414
  """
@@ -419,8 +439,9 @@ class AnalyticalTests(unittest.TestCase):
419
439
 
420
440
  self.assertEqual(query_result.json(), expected_results)
421
441
 
442
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
422
443
  @patch("chainalysis.sql.analytical.issue_request")
423
- def test_status_error(self, mocked_issue_request: Mock):
444
+ def test_status_error(self, mocked_issue_request: Mock, mocked_sleep: Mock):
424
445
  ds = DataSolutionsClient(
425
446
  api_key="",
426
447
  )
@@ -445,9 +466,10 @@ class AnalyticalTests(unittest.TestCase):
445
466
  "error",
446
467
  )
447
468
 
469
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
448
470
  @patch("chainalysis.sql.analytical.issue_request")
449
471
  def test_auto_pagination_errors_if_issue_request_errors(
450
- self, mocked_issue_request: Mock
472
+ self, mocked_issue_request: Mock, mocked_sleep: Mock
451
473
  ):
452
474
  ds = DataSolutionsClient(
453
475
  api_key="",
@@ -472,6 +494,28 @@ class AnalyticalTests(unittest.TestCase):
472
494
  with self.assertRaises(Exception):
473
495
  query_result.json()
474
496
 
497
+ @patch("chainalysis.sql.analytical.sleep", return_value=None)
498
+ @patch("chainalysis.sql.analytical.issue_request")
499
+ def test_polling_interval_is_updated_if_less_than_5(
500
+ self, mocked_issue_request: Mock, mocked_sleep: Mock
501
+ ):
502
+ ds = DataSolutionsClient(
503
+ api_key="",
504
+ )
505
+
506
+ first_successful_response = mocked_async_query_id_response
507
+ second_successful_response = mocked_async_query_response_1
508
+ third_successful_response = mocked_async_query_response_2
509
+
510
+ mocked_issue_request.side_effect = (
511
+ first_successful_response,
512
+ second_successful_response,
513
+ third_successful_response,
514
+ )
515
+
516
+ ds.sql.analytical("", polling_interval_sec=3, autopaginate=False)
517
+ mocked_sleep.assert_called_with(5)
518
+
475
519
 
476
520
  if __name__ == "__main__":
477
521
  unittest.main()
@@ -28,7 +28,24 @@ class AnalyticalE2eTest(unittest.TestCase):
28
28
  """
29
29
 
30
30
  query = """
31
- SELECT * FROM ethereum.category_signals LIMIT 1000000
31
+ SELECT * FROM ethereum.category_signals LIMIT 500000
32
+ """
33
+
34
+ analytical_result = Analytical(os.getenv("API_KEY")).__call__(
35
+ query=query,
36
+ autopaginate=True,
37
+ )
38
+
39
+ analytical_result.json()
40
+ analytical_result.df()
41
+
42
+ def test_execution_with_autopagination_with_one_page(self):
43
+ """
44
+ Test that the Analytical class can execute a query with autopagination.
45
+ """
46
+
47
+ query = """
48
+ SELECT * FROM ethereum.category_signals LIMIT 5
32
49
  """
33
50
 
34
51
  analytical_result = Analytical(os.getenv("API_KEY")).__call__(
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes