project run (#3097)
This commit is contained in:
@@ -55,6 +55,7 @@ from skyvern.forge.sdk.db.utils import (
|
||||
convert_to_organization_auth_token,
|
||||
convert_to_output_parameter,
|
||||
convert_to_project,
|
||||
convert_to_project_file,
|
||||
convert_to_step,
|
||||
convert_to_task,
|
||||
convert_to_workflow,
|
||||
@@ -99,7 +100,7 @@ from skyvern.forge.sdk.workflow.models.workflow import (
|
||||
WorkflowRunStatus,
|
||||
WorkflowStatus,
|
||||
)
|
||||
from skyvern.schemas.projects import Project
|
||||
from skyvern.schemas.projects import Project, ProjectFile
|
||||
from skyvern.schemas.runs import ProxyLocation, RunEngine, RunType
|
||||
from skyvern.webeye.actions.actions import Action
|
||||
from skyvern.webeye.actions.models import AgentStepOutput
|
||||
@@ -3632,6 +3633,17 @@ class AgentDB:
|
||||
LOG.error("UnexpectedError", exc_info=True)
|
||||
raise
|
||||
|
||||
async def get_project_revision(self, project_revision_id: str, organization_id: str) -> Project | None:
|
||||
async with self.Session() as session:
|
||||
project = (
|
||||
await session.scalars(
|
||||
select(ProjectModel)
|
||||
.filter_by(project_revision_id=project_revision_id)
|
||||
.filter_by(organization_id=organization_id)
|
||||
)
|
||||
).first()
|
||||
return convert_to_project(project) if project else None
|
||||
|
||||
async def create_project_file(
|
||||
self,
|
||||
project_revision_id: str,
|
||||
@@ -3670,3 +3682,14 @@ class AgentDB:
|
||||
except Exception:
|
||||
LOG.error("UnexpectedError", exc_info=True)
|
||||
raise
|
||||
|
||||
async def get_project_files(self, project_revision_id: str, organization_id: str) -> list[ProjectFile]:
|
||||
async with self.Session() as session:
|
||||
project_files = (
|
||||
await session.scalars(
|
||||
select(ProjectFileModel)
|
||||
.filter_by(project_revision_id=project_revision_id)
|
||||
.filter_by(organization_id=organization_id)
|
||||
)
|
||||
).all()
|
||||
return [convert_to_project_file(project_file) for project_file in project_files]
|
||||
|
||||
@@ -15,6 +15,7 @@ from skyvern.forge.sdk.db.models import (
|
||||
OrganizationAuthTokenModel,
|
||||
OrganizationModel,
|
||||
OutputParameterModel,
|
||||
ProjectFileModel,
|
||||
ProjectModel,
|
||||
StepModel,
|
||||
TaskModel,
|
||||
@@ -47,7 +48,7 @@ from skyvern.forge.sdk.workflow.models.workflow import (
|
||||
WorkflowRunStatus,
|
||||
WorkflowStatus,
|
||||
)
|
||||
from skyvern.schemas.projects import Project
|
||||
from skyvern.schemas.projects import Project, ProjectFile
|
||||
from skyvern.schemas.runs import ProxyLocation
|
||||
from skyvern.webeye.actions.actions import (
|
||||
Action,
|
||||
@@ -507,6 +508,25 @@ def convert_to_project(project_model: ProjectModel) -> Project:
|
||||
)
|
||||
|
||||
|
||||
def convert_to_project_file(project_file_model: ProjectFileModel) -> ProjectFile:
|
||||
return ProjectFile(
|
||||
file_id=project_file_model.file_id,
|
||||
project_revision_id=project_file_model.project_revision_id,
|
||||
project_id=project_file_model.project_id,
|
||||
organization_id=project_file_model.organization_id,
|
||||
file_path=project_file_model.file_path,
|
||||
file_name=project_file_model.file_name,
|
||||
file_type=project_file_model.file_type,
|
||||
content_hash=project_file_model.content_hash,
|
||||
file_size=project_file_model.file_size,
|
||||
mime_type=project_file_model.mime_type,
|
||||
encoding=project_file_model.encoding,
|
||||
artifact_id=project_file_model.artifact_id,
|
||||
created_at=project_file_model.created_at,
|
||||
modified_at=project_file_model.modified_at,
|
||||
)
|
||||
|
||||
|
||||
def hydrate_action(action_model: ActionModel) -> Action:
|
||||
"""
|
||||
Convert ActionModel to the appropriate Action type based on action_type.
|
||||
|
||||
Reference in New Issue
Block a user