Skip to content

Commit 75060df

Browse files
committed
pass organization id to launch browser
1 parent f690160 commit 75060df

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

skyvern/webeye/browser_factory.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ async def check_and_fix_state(
208208
proxy_location: ProxyLocation | None = None,
209209
task_id: str | None = None,
210210
workflow_run_id: str | None = None,
211+
organization_id: str | None = None,
211212
) -> None:
212213
if self.pw is None:
213214
LOG.info("Starting playwright")
@@ -225,6 +226,7 @@ async def check_and_fix_state(
225226
proxy_location=proxy_location,
226227
task_id=task_id,
227228
workflow_run_id=workflow_run_id,
229+
organization_id=organization_id,
228230
)
229231
self.browser_context = browser_context
230232
self.browser_artifacts = browser_artifacts
@@ -312,29 +314,42 @@ async def get_or_create_page(
312314
proxy_location: ProxyLocation | None = None,
313315
task_id: str | None = None,
314316
workflow_run_id: str | None = None,
317+
organization_id: str | None = None,
315318
) -> Page:
316319
page = await self.get_working_page()
317320
if page is not None:
318321
return page
319322

320323
try:
321324
await self.check_and_fix_state(
322-
url=url, proxy_location=proxy_location, task_id=task_id, workflow_run_id=workflow_run_id
325+
url=url,
326+
proxy_location=proxy_location,
327+
task_id=task_id,
328+
workflow_run_id=workflow_run_id,
329+
organization_id=organization_id,
323330
)
324331
except Exception as e:
325332
error_message = str(e)
326333
if "net::ERR" not in error_message:
327334
raise e
328335
await self.close_current_open_page()
329336
await self.check_and_fix_state(
330-
url=url, proxy_location=proxy_location, task_id=task_id, workflow_run_id=workflow_run_id
337+
url=url,
338+
proxy_location=proxy_location,
339+
task_id=task_id,
340+
workflow_run_id=workflow_run_id,
341+
organization_id=organization_id,
331342
)
332343
await self.__assert_page()
333344

334345
if not await BrowserContextFactory.validate_browser_context(await self.get_working_page()):
335346
await self.close_current_open_page()
336347
await self.check_and_fix_state(
337-
url=url, proxy_location=proxy_location, task_id=task_id, workflow_run_id=workflow_run_id
348+
url=url,
349+
proxy_location=proxy_location,
350+
task_id=task_id,
351+
workflow_run_id=workflow_run_id,
352+
organization_id=organization_id,
338353
)
339354
await self.__assert_page()
340355

skyvern/webeye/browser_manager.py

+19-4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ async def _create_browser_state(
3030
url: str | None = None,
3131
task_id: str | None = None,
3232
workflow_run_id: str | None = None,
33+
organization_id: str | None = None,
3334
) -> BrowserState:
3435
pw = await async_playwright().start()
3536
(
@@ -42,6 +43,7 @@ async def _create_browser_state(
4243
url=url,
4344
task_id=task_id,
4445
workflow_run_id=workflow_run_id,
46+
organization_id=organization_id,
4547
)
4648
return BrowserState(
4749
pw=pw,
@@ -64,11 +66,18 @@ async def get_or_create_for_task(self, task: Task) -> BrowserState:
6466
return self.pages[task.task_id]
6567

6668
LOG.info("Creating browser state for task", task_id=task.task_id)
67-
browser_state = await self._create_browser_state(task.proxy_location, task.url, task.task_id)
69+
browser_state = await self._create_browser_state(
70+
proxy_location=task.proxy_location,
71+
url=task.url,
72+
task_id=task.task_id,
73+
organization_id=task.organization_id,
74+
)
6875

6976
# The URL here is only used when creating a new page, and not when using an existing page.
7077
# This will make sure browser_state.page is not None.
71-
await browser_state.get_or_create_page(url=task.url, proxy_location=task.proxy_location, task_id=task.task_id)
78+
await browser_state.get_or_create_page(
79+
url=task.url, proxy_location=task.proxy_location, task_id=task.task_id, organization_id=task.organization_id
80+
)
7281

7382
self.pages[task.task_id] = browser_state
7483
if task.workflow_run_id:
@@ -83,13 +92,19 @@ async def get_or_create_for_workflow_run(self, workflow_run: WorkflowRun, url: s
8392
workflow_run_id=workflow_run.workflow_run_id,
8493
)
8594
browser_state = await self._create_browser_state(
86-
workflow_run.proxy_location, url=url, workflow_run_id=workflow_run.workflow_run_id
95+
workflow_run.proxy_location,
96+
url=url,
97+
workflow_run_id=workflow_run.workflow_run_id,
98+
organization_id=workflow_run.organization_id,
8799
)
88100

89101
# The URL here is only used when creating a new page, and not when using an existing page.
90102
# This will make sure browser_state.page is not None.
91103
await browser_state.get_or_create_page(
92-
url=url, proxy_location=workflow_run.proxy_location, workflow_run_id=workflow_run.workflow_run_id
104+
url=url,
105+
proxy_location=workflow_run.proxy_location,
106+
workflow_run_id=workflow_run.workflow_run_id,
107+
organization_id=workflow_run.organization_id,
93108
)
94109

95110
self.pages[workflow_run.workflow_run_id] = browser_state

0 commit comments

Comments
 (0)