From 7ab5617b98ce43d006650f6b737ec69b05dc9c14 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Sun, 25 May 2025 00:54:45 -0700 Subject: [PATCH] only ignore skyvern/artifacts folder (#2449) --- .gitignore | 2 +- skyvern/client/artifacts/__init__.py | 2 + skyvern/client/artifacts/client.py | 165 +++++++++++++++++++++++++++ 3 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 skyvern/client/artifacts/__init__.py create mode 100644 skyvern/client/artifacts/client.py diff --git a/.gitignore b/.gitignore index a88e841b..c6a50e72 100644 --- a/.gitignore +++ b/.gitignore @@ -160,7 +160,7 @@ ig_* # Skyvern ignores videos/ -artifacts/ +skyvern/artifacts/ traces/ *.pkl har/ diff --git a/skyvern/client/artifacts/__init__.py b/skyvern/client/artifacts/__init__.py new file mode 100644 index 00000000..f3ea2659 --- /dev/null +++ b/skyvern/client/artifacts/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/skyvern/client/artifacts/client.py b/skyvern/client/artifacts/client.py new file mode 100644 index 00000000..1749accb --- /dev/null +++ b/skyvern/client/artifacts/client.py @@ -0,0 +1,165 @@ +# This file was auto-generated by Fern from our API Definition. + +from ..core.client_wrapper import SyncClientWrapper +import typing +from ..core.request_options import RequestOptions +from ..types.artifact import Artifact +from ..core.jsonable_encoder import jsonable_encoder +from ..core.pydantic_utilities import parse_obj_as +from ..errors.not_found_error import NotFoundError +from ..errors.unprocessable_entity_error import UnprocessableEntityError +from json.decoder import JSONDecodeError +from ..core.api_error import ApiError +from ..core.client_wrapper import AsyncClientWrapper + + +class ArtifactsClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_artifact(self, artifact_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> Artifact: + """ + Get an artifact + + Parameters + ---------- + artifact_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Artifact + Successfully retrieved artifact + + Examples + -------- + from skyvern import Skyvern + + client = Skyvern( + api_key="YOUR_API_KEY", + ) + client.artifacts.get_artifact( + artifact_id="artifact_id", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/artifacts/{jsonable_encoder(artifact_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + Artifact, + parse_obj_as( + type_=Artifact, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + +class AsyncArtifactsClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_artifact( + self, artifact_id: str, *, request_options: typing.Optional[RequestOptions] = None + ) -> Artifact: + """ + Get an artifact + + Parameters + ---------- + artifact_id : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + Artifact + Successfully retrieved artifact + + Examples + -------- + import asyncio + + from skyvern import AsyncSkyvern + + client = AsyncSkyvern( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.artifacts.get_artifact( + artifact_id="artifact_id", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/artifacts/{jsonable_encoder(artifact_id)}", + method="GET", + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return typing.cast( + Artifact, + parse_obj_as( + type_=Artifact, # type: ignore + object_=_response.json(), + ), + ) + if _response.status_code == 404: + raise NotFoundError( + typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + ) + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast( + typing.Optional[typing.Any], + parse_obj_as( + type_=typing.Optional[typing.Any], # type: ignore + object_=_response.json(), + ), + ) + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json)