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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $ pip install -r requirements-dev.lock
## Modifying/Adding code

Most of the SDK is generated code, and any modified code will be overridden on the next generation. The
`src/runloop/lib/` and `examples/` directories are exceptions and will never be overridden.
`src/runloop_minus_api_minus_client/lib/` and `examples/` directories are exceptions and will never be overridden.

## Adding and running examples

Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Runloop Python API library

[![PyPI version](https://img.shields.io/pypi/v/runloop.svg)](https://pypi.org/project/runloop/)
[![PyPI version](https://img.shields.io/pypi/v/runloop-api-client.svg)](https://pypi.org/project/runloop-api-client/)

The Runloop Python library provides convenient access to the Runloop REST API from any Python 3.7+
application. The library includes type definitions for all request params and response fields,
Expand All @@ -16,7 +16,7 @@ The REST API documentation can be found [on runloop.ai](https://runloop.ai). The

```sh
# install from PyPI
pip install --pre runloop
pip install --pre runloop-api-client
```

## Usage
Expand All @@ -25,7 +25,7 @@ The full API of this library can be found in [api.md](api.md).

```python
import os
from runloop import Runloop
from runloop_minus_api_minus_client import Runloop

client = Runloop(
# This is the default and can be omitted
Expand All @@ -48,7 +48,7 @@ Simply import `AsyncRunloop` instead of `Runloop` and use `await` with each API
```python
import os
import asyncio
from runloop import AsyncRunloop
from runloop_minus_api_minus_client import AsyncRunloop

client = AsyncRunloop(
# This is the default and can be omitted
Expand Down Expand Up @@ -77,27 +77,27 @@ Typed requests and responses provide autocomplete and documentation within your

## Handling errors

When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `runloop.APIConnectionError` is raised.
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `runloop_minus_api_minus_client.APIConnectionError` is raised.

When the API returns a non-success status code (that is, 4xx or 5xx
response), a subclass of `runloop.APIStatusError` is raised, containing `status_code` and `response` properties.
response), a subclass of `runloop_minus_api_minus_client.APIStatusError` is raised, containing `status_code` and `response` properties.

All errors inherit from `runloop.APIError`.
All errors inherit from `runloop_minus_api_minus_client.APIError`.

```python
import runloop
from runloop import Runloop
import runloop_minus_api_minus_client
from runloop_minus_api_minus_client import Runloop

client = Runloop()

try:
client.devboxes.create()
except runloop.APIConnectionError as e:
except runloop_minus_api_minus_client.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
except runloop.RateLimitError as e:
except runloop_minus_api_minus_client.RateLimitError as e:
print("A 429 status code was received; we should back off a bit.")
except runloop.APIStatusError as e:
except runloop_minus_api_minus_client.APIStatusError as e:
print("Another non-200-range status code was received")
print(e.status_code)
print(e.response)
Expand Down Expand Up @@ -125,7 +125,7 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
You can use the `max_retries` option to configure or disable retry settings:

```python
from runloop import Runloop
from runloop_minus_api_minus_client import Runloop

# Configure the default for all requests:
client = Runloop(
Expand All @@ -143,7 +143,7 @@ By default requests time out after 1 minute. You can configure this with a `time
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:

```python
from runloop import Runloop
from runloop_minus_api_minus_client import Runloop

# Configure the default for all requests:
client = Runloop(
Expand Down Expand Up @@ -193,7 +193,7 @@ if response.my_field is None:
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,

```py
from runloop import Runloop
from runloop_minus_api_minus_client import Runloop

client = Runloop()
response = client.devboxes.with_raw_response.create()
Expand All @@ -203,9 +203,9 @@ devbox = response.parse() # get the object that `devboxes.create()` would have
print(devbox.id)
```

These methods return an [`APIResponse`](https://github.com/runloopai/api-client-python/tree/main/src/runloop/_response.py) object.
These methods return an [`APIResponse`](https://github.com/runloopai/api-client-python/tree/main/src/runloop_minus_api_minus_client/_response.py) object.

The async client returns an [`AsyncAPIResponse`](https://github.com/runloopai/api-client-python/tree/main/src/runloop/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
The async client returns an [`AsyncAPIResponse`](https://github.com/runloopai/api-client-python/tree/main/src/runloop_minus_api_minus_client/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.

#### `.with_streaming_response`

Expand Down Expand Up @@ -267,7 +267,7 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality

```python
from runloop import Runloop, DefaultHttpxClient
from runloop_minus_api_minus_client import Runloop, DefaultHttpxClient

client = Runloop(
# Or use the `RUNLOOP_BASE_URL` env var
Expand Down
51 changes: 29 additions & 22 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,91 +1,98 @@
# Shared Types

```python
from runloop.types import FunctionInvocationDetailView, ProjectLogsView
from runloop_minus_api_minus_client.types import FunctionInvocationDetailView, ProjectLogsView
```

# Devboxes

Types:

```python
from runloop.types import DevboxExecutionDetailView, DevboxListView, DevboxView
from runloop_minus_api_minus_client.types import (
DevboxExecutionDetailView,
DevboxListView,
DevboxView,
)
```

Methods:

- <code title="post /v1/devboxes">client.devboxes.<a href="./src/runloop/resources/devboxes/devboxes.py">create</a>(\*\*<a href="src/runloop/types/devbox_create_params.py">params</a>) -> <a href="./src/runloop/types/devbox_view.py">DevboxView</a></code>
- <code title="get /v1/devboxes/{id}">client.devboxes.<a href="./src/runloop/resources/devboxes/devboxes.py">retrieve</a>(id) -> <a href="./src/runloop/types/devbox_view.py">DevboxView</a></code>
- <code title="get /v1/devboxes">client.devboxes.<a href="./src/runloop/resources/devboxes/devboxes.py">list</a>(\*\*<a href="src/runloop/types/devbox_list_params.py">params</a>) -> <a href="./src/runloop/types/devbox_list_view.py">DevboxListView</a></code>
- <code title="post /v1/devboxes/{id}/execute_sync">client.devboxes.<a href="./src/runloop/resources/devboxes/devboxes.py">execute_sync</a>(id) -> <a href="./src/runloop/types/devbox_execution_detail_view.py">DevboxExecutionDetailView</a></code>
- <code title="post /v1/devboxes/{id}/shutdown">client.devboxes.<a href="./src/runloop/resources/devboxes/devboxes.py">shutdown</a>(id) -> <a href="./src/runloop/types/devbox_view.py">DevboxView</a></code>
- <code title="post /v1/devboxes">client.devboxes.<a href="./src/runloop_minus_api_minus_client/resources/devboxes/devboxes.py">create</a>(\*\*<a href="src/runloop_minus_api_minus_client/types/devbox_create_params.py">params</a>) -> <a href="./src/runloop_minus_api_minus_client/types/devbox_view.py">DevboxView</a></code>
- <code title="get /v1/devboxes/{id}">client.devboxes.<a href="./src/runloop_minus_api_minus_client/resources/devboxes/devboxes.py">retrieve</a>(id) -> <a href="./src/runloop_minus_api_minus_client/types/devbox_view.py">DevboxView</a></code>
- <code title="get /v1/devboxes">client.devboxes.<a href="./src/runloop_minus_api_minus_client/resources/devboxes/devboxes.py">list</a>(\*\*<a href="src/runloop_minus_api_minus_client/types/devbox_list_params.py">params</a>) -> <a href="./src/runloop_minus_api_minus_client/types/devbox_list_view.py">DevboxListView</a></code>
- <code title="post /v1/devboxes/{id}/execute_sync">client.devboxes.<a href="./src/runloop_minus_api_minus_client/resources/devboxes/devboxes.py">execute_sync</a>(id) -> <a href="./src/runloop_minus_api_minus_client/types/devbox_execution_detail_view.py">DevboxExecutionDetailView</a></code>
- <code title="post /v1/devboxes/{id}/shutdown">client.devboxes.<a href="./src/runloop_minus_api_minus_client/resources/devboxes/devboxes.py">shutdown</a>(id) -> <a href="./src/runloop_minus_api_minus_client/types/devbox_view.py">DevboxView</a></code>

## Logs

Types:

```python
from runloop.types.devboxes import DevboxLogsListView
from runloop_minus_api_minus_client.types.devboxes import DevboxLogsListView
```

Methods:

- <code title="get /v1/devboxes/{id}/logs">client.devboxes.logs.<a href="./src/runloop/resources/devboxes/logs.py">list</a>(id) -> <a href="./src/runloop/types/devboxes/devbox_logs_list_view.py">DevboxLogsListView</a></code>
- <code title="get /v1/devboxes/{id}/logs">client.devboxes.logs.<a href="./src/runloop_minus_api_minus_client/resources/devboxes/logs.py">list</a>(id) -> <a href="./src/runloop_minus_api_minus_client/types/devboxes/devbox_logs_list_view.py">DevboxLogsListView</a></code>

# Functions

Types:

```python
from runloop.types import FunctionListView
from runloop_minus_api_minus_client.types import FunctionListView
```

Methods:

- <code title="get /v1/functions">client.functions.<a href="./src/runloop/resources/functions/functions.py">list</a>() -> <a href="./src/runloop/types/function_list_view.py">FunctionListView</a></code>
- <code title="post /v1/functions/{project_name}/{function_name}/invoke_async">client.functions.<a href="./src/runloop/resources/functions/functions.py">invoke_async</a>(function_name, \*, project_name, \*\*<a href="src/runloop/types/function_invoke_async_params.py">params</a>) -> <a href="./src/runloop/types/shared/function_invocation_detail_view.py">FunctionInvocationDetailView</a></code>
- <code title="post /v1/functions/{project_name}/{function_name}/invoke_sync">client.functions.<a href="./src/runloop/resources/functions/functions.py">invoke_sync</a>(function_name, \*, project_name, \*\*<a href="src/runloop/types/function_invoke_sync_params.py">params</a>) -> <a href="./src/runloop/types/shared/function_invocation_detail_view.py">FunctionInvocationDetailView</a></code>
- <code title="get /v1/functions">client.functions.<a href="./src/runloop_minus_api_minus_client/resources/functions/functions.py">list</a>() -> <a href="./src/runloop_minus_api_minus_client/types/function_list_view.py">FunctionListView</a></code>
- <code title="post /v1/functions/{project_name}/{function_name}/invoke_async">client.functions.<a href="./src/runloop_minus_api_minus_client/resources/functions/functions.py">invoke_async</a>(function_name, \*, project_name, \*\*<a href="src/runloop_minus_api_minus_client/types/function_invoke_async_params.py">params</a>) -> <a href="./src/runloop_minus_api_minus_client/types/shared/function_invocation_detail_view.py">FunctionInvocationDetailView</a></code>
- <code title="post /v1/functions/{project_name}/{function_name}/invoke_sync">client.functions.<a href="./src/runloop_minus_api_minus_client/resources/functions/functions.py">invoke_sync</a>(function_name, \*, project_name, \*\*<a href="src/runloop_minus_api_minus_client/types/function_invoke_sync_params.py">params</a>) -> <a href="./src/runloop_minus_api_minus_client/types/shared/function_invocation_detail_view.py">FunctionInvocationDetailView</a></code>

## Invocations

Types:

```python
from runloop.types.functions import FunctionInvocationListView, KillOperationResponse
from runloop_minus_api_minus_client.types.functions import (
FunctionInvocationListView,
KillOperationResponse,
)
```

Methods:

- <code title="get /v1/functions/invocations/{invocationId}">client.functions.invocations.<a href="./src/runloop/resources/functions/invocations/invocations.py">retrieve</a>(invocation_id) -> <a href="./src/runloop/types/shared/function_invocation_detail_view.py">FunctionInvocationDetailView</a></code>
- <code title="get /v1/functions/invocations">client.functions.invocations.<a href="./src/runloop/resources/functions/invocations/invocations.py">list</a>() -> <a href="./src/runloop/types/functions/function_invocation_list_view.py">FunctionInvocationListView</a></code>
- <code title="post /v1/functions/invocations/{invocationId}/kill">client.functions.invocations.<a href="./src/runloop/resources/functions/invocations/invocations.py">kill</a>(invocation_id) -> <a href="./src/runloop/types/functions/kill_operation_response.py">object</a></code>
- <code title="get /v1/functions/invocations/{invocationId}">client.functions.invocations.<a href="./src/runloop_minus_api_minus_client/resources/functions/invocations/invocations.py">retrieve</a>(invocation_id) -> <a href="./src/runloop_minus_api_minus_client/types/shared/function_invocation_detail_view.py">FunctionInvocationDetailView</a></code>
- <code title="get /v1/functions/invocations">client.functions.invocations.<a href="./src/runloop_minus_api_minus_client/resources/functions/invocations/invocations.py">list</a>() -> <a href="./src/runloop_minus_api_minus_client/types/functions/function_invocation_list_view.py">FunctionInvocationListView</a></code>
- <code title="post /v1/functions/invocations/{invocationId}/kill">client.functions.invocations.<a href="./src/runloop_minus_api_minus_client/resources/functions/invocations/invocations.py">kill</a>(invocation_id) -> <a href="./src/runloop_minus_api_minus_client/types/functions/kill_operation_response.py">object</a></code>

### Spans

Types:

```python
from runloop.types.functions.invocations import InvocationSpanListView
from runloop_minus_api_minus_client.types.functions.invocations import InvocationSpanListView
```

Methods:

- <code title="get /v1/functions/invocations/{invocationId}/spans">client.functions.invocations.spans.<a href="./src/runloop/resources/functions/invocations/spans.py">list</a>(invocation_id) -> <a href="./src/runloop/types/functions/invocations/invocation_span_list_view.py">InvocationSpanListView</a></code>
- <code title="get /v1/functions/invocations/{invocationId}/spans">client.functions.invocations.spans.<a href="./src/runloop_minus_api_minus_client/resources/functions/invocations/spans.py">list</a>(invocation_id) -> <a href="./src/runloop_minus_api_minus_client/types/functions/invocations/invocation_span_list_view.py">InvocationSpanListView</a></code>

# Projects

Types:

```python
from runloop.types import ProjectListView
from runloop_minus_api_minus_client.types import ProjectListView
```

Methods:

- <code title="get /v1/projects">client.projects.<a href="./src/runloop/resources/projects/projects.py">list</a>() -> <a href="./src/runloop/types/project_list_view.py">ProjectListView</a></code>
- <code title="get /v1/projects">client.projects.<a href="./src/runloop_minus_api_minus_client/resources/projects/projects.py">list</a>() -> <a href="./src/runloop_minus_api_minus_client/types/project_list_view.py">ProjectListView</a></code>

## Logs

Methods:

- <code title="get /v1/projects/{id}/logs">client.projects.logs.<a href="./src/runloop/resources/projects/logs.py">list</a>(id) -> <a href="./src/runloop/types/shared/project_logs_view.py">ProjectLogsView</a></code>
- <code title="get /v1/projects/{id}/logs">client.projects.logs.<a href="./src/runloop_minus_api_minus_client/resources/projects/logs.py">list</a>(id) -> <a href="./src/runloop_minus_api_minus_client/types/shared/project_logs_view.py">ProjectLogsView</a></code>
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ show_error_codes = True
# Exclude _files.py because mypy isn't smart enough to apply
# the correct type narrowing and as this is an internal module
# it's fine to just use Pyright.
exclude = ^(src/runloop/_files\.py|_dev/.*\.py)$
exclude = ^(src/runloop_minus_api_minus_client/_files\.py|_dev/.*\.py)$

strict_equality = True
implicit_reexport = True
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "runloop"
name = "runloop-api-client"
version = "0.0.1-alpha.0"
description = "The official Python library for the runloop API"
dynamic = ["readme"]
Expand Down Expand Up @@ -84,7 +84,7 @@ typecheck = { chain = [
"typecheck:mypy"
]}
"typecheck:pyright" = "pyright"
"typecheck:verify-types" = "pyright --verifytypes runloop --ignoreexternal"
"typecheck:verify-types" = "pyright --verifytypes runloop_minus_api_minus_client --ignoreexternal"
"typecheck:mypy" = "mypy ."

[build-system]
Expand All @@ -97,7 +97,7 @@ include = [
]

[tool.hatch.build.targets.wheel]
packages = ["src/runloop"]
packages = ["src/runloop_minus_api_minus_client"]

[tool.hatch.metadata.hooks.fancy-pypi-readme]
content-type = "text/markdown"
Expand Down Expand Up @@ -187,7 +187,7 @@ length-sort = true
length-sort-straight = true
combine-as-imports = true
extra-standard-library = ["typing_extensions"]
known-first-party = ["runloop", "tests"]
known-first-party = ["runloop_minus_api_minus_client", "tests"]

[tool.ruff.per-file-ignores]
"bin/**.py" = ["T201", "T203"]
Expand Down
2 changes: 1 addition & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
],
"release-type": "python",
"extra-files": [
"src/runloop/_version.py"
"src/runloop_minus_api_minus_client/_version.py"
]
}
12 changes: 6 additions & 6 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ annotated-types==0.6.0
# via pydantic
anyio==4.1.0
# via httpx
# via runloop
# via runloop-api-client
argcomplete==3.1.2
# via nox
attrs==23.1.0
Expand All @@ -26,7 +26,7 @@ dirty-equals==0.6.0
distlib==0.3.7
# via virtualenv
distro==1.8.0
# via runloop
# via runloop-api-client
exceptiongroup==1.1.3
# via anyio
filelock==3.12.4
Expand All @@ -37,7 +37,7 @@ httpcore==1.0.2
# via httpx
httpx==0.25.2
# via respx
# via runloop
# via runloop-api-client
idna==3.4
# via anyio
# via httpx
Expand All @@ -60,7 +60,7 @@ pluggy==1.3.0
py==1.11.0
# via pytest
pydantic==2.7.1
# via runloop
# via runloop-api-client
pydantic-core==2.18.2
# via pydantic
pyright==1.1.364
Expand All @@ -80,7 +80,7 @@ six==1.16.0
sniffio==1.3.0
# via anyio
# via httpx
# via runloop
# via runloop-api-client
time-machine==2.9.0
tomli==2.0.1
# via mypy
Expand All @@ -89,7 +89,7 @@ typing-extensions==4.8.0
# via mypy
# via pydantic
# via pydantic-core
# via runloop
# via runloop-api-client
virtualenv==20.24.5
# via nox
zipp==3.17.0
Expand Down
12 changes: 6 additions & 6 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ annotated-types==0.6.0
# via pydantic
anyio==4.1.0
# via httpx
# via runloop
# via runloop-api-client
certifi==2023.7.22
# via httpcore
# via httpx
distro==1.8.0
# via runloop
# via runloop-api-client
exceptiongroup==1.1.3
# via anyio
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.25.2
# via runloop
# via runloop-api-client
idna==3.4
# via anyio
# via httpx
pydantic==2.7.1
# via runloop
# via runloop-api-client
pydantic-core==2.18.2
# via pydantic
sniffio==1.3.0
# via anyio
# via httpx
# via runloop
# via runloop-api-client
typing-extensions==4.8.0
# via pydantic
# via pydantic-core
# via runloop
# via runloop-api-client
Loading