Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 28
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/structify%2Fstructify-647d01f2b9cf0426e628f9049573a48a482b7af7f214df87a1d5ff64e80db2f1.yml
configured_endpoints: 29
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/structify%2Fstructify-5b6afe9b6d45bca4a8fdf73c2a1473465d60df3d67f61b673d0e399ed10d2ce2.yml
9 changes: 8 additions & 1 deletion api.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ Methods:
Types:

```python
from structify.types import RunListResponse, RunDeleteResponse, RunCancelResponse, RunGetResponse
from structify.types import (
RunListResponse,
RunDeleteResponse,
RunCancelResponse,
RunGetResponse,
RunGetStepsResponse,
)
```

Methods:
Expand All @@ -70,6 +76,7 @@ Methods:
- <code title="post /runs/delete/{uuid}">client.runs.<a href="./src/structify/resources/runs.py">delete</a>(uuid) -> str</code>
- <code title="post /runs/cancel/{uuid}">client.runs.<a href="./src/structify/resources/runs.py">cancel</a>(uuid) -> <a href="./src/structify/types/run_cancel_response.py">RunCancelResponse</a></code>
- <code title="get /runs/get/{uuid}">client.runs.<a href="./src/structify/resources/runs.py">get</a>(uuid) -> <a href="./src/structify/types/run_get_response.py">RunGetResponse</a></code>
- <code title="get /runs/get_steps/{job_id}">client.runs.<a href="./src/structify/resources/runs.py">get_steps</a>(job_id) -> <a href="./src/structify/types/run_get_steps_response.py">RunGetStepsResponse</a></code>
- <code title="post /runs/schedule">client.runs.<a href="./src/structify/resources/runs.py">schedule</a>() -> None</code>

# Server
Expand Down
79 changes: 79 additions & 0 deletions src/structify/resources/runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from ..types.run_get_response import RunGetResponse
from ..types.run_list_response import RunListResponse
from ..types.run_cancel_response import RunCancelResponse
from ..types.run_get_steps_response import RunGetStepsResponse

__all__ = ["RunsResource", "AsyncRunsResource"]

Expand Down Expand Up @@ -176,6 +177,39 @@ def get(
cast_to=RunGetResponse,
)

def get_steps(
self,
job_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> RunGetStepsResponse:
"""
Retrieve a run from structify.

Args:
extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if not job_id:
raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}")
return self._get(
f"/runs/get_steps/{job_id}",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=RunGetStepsResponse,
)

def schedule(
self,
*,
Expand Down Expand Up @@ -352,6 +386,39 @@ async def get(
cast_to=RunGetResponse,
)

async def get_steps(
self,
job_id: str,
*,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
extra_query: Query | None = None,
extra_body: Body | None = None,
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
) -> RunGetStepsResponse:
"""
Retrieve a run from structify.

Args:
extra_headers: Send extra headers

extra_query: Add additional query parameters to the request

extra_body: Add additional JSON properties to the request

timeout: Override the client-level default timeout for this request, in seconds
"""
if not job_id:
raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}")
return await self._get(
f"/runs/get_steps/{job_id}",
options=make_request_options(
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
),
cast_to=RunGetStepsResponse,
)

async def schedule(
self,
*,
Expand Down Expand Up @@ -392,6 +459,9 @@ def __init__(self, runs: RunsResource) -> None:
self.get = to_raw_response_wrapper(
runs.get,
)
self.get_steps = to_raw_response_wrapper(
runs.get_steps,
)
self.schedule = to_raw_response_wrapper(
runs.schedule,
)
Expand All @@ -413,6 +483,9 @@ def __init__(self, runs: AsyncRunsResource) -> None:
self.get = async_to_raw_response_wrapper(
runs.get,
)
self.get_steps = async_to_raw_response_wrapper(
runs.get_steps,
)
self.schedule = async_to_raw_response_wrapper(
runs.schedule,
)
Expand All @@ -434,6 +507,9 @@ def __init__(self, runs: RunsResource) -> None:
self.get = to_streamed_response_wrapper(
runs.get,
)
self.get_steps = to_streamed_response_wrapper(
runs.get_steps,
)
self.schedule = to_streamed_response_wrapper(
runs.schedule,
)
Expand All @@ -455,6 +531,9 @@ def __init__(self, runs: AsyncRunsResource) -> None:
self.get = async_to_streamed_response_wrapper(
runs.get,
)
self.get_steps = async_to_streamed_response_wrapper(
runs.get_steps,
)
self.schedule = async_to_streamed_response_wrapper(
runs.schedule,
)
1 change: 1 addition & 0 deletions src/structify/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from .label_update_response import LabelUpdateResponse as LabelUpdateResponse
from .document_list_response import DocumentListResponse as DocumentListResponse
from .document_upload_params import DocumentUploadParams as DocumentUploadParams
from .run_get_steps_response import RunGetStepsResponse as RunGetStepsResponse
from .extraction_criteria_param import ExtractionCriteriaParam as ExtractionCriteriaParam
from .label_get_messages_params import LabelGetMessagesParams as LabelGetMessagesParams
from .label_llm_assist_response import LabelLlmAssistResponse as LabelLlmAssistResponse
Expand Down
9 changes: 9 additions & 0 deletions src/structify/types/run_get_steps_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List

from .execution_step import ExecutionStep

__all__ = ["RunGetStepsResponse"]

RunGetStepsResponse = List[ExecutionStep]
83 changes: 82 additions & 1 deletion tests/api_resources/test_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@

from structify import Structify, AsyncStructify
from tests.utils import assert_matches_type
from structify.types import RunGetResponse, RunListResponse, RunCancelResponse
from structify.types import (
RunGetResponse,
RunListResponse,
RunCancelResponse,
RunGetStepsResponse,
)
from structify.pagination import SyncRunsList, AsyncRunsList

base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
Expand Down Expand Up @@ -165,6 +170,44 @@ def test_path_params_get(self, client: Structify) -> None:
"",
)

@parametrize
def test_method_get_steps(self, client: Structify) -> None:
run = client.runs.get_steps(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
assert_matches_type(RunGetStepsResponse, run, path=["response"])

@parametrize
def test_raw_response_get_steps(self, client: Structify) -> None:
response = client.runs.with_raw_response.get_steps(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)

assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
run = response.parse()
assert_matches_type(RunGetStepsResponse, run, path=["response"])

@parametrize
def test_streaming_response_get_steps(self, client: Structify) -> None:
with client.runs.with_streaming_response.get_steps(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

run = response.parse()
assert_matches_type(RunGetStepsResponse, run, path=["response"])

assert cast(Any, response.is_closed) is True

@parametrize
def test_path_params_get_steps(self, client: Structify) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"):
client.runs.with_raw_response.get_steps(
"",
)

@parametrize
def test_method_schedule(self, client: Structify) -> None:
run = client.runs.schedule()
Expand Down Expand Up @@ -341,6 +384,44 @@ async def test_path_params_get(self, async_client: AsyncStructify) -> None:
"",
)

@parametrize
async def test_method_get_steps(self, async_client: AsyncStructify) -> None:
run = await async_client.runs.get_steps(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)
assert_matches_type(RunGetStepsResponse, run, path=["response"])

@parametrize
async def test_raw_response_get_steps(self, async_client: AsyncStructify) -> None:
response = await async_client.runs.with_raw_response.get_steps(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
)

assert response.is_closed is True
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
run = await response.parse()
assert_matches_type(RunGetStepsResponse, run, path=["response"])

@parametrize
async def test_streaming_response_get_steps(self, async_client: AsyncStructify) -> None:
async with async_client.runs.with_streaming_response.get_steps(
"182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
) as response:
assert not response.is_closed
assert response.http_request.headers.get("X-Stainless-Lang") == "python"

run = await response.parse()
assert_matches_type(RunGetStepsResponse, run, path=["response"])

assert cast(Any, response.is_closed) is True

@parametrize
async def test_path_params_get_steps(self, async_client: AsyncStructify) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"):
await async_client.runs.with_raw_response.get_steps(
"",
)

@parametrize
async def test_method_schedule(self, async_client: AsyncStructify) -> None:
run = await async_client.runs.schedule()
Expand Down