Skip to content

Commit 4fddd6b

Browse files
feat: Align browser-pool timeout/viewport/fill-rate contract with implementation; reject save_changes on update
1 parent 0f8051d commit 4fddd6b

8 files changed

Lines changed: 48 additions & 26 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 120
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-d70be5e703da22000f3f7e76b19d5fa3e3bf8c33be2e9570bfafb5cf9d956a17.yml
3-
openapi_spec_hash: deaa8926543116d1f81d34d1e01e0c0a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-ab4e7c50c41fefd891648fa84ba0258986f192ba1bde9f42cbdf487f64c4cc27.yml
3+
openapi_spec_hash: b4bcd6557f7045ecff30b01e02d28ac5
44
config_hash: 03c7e57f268c750e2415831662e95969

src/kernel/resources/browser_pools.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ def create(
9696
9797
extensions: List of browser extensions to load into the session. Provide each by id or name.
9898
99-
fill_rate_per_minute: Percentage of the pool to fill per minute. Defaults to 10%.
99+
fill_rate_per_minute: Percentage of the pool to fill per minute. Defaults to 10. The cap is 25 for
100+
most organizations but can be raised per-organization, so only the lower bound
101+
is enforced here.
100102
101103
headless: If true, launches the browser using a headless image. Defaults to false.
102104
@@ -122,7 +124,7 @@ def create(
122124
mechanisms.
123125
124126
timeout_seconds: Default idle timeout in seconds for browsers acquired from this pool before they
125-
are destroyed. Defaults to 600 seconds if not specified
127+
are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
126128
127129
viewport: Initial browser window size in pixels with optional refresh rate. If omitted,
128130
image defaults apply (1920x1080@25). For GPU images, the default is
@@ -243,7 +245,9 @@ def update(
243245
244246
extensions: List of browser extensions to load into the session. Provide each by id or name.
245247
246-
fill_rate_per_minute: Percentage of the pool to fill per minute. Defaults to 10%.
248+
fill_rate_per_minute: Percentage of the pool to fill per minute. Defaults to 10. The cap is 25 for
249+
most organizations but can be raised per-organization, so only the lower bound
250+
is enforced here.
247251
248252
headless: If true, launches the browser using a headless image. Defaults to false.
249253
@@ -273,7 +277,7 @@ def update(
273277
mechanisms.
274278
275279
timeout_seconds: Default idle timeout in seconds for browsers acquired from this pool before they
276-
are destroyed. Defaults to 600 seconds if not specified
280+
are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
277281
278282
viewport: Initial browser window size in pixels with optional refresh rate. If omitted,
279283
image defaults apply (1920x1080@25). For GPU images, the default is
@@ -621,7 +625,9 @@ async def create(
621625
622626
extensions: List of browser extensions to load into the session. Provide each by id or name.
623627
624-
fill_rate_per_minute: Percentage of the pool to fill per minute. Defaults to 10%.
628+
fill_rate_per_minute: Percentage of the pool to fill per minute. Defaults to 10. The cap is 25 for
629+
most organizations but can be raised per-organization, so only the lower bound
630+
is enforced here.
625631
626632
headless: If true, launches the browser using a headless image. Defaults to false.
627633
@@ -647,7 +653,7 @@ async def create(
647653
mechanisms.
648654
649655
timeout_seconds: Default idle timeout in seconds for browsers acquired from this pool before they
650-
are destroyed. Defaults to 600 seconds if not specified
656+
are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
651657
652658
viewport: Initial browser window size in pixels with optional refresh rate. If omitted,
653659
image defaults apply (1920x1080@25). For GPU images, the default is
@@ -768,7 +774,9 @@ async def update(
768774
769775
extensions: List of browser extensions to load into the session. Provide each by id or name.
770776
771-
fill_rate_per_minute: Percentage of the pool to fill per minute. Defaults to 10%.
777+
fill_rate_per_minute: Percentage of the pool to fill per minute. Defaults to 10. The cap is 25 for
778+
most organizations but can be raised per-organization, so only the lower bound
779+
is enforced here.
772780
773781
headless: If true, launches the browser using a headless image. Defaults to false.
774782
@@ -798,7 +806,7 @@ async def update(
798806
mechanisms.
799807
800808
timeout_seconds: Default idle timeout in seconds for browsers acquired from this pool before they
801-
are destroyed. Defaults to 600 seconds if not specified
809+
are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
802810
803811
viewport: Initial browser window size in pixels with optional refresh rate. If omitted,
804812
image defaults apply (1920x1080@25). For GPU images, the default is

src/kernel/types/browser_pool.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ class BrowserPoolConfig(BaseModel):
3636
"""
3737

3838
fill_rate_per_minute: Optional[int] = None
39-
"""Percentage of the pool to fill per minute. Defaults to 10%."""
39+
"""Percentage of the pool to fill per minute.
40+
41+
Defaults to 10. The cap is 25 for most organizations but can be raised
42+
per-organization, so only the lower bound is enforced here.
43+
"""
4044

4145
headless: Optional[bool] = None
4246
"""If true, launches the browser using a headless image. Defaults to false."""
@@ -81,7 +85,7 @@ class BrowserPoolConfig(BaseModel):
8185
timeout_seconds: Optional[int] = None
8286
"""
8387
Default idle timeout in seconds for browsers acquired from this pool before they
84-
are destroyed. Defaults to 600 seconds if not specified
88+
are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
8589
"""
8690

8791
viewport: Optional[BrowserViewport] = None

src/kernel/types/browser_pool_create_params.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ class BrowserPoolCreateParams(TypedDict, total=False):
3535
"""
3636

3737
fill_rate_per_minute: int
38-
"""Percentage of the pool to fill per minute. Defaults to 10%."""
38+
"""Percentage of the pool to fill per minute.
39+
40+
Defaults to 10. The cap is 25 for most organizations but can be raised
41+
per-organization, so only the lower bound is enforced here.
42+
"""
3943

4044
headless: bool
4145
"""If true, launches the browser using a headless image. Defaults to false."""
@@ -80,7 +84,7 @@ class BrowserPoolCreateParams(TypedDict, total=False):
8084
timeout_seconds: int
8185
"""
8286
Default idle timeout in seconds for browsers acquired from this pool before they
83-
are destroyed. Defaults to 600 seconds if not specified
87+
are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
8488
"""
8589

8690
viewport: BrowserViewport

src/kernel/types/browser_pool_update_params.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ class BrowserPoolUpdateParams(TypedDict, total=False):
3434
"""
3535

3636
fill_rate_per_minute: int
37-
"""Percentage of the pool to fill per minute. Defaults to 10%."""
37+
"""Percentage of the pool to fill per minute.
38+
39+
Defaults to 10. The cap is 25 for most organizations but can be raised
40+
per-organization, so only the lower bound is enforced here.
41+
"""
3842

3943
headless: bool
4044
"""If true, launches the browser using a headless image. Defaults to false."""
@@ -86,7 +90,7 @@ class BrowserPoolUpdateParams(TypedDict, total=False):
8690
timeout_seconds: int
8791
"""
8892
Default idle timeout in seconds for browsers acquired from this pool before they
89-
are destroyed. Defaults to 600 seconds if not specified
93+
are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
9094
"""
9195

9296
viewport: BrowserViewport

src/kernel/types/shared/browser_viewport.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ class BrowserViewport(BaseModel):
2323
"""
2424

2525
height: int
26-
"""Browser window height in pixels."""
26+
"""Browser window height in pixels. Any positive integer is accepted."""
2727

2828
width: int
29-
"""Browser window width in pixels."""
29+
"""Browser window width in pixels. Any positive integer is accepted."""
3030

3131
refresh_rate: Optional[int] = None
3232
"""Display refresh rate in Hz.
3333
34-
If omitted, automatically determined from width and height.
34+
Any positive integer is accepted; if omitted, automatically determined from
35+
width and height.
3536
"""

src/kernel/types/shared_params/browser_viewport.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ class BrowserViewport(TypedDict, total=False):
2323
"""
2424

2525
height: Required[int]
26-
"""Browser window height in pixels."""
26+
"""Browser window height in pixels. Any positive integer is accepted."""
2727

2828
width: Required[int]
29-
"""Browser window width in pixels."""
29+
"""Browser window width in pixels. Any positive integer is accepted."""
3030

3131
refresh_rate: int
3232
"""Display refresh rate in Hz.
3333
34-
If omitted, automatically determined from width and height.
34+
Any positive integer is accepted; if omitted, automatically determined from
35+
width and height.
3536
"""

tests/api_resources/test_browser_pools.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_method_create_with_all_params(self, client: Kernel) -> None:
5353
proxy_id="proxy_id",
5454
start_url="https://example.com",
5555
stealth=True,
56-
timeout_seconds=60,
56+
timeout_seconds=10,
5757
viewport={
5858
"height": 800,
5959
"width": 1280,
@@ -164,7 +164,7 @@ def test_method_update_with_all_params(self, client: Kernel) -> None:
164164
size=10,
165165
start_url="https://example.com",
166166
stealth=True,
167-
timeout_seconds=60,
167+
timeout_seconds=10,
168168
viewport={
169169
"height": 800,
170170
"width": 1280,
@@ -488,7 +488,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncKernel) ->
488488
proxy_id="proxy_id",
489489
start_url="https://example.com",
490490
stealth=True,
491-
timeout_seconds=60,
491+
timeout_seconds=10,
492492
viewport={
493493
"height": 800,
494494
"width": 1280,
@@ -599,7 +599,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncKernel) ->
599599
size=10,
600600
start_url="https://example.com",
601601
stealth=True,
602-
timeout_seconds=60,
602+
timeout_seconds=10,
603603
viewport={
604604
"height": 800,
605605
"width": 1280,

0 commit comments

Comments
 (0)