rename variable (#2865)

This commit is contained in:
Shuchang Zheng
2025-07-03 02:03:01 -07:00
committed by GitHub
parent 73d6743c87
commit 393387acb0
34 changed files with 118 additions and 126 deletions

View File

@@ -19,7 +19,7 @@ from skyvern import analytics
from skyvern.config import settings
from skyvern.constants import (
BROWSER_DOWNLOADING_SUFFIX,
DEFAULT_MAX_SCREENSHOT_SCROLLING_TIMES,
DEFAULT_MAX_SCREENSHOT_SCROLLS,
GET_DOWNLOADED_FILES_TIMEOUT,
SAVE_DOWNLOADED_FILES_TIMEOUT,
SCRAPE_TYPE_ORDER,
@@ -183,7 +183,7 @@ class ForgeAgent:
error_code_mapping=task_block.error_code_mapping,
include_action_history_in_verification=task_block.include_action_history_in_verification,
model=task_block.model,
max_screenshot_scrolling_times=workflow_run.max_screenshot_scrolling_times,
max_screenshot_scrolling_times=workflow_run.max_screenshot_scrolls,
extra_http_headers=workflow_run.extra_http_headers,
)
LOG.info(
@@ -241,7 +241,7 @@ class ForgeAgent:
application=task_request.application,
include_action_history_in_verification=task_request.include_action_history_in_verification,
model=task_request.model,
max_screenshot_scrolling_times=task_request.max_screenshot_scrolling_times,
max_screenshot_scrolling_times=task_request.max_screenshot_scrolls,
extra_http_headers=task_request.extra_http_headers,
)
LOG.info(
@@ -1662,9 +1662,9 @@ class ForgeAgent:
raise BrowserStateMissingPage()
context = skyvern_context.ensure_context()
scrolling_number = context.max_screenshot_scrolling_times
scrolling_number = context.max_screenshot_scrolls
if scrolling_number is None:
scrolling_number = DEFAULT_MAX_SCREENSHOT_SCROLLING_TIMES
scrolling_number = DEFAULT_MAX_SCREENSHOT_SCROLLS
if engine in CUA_ENGINES:
scrolling_number = 0

View File

@@ -24,8 +24,8 @@ class SkyvernContext:
hashed_href_map: dict[str, str] = field(default_factory=dict)
refresh_working_page: bool = False
frame_index_map: dict[Frame, int] = field(default_factory=dict)
max_screenshot_scrolling_times: int | None = None
dropped_css_svg_element_map: dict[str, bool] = field(default_factory=dict)
max_screenshot_scrolls: int | None = None
def __repr__(self) -> str:
return f"SkyvernContext(request_id={self.request_id}, organization_id={self.organization_id}, task_id={self.task_id}, workflow_id={self.workflow_id}, workflow_run_id={self.workflow_run_id}, task_v2_id={self.task_v2_id}, max_steps_override={self.max_steps_override}, run_id={self.run_id})"

View File

@@ -143,7 +143,7 @@ def convert_to_task(task_obj: TaskModel, debug_enabled: bool = False, workflow_p
queued_at=task_obj.queued_at,
started_at=task_obj.started_at,
finished_at=task_obj.finished_at,
max_screenshot_scrolling_times=task_obj.max_screenshot_scrolling_times,
max_screenshot_scrolls=task_obj.max_screenshot_scrolling_times,
)
return task
@@ -240,7 +240,7 @@ def convert_to_workflow(workflow_model: WorkflowModel, debug_enabled: bool = Fal
persist_browser_session=workflow_model.persist_browser_session,
model=workflow_model.model,
proxy_location=(ProxyLocation(workflow_model.proxy_location) if workflow_model.proxy_location else None),
max_screenshot_scrolling_times=workflow_model.max_screenshot_scrolling_times,
max_screenshot_scrolls=workflow_model.max_screenshot_scrolling_times,
version=workflow_model.version,
is_saved_task=workflow_model.is_saved_task,
description=workflow_model.description,
@@ -282,7 +282,7 @@ def convert_to_workflow_run(
created_at=workflow_run_model.created_at,
modified_at=workflow_run_model.modified_at,
workflow_title=workflow_title,
max_screenshot_scrolling_times=workflow_run_model.max_screenshot_scrolling_times,
max_screenshot_scrolls=workflow_run_model.max_screenshot_scrolling_times,
extra_http_headers=workflow_run_model.extra_http_headers,
)

View File

@@ -108,7 +108,7 @@ class BackgroundTaskExecutor(AsyncExecutor):
context.run_id = context.run_id or task.task_id
context.organization_id = organization_id
context.max_steps_override = max_steps_override
context.max_screenshot_scrolling_times = task.max_screenshot_scrolling_times
context.max_screenshot_scrolls = task.max_screenshot_scrolls
if background_tasks:
await initialize_skyvern_state_file(task_id=task_id, organization_id=organization_id)

View File

@@ -167,7 +167,7 @@ async def run_task(
totp_identifier=run_request.totp_identifier,
include_action_history_in_verification=run_request.include_action_history_in_verification,
model=run_request.model,
max_screenshot_scrolling_times=run_request.max_screenshot_scrolling_times,
max_screenshot_scrolls=run_request.max_screenshot_scrolls,
extra_http_headers=run_request.extra_http_headers,
)
task_v1_response = await task_v1_service.run_task(
@@ -206,7 +206,7 @@ async def run_task(
data_extraction_schema=task_v1_response.extracted_information_schema,
error_code_mapping=task_v1_response.error_code_mapping,
browser_session_id=run_request.browser_session_id,
max_screenshot_scrolling_times=run_request.max_screenshot_scrolling_times,
max_screenshot_scrolls=run_request.max_screenshot_scrolls,
),
)
if run_request.engine == RunEngine.skyvern_v2:
@@ -225,7 +225,7 @@ async def run_task(
error_code_mapping=run_request.error_code_mapping,
create_task_run=True,
model=run_request.model,
max_screenshot_scrolling_times=run_request.max_screenshot_scrolling_times,
max_screenshot_scrolling_times=run_request.max_screenshot_scrolls,
extra_http_headers=run_request.extra_http_headers,
)
except MissingBrowserAddressError as e:
@@ -269,7 +269,7 @@ async def run_task(
error_code_mapping=task_v2.error_code_mapping,
data_extraction_schema=task_v2.extracted_information_schema,
publish_workflow=run_request.publish_workflow,
max_screenshot_scrolling_times=run_request.max_screenshot_scrolling_times,
max_screenshot_scrolls=run_request.max_screenshot_scrolls,
),
)
LOG.error("Invalid agent engine", engine=run_request.engine, organization_id=current_org.organization_id)
@@ -325,7 +325,7 @@ async def run_workflow(
totp_identifier=workflow_run_request.totp_identifier,
totp_verification_url=workflow_run_request.totp_url,
browser_session_id=workflow_run_request.browser_session_id,
max_screenshot_scrolling_times=workflow_run_request.max_screenshot_scrolling_times,
max_screenshot_scrolls=workflow_run_request.max_screenshot_scrolls,
extra_http_headers=workflow_run_request.extra_http_headers,
)
@@ -1878,7 +1878,7 @@ async def run_task_v2(
create_task_run=True,
extracted_information_schema=data.extracted_information_schema,
error_code_mapping=data.error_code_mapping,
max_screenshot_scrolling_times=data.max_screenshot_scrolling_times,
max_screenshot_scrolling_times=data.max_screenshot_scrolls,
browser_session_id=data.browser_session_id,
extra_http_headers=data.extra_http_headers,
)

View File

@@ -48,7 +48,7 @@ class TaskV2(BaseModel):
queued_at: datetime | None = None
started_at: datetime | None = None
finished_at: datetime | None = None
max_screenshot_scrolling_times: int | None = None
max_screenshot_scrolls: int | None = Field(default=None, alias="max_screenshot_scrolling_times")
extra_http_headers: dict[str, str] | None = None
created_at: datetime
@@ -150,7 +150,7 @@ class TaskV2Request(BaseModel):
publish_workflow: bool = False
extracted_information_schema: dict | list | str | None = None
error_code_mapping: dict[str, str] | None = None
max_screenshot_scrolling_times: int | None = None
max_screenshot_scrolls: int | None = None
extra_http_headers: dict[str, str] | None = None
@field_validator("url", "webhook_callback_url", "totp_verification_url")

View File

@@ -99,9 +99,9 @@ class TaskBase(BaseModel):
description="Whether to include the action history when verifying the task is complete",
examples=[True, False],
)
max_screenshot_scrolling_times: int | None = Field(
max_screenshot_scrolls: int | None = Field(
default=None,
description="Scroll down n times to get the merged screenshot of the page after taking an action. When it's None or 0, it takes the current viewpoint screenshot.",
description="The maximum number of scrolls for the post action screenshot. When it's None or 0, it takes the current viewpoint screenshot.",
examples=[10],
)
@@ -322,7 +322,7 @@ class Task(TaskBase):
errors=self.errors,
max_steps_per_run=self.max_steps_per_run,
workflow_run_id=self.workflow_run_id,
max_screenshot_scrolling_times=self.max_screenshot_scrolling_times,
max_screenshot_scrolls=self.max_screenshot_scrolls,
)
@@ -346,7 +346,7 @@ class TaskResponse(BaseModel):
queued_at: datetime | None = None
started_at: datetime | None = None
finished_at: datetime | None = None
max_screenshot_scrolling_times: int | None = None
max_screenshot_scrolls: int | None = None
class TaskOutput(BaseModel):

View File

@@ -2522,7 +2522,7 @@ class TaskV2Block(Block):
proxy_location=workflow_run.proxy_location,
totp_identifier=self.totp_identifier,
totp_verification_url=self.totp_verification_url,
max_screenshot_scrolling_times=workflow_run.max_screenshot_scrolling_times,
max_screenshot_scrolling_times=workflow_run.max_screenshot_scrolls,
)
await app.DATABASE.update_task_v2(
task_v2.observer_cruise_id, status=TaskV2Status.queued, organization_id=organization_id
@@ -2557,7 +2557,7 @@ class TaskV2Block(Block):
workflow_run_id=workflow_run_id,
run_id=current_run_id,
browser_session_id=browser_session_id,
max_screenshot_scrolling_times=workflow_run.max_screenshot_scrolling_times,
max_screenshot_scrolls=workflow_run.max_screenshot_scrolls,
)
)
result_dict = None

View File

@@ -22,7 +22,7 @@ class WorkflowRequestBody(BaseModel):
totp_verification_url: str | None = None
totp_identifier: str | None = None
browser_session_id: str | None = None
max_screenshot_scrolling_times: int | None = None
max_screenshot_scrolls: int | None = None
extra_http_headers: dict[str, str] | None = None
@field_validator("webhook_callback_url", "totp_verification_url")
@@ -78,7 +78,7 @@ class Workflow(BaseModel):
persist_browser_session: bool = False
model: dict[str, Any] | None = None
status: WorkflowStatus = WorkflowStatus.published
max_screenshot_scrolling_times: int | None = None
max_screenshot_scrolls: int | None = None
extra_http_headers: dict[str, str] | None = None
created_at: datetime
@@ -120,7 +120,7 @@ class WorkflowRun(BaseModel):
failure_reason: str | None = None
parent_workflow_run_id: str | None = None
workflow_title: str | None = None
max_screenshot_scrolling_times: int | None = None
max_screenshot_scrolls: int | None = None
queued_at: datetime | None = None
started_at: datetime | None = None
@@ -169,4 +169,4 @@ class WorkflowRunResponseBase(BaseModel):
task_v2: TaskV2 | None = None
workflow_title: str | None = None
browser_session_id: str | None = None
max_screenshot_scrolling_times: int | None = None
max_screenshot_scrolls: int | None = None

View File

@@ -440,6 +440,6 @@ class WorkflowCreateYAMLRequest(BaseModel):
model: dict[str, Any] | None = None
workflow_definition: WorkflowDefinitionYAML
is_saved_task: bool = False
max_screenshot_scrolling_times: int | None = None
max_screenshot_scrolls: int | None = None
extra_http_headers: dict[str, str] | None = None
status: WorkflowStatus = WorkflowStatus.published

View File

@@ -176,7 +176,7 @@ class WorkflowService:
organization_id=workflow.organization_id,
proxy_location=workflow_request.proxy_location,
webhook_callback_url=workflow_request.webhook_callback_url,
max_screenshot_scrolling_times=workflow_request.max_screenshot_scrolling_times,
max_screenshot_scrolling_times=workflow_request.max_screenshot_scrolls,
)
context: skyvern_context.SkyvernContext | None = skyvern_context.current()
current_run_id = context.run_id if context and context.run_id else workflow_run.workflow_run_id
@@ -190,7 +190,7 @@ class WorkflowService:
run_id=current_run_id,
workflow_permanent_id=workflow_run.workflow_permanent_id,
max_steps_override=max_steps_override,
max_screenshot_scrolling_times=workflow_request.max_screenshot_scrolling_times,
max_screenshot_scrolls=workflow_request.max_screenshot_scrolls,
)
)
@@ -788,7 +788,7 @@ class WorkflowService:
totp_verification_url=workflow_request.totp_verification_url,
totp_identifier=workflow_request.totp_identifier,
parent_workflow_run_id=parent_workflow_run_id,
max_screenshot_scrolling_times=workflow_request.max_screenshot_scrolling_times,
max_screenshot_scrolling_times=workflow_request.max_screenshot_scrolls,
extra_http_headers=workflow_request.extra_http_headers,
)
@@ -1204,7 +1204,7 @@ class WorkflowService:
total_steps=total_steps,
total_cost=total_cost,
workflow_title=workflow.title,
max_screenshot_scrolling_times=workflow_run.max_screenshot_scrolling_times,
max_screenshot_scrolls=workflow_run.max_screenshot_scrolls,
)
async def clean_up_workflow(
@@ -1478,7 +1478,7 @@ class WorkflowService:
totp_identifier=request.totp_identifier,
persist_browser_session=request.persist_browser_session,
model=request.model,
max_screenshot_scrolling_times=request.max_screenshot_scrolling_times,
max_screenshot_scrolling_times=request.max_screenshot_scrolls,
extra_http_headers=request.extra_http_headers,
workflow_permanent_id=workflow_permanent_id,
version=existing_version + 1,
@@ -1497,7 +1497,7 @@ class WorkflowService:
totp_identifier=request.totp_identifier,
persist_browser_session=request.persist_browser_session,
model=request.model,
max_screenshot_scrolling_times=request.max_screenshot_scrolling_times,
max_screenshot_scrolling_times=request.max_screenshot_scrolls,
extra_http_headers=request.extra_http_headers,
is_saved_task=request.is_saved_task,
status=request.status,
@@ -2114,7 +2114,7 @@ class WorkflowService:
),
proxy_location=proxy_location,
status=status,
max_screenshot_scrolling_times=max_screenshot_scrolling_times,
max_screenshot_scrolls=max_screenshot_scrolling_times,
extra_http_headers=extra_http_headers,
)
return await app.WORKFLOW_SERVICE.create_workflow_from_request(