scrapely-python 0.1.49__tar.gz → 0.1.50__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 (85) hide show
  1. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/CHANGELOG.md +4 -0
  2. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/PKG-INFO +1 -1
  3. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/pyproject.toml +1 -1
  4. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/__init__.py +1 -1
  5. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/charging.py +34 -11
  6. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/pricing_types.py +6 -1
  7. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely_python.egg-info/PKG-INFO +1 -1
  8. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/LICENSE +0 -0
  9. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/LICENSE-APACHE +0 -0
  10. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/MANIFEST.in +0 -0
  11. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/NOTICE +0 -0
  12. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/README.md +0 -0
  13. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/setup.cfg +0 -0
  14. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/_browser_locations.py +0 -0
  15. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/actor.py +0 -0
  16. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/browser_configuration.py +0 -0
  17. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/cdp_retry.py +0 -0
  18. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/charging_client.py +0 -0
  19. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/configuration.py +0 -0
  20. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/crypto/__init__.py +0 -0
  21. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/crypto/_secrets.py +0 -0
  22. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/errors.py +0 -0
  23. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/events/__init__.py +0 -0
  24. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/events/_types.py +0 -0
  25. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/events/event_manager.py +0 -0
  26. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/__init__.py +0 -0
  27. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/_capture.py +0 -0
  28. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/_client.py +0 -0
  29. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/_compat.py +0 -0
  30. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/_detect.py +0 -0
  31. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/_headers.py +0 -0
  32. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/_options.py +0 -0
  33. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/_policy.py +0 -0
  34. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/_profiles.py +0 -0
  35. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/_response.py +0 -0
  36. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/_stats.py +0 -0
  37. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/_transport.py +0 -0
  38. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/http/profiles.json +0 -0
  39. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/log.py +0 -0
  40. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/patch_browser_pool.py +0 -0
  41. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/proxy_configuration.py +0 -0
  42. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/py.typed +0 -0
  43. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/request_loaders/__init__.py +0 -0
  44. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/request_loaders/_scrapely_request_list.py +0 -0
  45. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/resume_dedupe.py +0 -0
  46. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/__init__.py +0 -0
  47. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/_actor_runner.py +0 -0
  48. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/_async_thread.py +0 -0
  49. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/_logging_config.py +0 -0
  50. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/_serialization.py +0 -0
  51. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/_warnings.py +0 -0
  52. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/extensions/__init__.py +0 -0
  53. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/extensions/_graceful_stop.py +0 -0
  54. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/extensions/_httpcache.py +0 -0
  55. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/middlewares/__init__.py +0 -0
  56. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/middlewares/apify_proxy.py +0 -0
  57. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/pipelines/__init__.py +0 -0
  58. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/pipelines/actor_dataset_push.py +0 -0
  59. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/requests.py +0 -0
  60. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/scheduler.py +0 -0
  61. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/scrapy/utils.py +0 -0
  62. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/solver.py +0 -0
  63. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/__init__.py +0 -0
  64. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/_file_system/__init__.py +0 -0
  65. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/_file_system/_key_value_store_client.py +0 -0
  66. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/_file_system/_storage_client.py +0 -0
  67. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/_metadata.py +0 -0
  68. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/api_client.py +0 -0
  69. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/client.py +0 -0
  70. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/patch_storage.py +0 -0
  71. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/scrapely_dataset_client.py +0 -0
  72. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/scrapely_kvs_client.py +0 -0
  73. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/scrapely_rq_client.py +0 -0
  74. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/scrapely_storage_client.py +0 -0
  75. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/smart_scrapely_storage_client.py +0 -0
  76. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/types.py +0 -0
  77. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage/utils.py +0 -0
  78. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storage_clients/__init__.py +0 -0
  79. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/storages/__init__.py +0 -0
  80. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/types.py +0 -0
  81. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely/webhook.py +0 -0
  82. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely_python.egg-info/SOURCES.txt +0 -0
  83. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely_python.egg-info/dependency_links.txt +0 -0
  84. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely_python.egg-info/requires.txt +0 -0
  85. {scrapely_python-0.1.49 → scrapely_python-0.1.50}/src/scrapely_python.egg-info/top_level.txt +0 -0
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ## [0.1.50] - 2026-11-13
8
+
9
+ - **A charge accepted in full no longer reports the limit as reached.** `ChargeResult.event_charge_limit_reached` (from `Actor.charge()`, `Actor.push_data()` and `push_data(rows, charges={...})`) was `True` whenever the room left under `maxTotalChargeUsd` was below one more event, even when nothing had been refused. Actors stop on it and end with "stopped because the maximum charge for this run was reached", which the SDK words as "Stopped: reached the maximum charge you set ($0.05)", so a run that had saved everything it was asked for said it had been stopped by its maximum charge. It is now `True` only once the limit really refused or cut a charge or dropped rows; such a run ends with its own status message, and a run with more to do gets `True` from its next charge or push, which is refused. A charged push to a named dataset that the budget trims now also reports it. `chargeable_within_limit`, `calculate_max_event_charge_count_within_limit()` and `is_charge_limit_reached()` are unchanged. Charging is unchanged.
10
+
7
11
  ## [0.1.49] - 2026-11-13
8
12
 
9
13
  - **The actor-start event is never counted as a saved item when the stop reason is guessed.** The platform now includes the actor start it bills in `ACTOR_CHARGED_EVENT_COUNTS`, so the room left under the maximum charge leaves its price out. When the platform does not say which limit stopped a run, the SDK guesses it from the charged counts; `scrapely-actor-start` / `apify-actor-start` no longer count there, so a run with an item limit of 1 that the start alone stopped is reported as stopped at the maximum charge (`get_charge_limit_message()`), not at the item limit. Charging is unchanged.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scrapely-python
3
- Version: 0.1.49
3
+ Version: 0.1.50
4
4
  Summary: Scrapely Python SDK - A toolkit for building Actors on the Scrapely platform
5
5
  Author-email: Scrapely <hello@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.49"
7
+ version = "0.1.50"
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"
@@ -325,7 +325,7 @@ if TYPE_CHECKING: # Static analysers and IDEs see the lazy names as plain impor
325
325
  )
326
326
  from .webhook import Webhook, WebhookEventType
327
327
 
328
- __version__ = '0.1.49'
328
+ __version__ = '0.1.50'
329
329
  __all__ = [
330
330
  # Core
331
331
  'Actor',
@@ -568,6 +568,26 @@ class ChargingManager:
568
568
  """The platform accepted fewer events than asked: record which limit cut it."""
569
569
  self._mark_charge_limit_hit(self._last_limited_by, self._last_limit_max_items)
570
570
 
571
+ def _limit_reported(self, event_name: Optional[str] = None) -> bool:
572
+ """``event_charge_limit_reached`` for a charge or push that the limit did not cut.
573
+
574
+ True only once a limit of this run really refused or cut a charge or
575
+ dropped rows, and (for ``event_name``) not one more such event fits.
576
+ A charge that is accepted in full but leaves less than one more event
577
+ of room reports False: the run has not been stopped by its limit, and
578
+ an Actor that already has everything it was asked for ends with its
579
+ own status message instead of "stopped because the maximum charge
580
+ was reached". If it does go on, its next charge or push is refused,
581
+ and that result reports True. ``chargeable_within_limit``,
582
+ ``calculate_max_event_charge_count_within_limit()`` and
583
+ ``is_charge_limit_reached()`` still tell how much room is left.
584
+ """
585
+ if not self._charge_limit_hit:
586
+ return False
587
+ if event_name is None:
588
+ return True
589
+ return self._is_event_limit_reached(event_name)
590
+
571
591
  def _max_items_setting(self) -> Optional[int]:
572
592
  """The run's item limit: as the platform reported it, else ACTOR_MAX_PAID_DATASET_ITEMS."""
573
593
  if self._charge_limit_max_items is not None:
@@ -646,6 +666,7 @@ class ChargingManager:
646
666
  """Count rows dropped because of the limit; warn on the first one only."""
647
667
  if count <= 0:
648
668
  return
669
+ self._mark_charge_limit_hit()
649
670
  if not self._refused_default_dataset_items:
650
671
  name = self._limit_name()
651
672
  logger.warning(
@@ -1428,7 +1449,7 @@ class ChargingManager:
1428
1449
  result = ChargeResult(
1429
1450
  chargeable_within_limit=self._compute_chargeable(),
1430
1451
  charged_count=chargeable_count,
1431
- event_charge_limit_reached=self._is_event_limit_reached(event_name),
1452
+ event_charge_limit_reached=self._limit_reported(event_name),
1432
1453
  )
1433
1454
 
1434
1455
  # Record charge with the platform.
@@ -1462,7 +1483,7 @@ class ChargingManager:
1462
1483
  result = ChargeResult(
1463
1484
  chargeable_within_limit=self._compute_chargeable(),
1464
1485
  charged_count=chargeable_count,
1465
- event_charge_limit_reached=self._is_event_limit_reached(event_name),
1486
+ event_charge_limit_reached=True,
1466
1487
  )
1467
1488
  self._sync_platform_budget()
1468
1489
  if self._max_total_charge_usd is not None and self._platform_other_usd > 0:
@@ -1471,7 +1492,7 @@ class ChargingManager:
1471
1492
  chargeable_within_limit=self._compute_chargeable(),
1472
1493
  charged_count=result.charged_count,
1473
1494
  event_charge_limit_reached=result.event_charge_limit_reached
1474
- or self._is_event_limit_reached(event_name),
1495
+ or self._limit_reported(event_name),
1475
1496
  )
1476
1497
  else:
1477
1498
  # Not confirmed: keep a durable copy so a crash before the next
@@ -1969,7 +1990,7 @@ async def _skip_saved_rows(
1969
1990
  result = ChargeResult(
1970
1991
  chargeable_within_limit=charging_manager.compute_chargeable(),
1971
1992
  charged_count=0,
1972
- event_charge_limit_reached=charging_manager.is_charge_limit_reached(),
1993
+ event_charge_limit_reached=charging_manager._limit_reported(),
1973
1994
  )
1974
1995
  stored = max(0, result.charged_count)
1975
1996
  n = dedupe.commit(skipped, pushed[:stored])
@@ -2033,7 +2054,8 @@ async def _push_data_and_charge_one(
2033
2054
  # budget cap stores only the rows that are actually charged.
2034
2055
  # Rows the Actor already paid for with an earlier charge() (charge first,
2035
2056
  # then a plain push) are still stored: see ChargingManager._take_unpaid_rows.
2036
- # The result still reports the limit, so the Actor stops after them.
2057
+ # The result reports the limit once it refused something (these rows or
2058
+ # an earlier charge), so the Actor stops after them; see _limit_reported.
2037
2059
  unpaid_past_limit = False
2038
2060
  if (
2039
2061
  is_ppe
@@ -2041,7 +2063,6 @@ async def _push_data_and_charge_one(
2041
2063
  and items
2042
2064
  and not _push_is_paid_per_item(charging_manager, event_name, resolved_event)
2043
2065
  ):
2044
- unpaid_past_limit = charging_manager.is_charge_limit_reached()
2045
2066
  allowed = charging_manager._take_unpaid_rows(len(items))
2046
2067
  if allowed < len(items):
2047
2068
  charging_manager._note_refused_default_dataset_items(len(items) - allowed)
@@ -2052,6 +2073,7 @@ async def _push_data_and_charge_one(
2052
2073
  event_charge_limit_reached=True,
2053
2074
  )
2054
2075
  items = items[:allowed]
2076
+ unpaid_past_limit = charging_manager._limit_reported()
2055
2077
 
2056
2078
  limited_count = len(items)
2057
2079
  if is_ppe and resolved_event:
@@ -2064,10 +2086,11 @@ async def _push_data_and_charge_one(
2064
2086
  )
2065
2087
 
2066
2088
  limited_items = items[:limited_count] if limited_count < len(items) else items
2067
- if is_ppe and is_default_dataset and limited_count < len(items):
2068
- # Rows beyond what the budget can pay for are dropped.
2089
+ if is_ppe and limited_count < len(items):
2090
+ # Rows beyond what the budget can pay for are dropped (any dataset).
2069
2091
  charging_manager._mark_charge_limit_hit(CHARGE_LIMIT_MAX_CHARGE)
2070
- charging_manager._note_refused_default_dataset_items(len(items) - limited_count)
2092
+ if is_default_dataset:
2093
+ charging_manager._note_refused_default_dataset_items(len(items) - limited_count)
2071
2094
 
2072
2095
  if not limited_items:
2073
2096
  return ChargeResult(
@@ -2570,7 +2593,7 @@ async def _push_data_with_charges_one(
2570
2593
  return ChargeResult(
2571
2594
  chargeable_within_limit=charging_manager.compute_chargeable(),
2572
2595
  charged_count=len(kept),
2573
- event_charge_limit_reached=len(kept) < len(rows_in) or charging_manager.is_charge_limit_reached(),
2596
+ event_charge_limit_reached=len(kept) < len(rows_in) or charging_manager._limit_reported(),
2574
2597
  covered_counts=covered_counts(),
2575
2598
  )
2576
2599
 
@@ -2579,10 +2602,10 @@ async def _unpaid_push_locked(
2579
2602
  charging_manager: ChargingManager, rows: List[Dict[str, Any]], is_default_dataset: bool, push_fn: Any
2580
2603
  ) -> ChargeResult:
2581
2604
  """A push whose rows carry no priced event (caller holds the operation lock)."""
2582
- past_limit = charging_manager.is_charge_limit_reached()
2583
2605
  allowed = charging_manager._take_unpaid_rows(len(rows)) if is_default_dataset else len(rows)
2584
2606
  if allowed < len(rows):
2585
2607
  charging_manager._note_refused_default_dataset_items(len(rows) - allowed)
2608
+ past_limit = charging_manager._limit_reported()
2586
2609
  if allowed > 0:
2587
2610
  await _gated_push(push_fn, rows[:allowed])
2588
2611
  return ChargeResult(
@@ -124,7 +124,12 @@ class ChargeResult(BaseModel):
124
124
  )
125
125
  event_charge_limit_reached: bool = Field(
126
126
  alias='eventChargeLimitReached',
127
- description='If true, no more events of this type can be charged within the limit.'
127
+ description=(
128
+ 'If true, a limit of the run (maxTotalChargeUsd, maxItems, the account balance) refused or '
129
+ 'cut a charge or dropped rows, and no more events of this type can be charged: stop. A '
130
+ 'charge accepted in full that leaves less than one more event of room reports False (the '
131
+ 'next charge or push is refused and reports True); chargeable_within_limit tells the room left.'
132
+ )
128
133
  )
129
134
  covered_counts: Dict[str, int] = Field(
130
135
  default_factory=dict,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scrapely-python
3
- Version: 0.1.49
3
+ Version: 0.1.50
4
4
  Summary: Scrapely Python SDK - A toolkit for building Actors on the Scrapely platform
5
5
  Author-email: Scrapely <hello@scrape.ly>
6
6
  License-Expression: MIT AND Apache-2.0