Skip to content

Commit

Permalink
Merge pull request #10 from riza-io/release-please--branches--main--c…
Browse files Browse the repository at this point in the history
…hanges--next

release: 0.1.0-alpha.3
  • Loading branch information
kyleconroy authored Apr 18, 2024
2 parents 6c3ba42 + ffe5924 commit 2621e67
Show file tree
Hide file tree
Showing 54 changed files with 6,790 additions and 216 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ jobs:
- name: Ensure importable
run: |
rye run python -c 'import riza'
rye run python -c 'import rizaio'
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.2"
".": "0.1.0-alpha.3"
}
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 0.1.0-alpha.3 (2024-04-18)

Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/riza-io/riza-api-python/compare/v0.1.0-alpha.2...v0.1.0-alpha.3)

### Features

* **api:** update via SDK Studio ([#11](https://github.com/riza-io/riza-api-python/issues/11)) ([b1a00ad](https://github.com/riza-io/riza-api-python/commit/b1a00adc91789b33848b241db2df14fa10e21cdc))
* **api:** update via SDK Studio ([#12](https://github.com/riza-io/riza-api-python/issues/12)) ([7abe327](https://github.com/riza-io/riza-api-python/commit/7abe3271497b4b25ebae4968f9e5983d23cd5509))
* **api:** update via SDK Studio ([#7](https://github.com/riza-io/riza-api-python/issues/7)) ([2f007bc](https://github.com/riza-io/riza-api-python/commit/2f007bc3355bfa36e7e056fd890635f4549e8d7c))
* **api:** update via SDK Studio ([#9](https://github.com/riza-io/riza-api-python/issues/9)) ([9608f97](https://github.com/riza-io/riza-api-python/commit/9608f9709fe4df610841daae63170dd47740b8b5))

## 0.1.0-alpha.2 (2024-04-18)

Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/riza-io/riza-api-python/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)
Expand Down
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/riza/lib/` and `examples/` directories are exceptions and will never be overridden.
`src/rizaio/lib/` and `examples/` directories are exceptions and will never be overridden.

## Adding and running examples

Expand Down
64 changes: 32 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ The full API of this library can be found in [api.md](api.md).

```python
import os
from riza import Riza
from rizaio import Riza

client = Riza(
# This is the default and can be omitted
auth_token=os.environ.get("RIZA_AUTH_TOKEN"),
api_key=os.environ.get("RIZA_API_KEY"),
)

v1_execute_response = client.v1.execute()
print(v1_execute_response.exit_code)
code_execute_response = client.code.execute()
print(code_execute_response.exit_code)
```

While you can provide a `auth_token` keyword argument,
While you can provide an `api_key` keyword argument,
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
to add `RIZA_AUTH_TOKEN="My Auth Token"` to your `.env` file
so that your Auth Token is not stored in source control.
to add `RIZA_API_KEY="My API Key"` to your `.env` file
so that your API Key is not stored in source control.

## Async usage

Expand All @@ -48,17 +48,17 @@ Simply import `AsyncRiza` instead of `Riza` and use `await` with each API call:
```python
import os
import asyncio
from riza import AsyncRiza
from rizaio import AsyncRiza

client = AsyncRiza(
# This is the default and can be omitted
auth_token=os.environ.get("RIZA_AUTH_TOKEN"),
api_key=os.environ.get("RIZA_API_KEY"),
)


async def main() -> None:
v1_execute_response = await client.v1.execute()
print(v1_execute_response.exit_code)
code_execute_response = await client.code.execute()
print(code_execute_response.exit_code)


asyncio.run(main())
Expand All @@ -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 `riza.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 `rizaio.APIConnectionError` is raised.

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

All errors inherit from `riza.APIError`.
All errors inherit from `rizaio.APIError`.

```python
import riza
from riza import Riza
import rizaio
from rizaio import Riza

client = Riza()

try:
client.v1.execute()
except riza.APIConnectionError as e:
client.code.execute()
except rizaio.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
except riza.RateLimitError as e:
except rizaio.RateLimitError as e:
print("A 429 status code was received; we should back off a bit.")
except riza.APIStatusError as e:
except rizaio.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 riza import Riza
from rizaio import Riza

# Configure the default for all requests:
client = Riza(
Expand All @@ -134,7 +134,7 @@ client = Riza(
)

# Or, configure per-request:
client.with_options(max_retries=5).v1.execute()
client.with_options(max_retries=5).code.execute()
```

### Timeouts
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 riza import Riza
from rizaio import Riza

# Configure the default for all requests:
client = Riza(
Expand All @@ -157,7 +157,7 @@ client = Riza(
)

# Override per-request:
client.with_options(timeout=5 * 1000).v1.execute()
client.with_options(timeout=5 * 1000).code.execute()
```

On timeout, an `APITimeoutError` is thrown.
Expand Down Expand Up @@ -193,19 +193,19 @@ 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 riza import Riza
from rizaio import Riza

client = Riza()
response = client.v1.with_raw_response.execute()
response = client.code.with_raw_response.execute()
print(response.headers.get('X-My-Header'))

v1 = response.parse() # get the object that `v1.execute()` would have returned
print(v1.exit_code)
code = response.parse() # get the object that `code.execute()` would have returned
print(code.exit_code)
```

These methods return an [`APIResponse`](https://github.com/riza-io/riza-api-python/tree/main/src/riza/_response.py) object.
These methods return an [`APIResponse`](https://github.com/riza-io/riza-api-python/tree/main/src/rizaio/_response.py) object.

The async client returns an [`AsyncAPIResponse`](https://github.com/riza-io/riza-api-python/tree/main/src/riza/_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/riza-io/riza-api-python/tree/main/src/rizaio/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.

#### `.with_streaming_response`

Expand All @@ -214,7 +214,7 @@ The above interface eagerly reads the full response body when you make the reque
To stream the response body, use `.with_streaming_response` instead, which requires a context manager and only reads the response body once you call `.read()`, `.text()`, `.json()`, `.iter_bytes()`, `.iter_text()`, `.iter_lines()` or `.parse()`. In the async client, these are async methods.

```python
with client.v1.with_streaming_response.execute() as response:
with client.code.with_streaming_response.execute() as response:
print(response.headers.get("X-My-Header"))

for line in response.iter_lines():
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/#client-instances) functionality

```python
from riza import Riza, DefaultHttpxClient
from rizaio import Riza, DefaultHttpxClient

client = Riza(
# Or use the `RIZA_BASE_URL` env var
Expand Down
6 changes: 3 additions & 3 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# V1
# Code

Types:

```python
from riza.types import V1ExecuteResponse
from rizaio.types import CodeExecuteResponse
```

Methods:

- <code title="post /v1/execute">client.v1.<a href="./src/riza/resources/v1.py">execute</a>(\*\*<a href="src/riza/types/v1_execute_params.py">params</a>) -> <a href="./src/riza/types/v1_execute_response.py">V1ExecuteResponse</a></code>
- <code title="post /v1/execute">client.code.<a href="./src/rizaio/resources/code.py">execute</a>(\*\*<a href="src/rizaio/types/code_execute_params.py">params</a>) -> <a href="./src/rizaio/types/code_execute_response.py">CodeExecuteResponse</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/riza/_files\.py|_dev/.*\.py)$
exclude = ^(src/rizaio/_files\.py|_dev/.*\.py)$

strict_equality = True
implicit_reexport = True
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "rizaio"
version = "0.1.0-alpha.2"
version = "0.1.0-alpha.3"
description = "The official Python library for the riza API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -48,7 +48,7 @@ Repository = "https://github.com/riza-io/riza-api-python"
managed = true
# version pins are in requirements-dev.lock
dev-dependencies = [
"pyright",
"pyright>=1.1.359",
"mypy",
"respx",
"pytest",
Expand Down Expand Up @@ -84,7 +84,7 @@ typecheck = { chain = [
"typecheck:mypy"
]}
"typecheck:pyright" = "pyright"
"typecheck:verify-types" = "pyright --verifytypes riza --ignoreexternal"
"typecheck:verify-types" = "pyright --verifytypes rizaio --ignoreexternal"
"typecheck:mypy" = "mypy ."

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

[tool.hatch.build.targets.wheel]
packages = ["src/riza"]
packages = ["src/rizaio"]

[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 = ["riza", "tests"]
known-first-party = ["rizaio", "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/riza/_version.py"
"src/rizaio/_version.py"
]
}
2 changes: 1 addition & 1 deletion requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pydantic==2.4.2
# via rizaio
pydantic-core==2.10.1
# via pydantic
pyright==1.1.353
pyright==1.1.359
pytest==7.1.1
# via pytest-asyncio
pytest-asyncio==0.21.1
Expand Down
83 changes: 83 additions & 0 deletions src/rizaio/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from . import types
from ._types import NOT_GIVEN, NoneType, NotGiven, Transport, ProxiesTypes
from ._utils import file_from_path
from ._client import Riza, Client, Stream, Timeout, AsyncRiza, Transport, AsyncClient, AsyncStream, RequestOptions
from ._models import BaseModel
from ._version import __title__, __version__
from ._response import APIResponse as APIResponse, AsyncAPIResponse as AsyncAPIResponse
from ._constants import DEFAULT_TIMEOUT, DEFAULT_MAX_RETRIES, DEFAULT_CONNECTION_LIMITS
from ._exceptions import (
APIError,
RizaError,
ConflictError,
NotFoundError,
APIStatusError,
RateLimitError,
APITimeoutError,
BadRequestError,
APIConnectionError,
AuthenticationError,
InternalServerError,
PermissionDeniedError,
UnprocessableEntityError,
APIResponseValidationError,
)
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
from ._utils._logs import setup_logging as _setup_logging

__all__ = [
"types",
"__version__",
"__title__",
"NoneType",
"Transport",
"ProxiesTypes",
"NotGiven",
"NOT_GIVEN",
"RizaError",
"APIError",
"APIStatusError",
"APITimeoutError",
"APIConnectionError",
"APIResponseValidationError",
"BadRequestError",
"AuthenticationError",
"PermissionDeniedError",
"NotFoundError",
"ConflictError",
"UnprocessableEntityError",
"RateLimitError",
"InternalServerError",
"Timeout",
"RequestOptions",
"Client",
"AsyncClient",
"Stream",
"AsyncStream",
"Riza",
"AsyncRiza",
"file_from_path",
"BaseModel",
"DEFAULT_TIMEOUT",
"DEFAULT_MAX_RETRIES",
"DEFAULT_CONNECTION_LIMITS",
"DefaultHttpxClient",
"DefaultAsyncHttpxClient",
]

_setup_logging()

# Update the __module__ attribute for exported symbols so that
# error messages point to this module instead of the module
# it was originally defined in, e.g.
# rizaio._exceptions.NotFoundError -> rizaio.NotFoundError
__locals = locals()
for __name in __all__:
if not __name.startswith("__"):
try:
__locals[__name].__module__ = "rizaio"
except (TypeError, AttributeError):
# Some of our exported symbols are builtins which we can't set attributes for.
pass
Loading

0 comments on commit 2621e67

Please sign in to comment.