clean up fullpage screenshot exp (#4102)
This commit is contained in:
@@ -2198,11 +2198,6 @@ class ForgeAgent:
|
|||||||
try:
|
try:
|
||||||
screenshot = await browser_state.take_post_action_screenshot(
|
screenshot = await browser_state.take_post_action_screenshot(
|
||||||
scrolling_number=scrolling_number,
|
scrolling_number=scrolling_number,
|
||||||
use_playwright_fullpage=await app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(
|
|
||||||
"ENABLE_PLAYWRIGHT_FULLPAGE",
|
|
||||||
task.workflow_run_id or task.task_id,
|
|
||||||
properties={"organization_id": task.organization_id},
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
await app.ARTIFACT_MANAGER.create_artifact(
|
await app.ARTIFACT_MANAGER.create_artifact(
|
||||||
step=step,
|
step=step,
|
||||||
@@ -3069,13 +3064,7 @@ class ForgeAgent:
|
|||||||
browser_state = app.BROWSER_MANAGER.get_for_task(task.task_id)
|
browser_state = app.BROWSER_MANAGER.get_for_task(task.task_id)
|
||||||
if browser_state is not None and await browser_state.get_working_page() is not None:
|
if browser_state is not None and await browser_state.get_working_page() is not None:
|
||||||
try:
|
try:
|
||||||
screenshot = await browser_state.take_fullpage_screenshot(
|
screenshot = await browser_state.take_fullpage_screenshot()
|
||||||
use_playwright_fullpage=await app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(
|
|
||||||
"ENABLE_PLAYWRIGHT_FULLPAGE",
|
|
||||||
task.workflow_run_id or task.task_id,
|
|
||||||
properties={"organization_id": task.organization_id},
|
|
||||||
)
|
|
||||||
)
|
|
||||||
await app.ARTIFACT_MANAGER.create_artifact(
|
await app.ARTIFACT_MANAGER.create_artifact(
|
||||||
step=last_step,
|
step=last_step,
|
||||||
artifact_type=ArtifactType.SCREENSHOT_FINAL,
|
artifact_type=ArtifactType.SCREENSHOT_FINAL,
|
||||||
|
|||||||
@@ -383,13 +383,7 @@ class Block(BaseModel, abc.ABC):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
screenshot = await browser_state.take_fullpage_screenshot(
|
screenshot = await browser_state.take_fullpage_screenshot()
|
||||||
use_playwright_fullpage=await app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(
|
|
||||||
"ENABLE_PLAYWRIGHT_FULLPAGE",
|
|
||||||
workflow_run_id,
|
|
||||||
properties={"organization_id": str(organization_id)},
|
|
||||||
)
|
|
||||||
)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"Failed to take screenshot before executing the block, ignoring the exception",
|
"Failed to take screenshot before executing the block, ignoring the exception",
|
||||||
@@ -693,13 +687,7 @@ class BaseTaskBlock(Block):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# add screenshot artifact for the first task
|
# add screenshot artifact for the first task
|
||||||
screenshot = await browser_state.take_fullpage_screenshot(
|
screenshot = await browser_state.take_fullpage_screenshot()
|
||||||
use_playwright_fullpage=await app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(
|
|
||||||
"ENABLE_PLAYWRIGHT_FULLPAGE",
|
|
||||||
workflow_run_id,
|
|
||||||
properties={"organization_id": str(organization_id)},
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if screenshot:
|
if screenshot:
|
||||||
await app.ARTIFACT_MANAGER.create_workflow_run_block_artifact(
|
await app.ARTIFACT_MANAGER.create_workflow_run_block_artifact(
|
||||||
workflow_run_block=workflow_run_block,
|
workflow_run_block=workflow_run_block,
|
||||||
|
|||||||
@@ -378,13 +378,7 @@ async def _take_workflow_run_block_screenshot(
|
|||||||
if not browser_state:
|
if not browser_state:
|
||||||
LOG.warning("No browser state found when creating workflow_run_block", workflow_run_id=workflow_run_id)
|
LOG.warning("No browser state found when creating workflow_run_block", workflow_run_id=workflow_run_id)
|
||||||
else:
|
else:
|
||||||
screenshot = await browser_state.take_fullpage_screenshot(
|
screenshot = await browser_state.take_fullpage_screenshot()
|
||||||
use_playwright_fullpage=await app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(
|
|
||||||
"ENABLE_PLAYWRIGHT_FULLPAGE",
|
|
||||||
workflow_run_id,
|
|
||||||
properties={"organization_id": str(organization_id)},
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if screenshot:
|
if screenshot:
|
||||||
await app.ARTIFACT_MANAGER.create_workflow_run_block_artifact(
|
await app.ARTIFACT_MANAGER.create_workflow_run_block_artifact(
|
||||||
workflow_run_block=workflow_run_block,
|
workflow_run_block=workflow_run_block,
|
||||||
|
|||||||
@@ -1017,21 +1017,18 @@ class BrowserState:
|
|||||||
async def take_fullpage_screenshot(
|
async def take_fullpage_screenshot(
|
||||||
self,
|
self,
|
||||||
file_path: str | None = None,
|
file_path: str | None = None,
|
||||||
use_playwright_fullpage: bool = False, # TODO: THIS IS ONLY FOR EXPERIMENT. will be removed after experiment.
|
|
||||||
) -> bytes:
|
) -> bytes:
|
||||||
page = await self.__assert_page()
|
page = await self.__assert_page()
|
||||||
return await SkyvernFrame.take_scrolling_screenshot(
|
return await SkyvernFrame.take_scrolling_screenshot(
|
||||||
page=page,
|
page=page,
|
||||||
file_path=file_path,
|
file_path=file_path,
|
||||||
mode=ScreenshotMode.LITE,
|
mode=ScreenshotMode.LITE,
|
||||||
use_playwright_fullpage=use_playwright_fullpage,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
async def take_post_action_screenshot(
|
async def take_post_action_screenshot(
|
||||||
self,
|
self,
|
||||||
scrolling_number: int,
|
scrolling_number: int,
|
||||||
file_path: str | None = None,
|
file_path: str | None = None,
|
||||||
use_playwright_fullpage: bool = False, # TODO: THIS IS ONLY FOR EXPERIMENT. will be removed after experiment.
|
|
||||||
) -> bytes:
|
) -> bytes:
|
||||||
page = await self.__assert_page()
|
page = await self.__assert_page()
|
||||||
return await SkyvernFrame.take_scrolling_screenshot(
|
return await SkyvernFrame.take_scrolling_screenshot(
|
||||||
@@ -1039,5 +1036,4 @@ class BrowserState:
|
|||||||
file_path=file_path,
|
file_path=file_path,
|
||||||
mode=ScreenshotMode.LITE,
|
mode=ScreenshotMode.LITE,
|
||||||
scrolling_number=scrolling_number,
|
scrolling_number=scrolling_number,
|
||||||
use_playwright_fullpage=use_playwright_fullpage,
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -240,18 +240,12 @@ class SkyvernFrame:
|
|||||||
timeout: float = SettingsManager.get_settings().BROWSER_SCREENSHOT_TIMEOUT_MS,
|
timeout: float = SettingsManager.get_settings().BROWSER_SCREENSHOT_TIMEOUT_MS,
|
||||||
mode: ScreenshotMode = ScreenshotMode.DETAILED,
|
mode: ScreenshotMode = ScreenshotMode.DETAILED,
|
||||||
scrolling_number: int = SettingsManager.get_settings().MAX_NUM_SCREENSHOTS,
|
scrolling_number: int = SettingsManager.get_settings().MAX_NUM_SCREENSHOTS,
|
||||||
use_playwright_fullpage: bool = False, # TODO: THIS IS ONLY FOR EXPERIMENT. will be removed after experiment.
|
|
||||||
) -> bytes:
|
) -> bytes:
|
||||||
if scrolling_number <= 0:
|
if scrolling_number <= 0:
|
||||||
return await _current_viewpoint_screenshot_helper(
|
return await _current_viewpoint_screenshot_helper(
|
||||||
page=page, file_path=file_path, timeout=timeout, mode=mode
|
page=page, file_path=file_path, timeout=timeout, mode=mode
|
||||||
)
|
)
|
||||||
|
|
||||||
if use_playwright_fullpage:
|
|
||||||
return await _current_viewpoint_screenshot_helper(
|
|
||||||
page=page, file_path=file_path, timeout=timeout, full_page=True
|
|
||||||
)
|
|
||||||
|
|
||||||
if scrolling_number > SettingsManager.get_settings().MAX_NUM_SCREENSHOTS:
|
if scrolling_number > SettingsManager.get_settings().MAX_NUM_SCREENSHOTS:
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"scrolling_number is greater than the max number of screenshots, setting it to the max number of screenshots",
|
"scrolling_number is greater than the max number of screenshots, setting it to the max number of screenshots",
|
||||||
|
|||||||
Reference in New Issue
Block a user