scrapely-python 0.1.9__tar.gz → 0.1.10__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 (67) hide show
  1. {scrapely_python-0.1.9/src/scrapely_python.egg-info → scrapely_python-0.1.10}/PKG-INFO +1 -1
  2. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/pyproject.toml +1 -1
  3. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/__init__.py +1 -1
  4. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/charging.py +3 -1
  5. {scrapely_python-0.1.9 → scrapely_python-0.1.10/src/scrapely_python.egg-info}/PKG-INFO +1 -1
  6. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_charging_parity.py +38 -0
  7. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_charging_pending.py +2 -1
  8. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/LICENSE +0 -0
  9. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/LICENSE-APACHE +0 -0
  10. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/NOTICE +0 -0
  11. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/README.md +0 -0
  12. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/setup.cfg +0 -0
  13. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/_browser_locations.py +0 -0
  14. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/actor.py +0 -0
  15. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/browser_configuration.py +0 -0
  16. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/cdp_retry.py +0 -0
  17. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/charging_client.py +0 -0
  18. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/configuration.py +0 -0
  19. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/crypto/__init__.py +0 -0
  20. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/crypto/_secrets.py +0 -0
  21. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/errors.py +0 -0
  22. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/events/__init__.py +0 -0
  23. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/events/_types.py +0 -0
  24. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/events/event_manager.py +0 -0
  25. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/log.py +0 -0
  26. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/patch_browser_pool.py +0 -0
  27. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/pricing_types.py +0 -0
  28. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/proxy_configuration.py +0 -0
  29. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/py.typed +0 -0
  30. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/request_loaders/__init__.py +0 -0
  31. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/request_loaders/_scrapely_request_list.py +0 -0
  32. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/__init__.py +0 -0
  33. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/_file_system/__init__.py +0 -0
  34. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/_file_system/_key_value_store_client.py +0 -0
  35. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/_file_system/_storage_client.py +0 -0
  36. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/_metadata.py +0 -0
  37. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/api_client.py +0 -0
  38. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/client.py +0 -0
  39. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/patch_storage.py +0 -0
  40. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/scrapely_dataset_client.py +0 -0
  41. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/scrapely_kvs_client.py +0 -0
  42. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/scrapely_rq_client.py +0 -0
  43. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/scrapely_storage_client.py +0 -0
  44. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/smart_scrapely_storage_client.py +0 -0
  45. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/types.py +0 -0
  46. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage/utils.py +0 -0
  47. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storage_clients/__init__.py +0 -0
  48. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/storages/__init__.py +0 -0
  49. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/types.py +0 -0
  50. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely/webhook.py +0 -0
  51. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely_python.egg-info/SOURCES.txt +0 -0
  52. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely_python.egg-info/dependency_links.txt +0 -0
  53. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely_python.egg-info/requires.txt +0 -0
  54. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/src/scrapely_python.egg-info/top_level.txt +0 -0
  55. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_api_client_retries.py +0 -0
  56. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_apify_parity.py +0 -0
  57. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_browser_configuration.py +0 -0
  58. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_cdp_retry.py +0 -0
  59. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_charge_retries.py +0 -0
  60. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_input_proxy_aliases.py +0 -0
  61. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_parity.py +0 -0
  62. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_patch_browser_pool.py +0 -0
  63. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_proxy_configuration.py +0 -0
  64. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_run_control.py +0 -0
  65. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_secrets.py +0 -0
  66. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_storage.py +0 -0
  67. {scrapely_python-0.1.9 → scrapely_python-0.1.10}/tests/test_terminal_status_message.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scrapely-python
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: Scrapely Python SDK - A toolkit for building Actors on the Scrapely platform
5
5
  Author-email: Scrapely <support@scrape.ly>
6
6
  License-Expression: MIT AND Apache-2.0
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "scrapely-python"
7
- version = "0.1.9"
7
+ version = "0.1.10"
8
8
  description = "Scrapely Python SDK - A toolkit for building Actors on the Scrapely platform"
9
9
  readme = "README.md"
10
10
  license = "MIT AND Apache-2.0"
@@ -132,7 +132,7 @@ from .errors import (
132
132
  raise_for_status,
133
133
  )
134
134
 
135
- __version__ = '0.1.9'
135
+ __version__ = '0.1.10'
136
136
  __all__ = [
137
137
  # Core
138
138
  'Actor',
@@ -1333,7 +1333,9 @@ async def push_data_and_charge(
1333
1333
  raise
1334
1334
  return ChargeResult(
1335
1335
  chargeable_within_limit=charging_manager.compute_chargeable(),
1336
- charged_count=accepted_for_items * len(results) if results else 0,
1336
+ # Rows charged, as Apify reports it for the pushed event; the
1337
+ # implicit default-dataset event is not counted on top.
1338
+ charged_count=accepted_for_items,
1337
1339
  event_charge_limit_reached=any(
1338
1340
  result.event_charge_limit_reached for result in results
1339
1341
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scrapely-python
3
- Version: 0.1.9
3
+ Version: 0.1.10
4
4
  Summary: Scrapely Python SDK - A toolkit for building Actors on the Scrapely platform
5
5
  Author-email: Scrapely <support@scrape.ly>
6
6
  License-Expression: MIT AND Apache-2.0
@@ -338,3 +338,41 @@ async def test_local_mode_never_posts_charges_despite_client_and_run_id() -> Non
338
338
  # Flushing must not attempt any remote POST either.
339
339
  assert await mgr.flush_pending() == 0
340
340
  assert client.post_calls == []
341
+
342
+
343
+ @pytest.mark.asyncio
344
+ async def test_push_data_with_explicit_event_reports_rows_not_rows_times_events() -> None:
345
+ """charged_count is the number of rows charged, not rows x events.
346
+
347
+ With an explicit event on the default dataset the SDK also charges the
348
+ (unpriced) default-dataset-item event. Apify returns the explicit event's
349
+ count; summing both reported twice the rows pushed.
350
+ """
351
+ from scrapely.charging import push_data_and_charge
352
+
353
+ pricing = '{"pricingModel": "PAY_PER_EVENT", "pricingPerEvent": {"actorChargeEvents": {"profile": {"eventPriceUsd": 0.001, "eventTitle": "Profile"}}}}'
354
+ config = _config_with({
355
+ 'is_at_home': False,
356
+ 'actor_pricing_info': pricing,
357
+ 'charged_event_counts': '{}',
358
+ 'max_total_charge_usd': '10',
359
+ })
360
+ mgr = ChargingManager(config, None)
361
+ await mgr.init()
362
+
363
+ pushed: List[Any] = []
364
+
365
+ async def push_fn(items: List[Any]) -> None:
366
+ pushed.extend(items)
367
+
368
+ rows = [{'i': i} for i in range(3)]
369
+ result = await push_data_and_charge(mgr, rows, 'profile', True, push_fn)
370
+
371
+ assert len(pushed) == 3
372
+ assert result.charged_count == 3
373
+ assert result.event_charge_limit_reached is False
374
+ assert mgr.get_charged_event_count('profile') == 3
375
+
376
+ # Without an explicit event the default event alone is counted once.
377
+ result2 = await push_data_and_charge(mgr, rows, None, True, push_fn)
378
+ assert result2.charged_count == 3
@@ -286,7 +286,8 @@ async def test_explicit_and_default_dataset_events_are_each_reserved_once() -> N
286
286
  )
287
287
 
288
288
  assert len(pushed) == 2
289
- assert result.charged_count == 4
289
+ # Rows charged (Apify parity), not rows x events: both events billed 2 each.
290
+ assert result.charged_count == 2
290
291
  assert mgr.get_charged_event_count('page-open') == 2
291
292
  assert mgr.get_charged_event_count('apify-default-dataset-item') == 2
292
293
  assert mgr.get_total_charged_usd() == Decimal('0.04')
File without changes