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
22 changes: 19 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/luma_ai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v4

Expand All @@ -34,17 +35,31 @@ jobs:
- name: Run lints
run: ./scripts/lint

upload:
if: github.repository == 'stainless-sdks/luma_ai-python'
build:
if: github.repository == 'stainless-sdks/luma_ai-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork)
timeout-minutes: 10
name: upload
name: build
permissions:
contents: read
id-token: write
runs-on: depot-ubuntu-24.04
steps:
- uses: actions/checkout@v4

- name: Install Rye
run: |
curl -sSf https://rye.astral.sh/get | bash
echo "$HOME/.rye/shims" >> $GITHUB_PATH
env:
RYE_VERSION: '0.44.0'
RYE_INSTALL_OPTION: '--yes'

- name: Install dependencies
run: rye sync --all-features

- name: Run build
run: rye build

- name: Get GitHub OIDC Token
id: github-oidc
uses: actions/github-script@v6
Expand All @@ -62,6 +77,7 @@ jobs:
timeout-minutes: 10
name: test
runs-on: ${{ github.repository == 'stainless-sdks/luma_ai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.15.0"
".": "1.15.1"
}
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
# Changelog

## 1.15.1 (2025-07-11)

Full Changelog: [v1.15.0...v1.15.1](https://github.com/lumalabs/lumaai-python/compare/v1.15.0...v1.15.1)

### Bug Fixes

* **ci:** correct conditional ([7cd4571](https://github.com/lumalabs/lumaai-python/commit/7cd4571c6553c4f540bff998e14dc871cc58271e))
* **ci:** release-doctor — report correct token name ([adda4e4](https://github.com/lumalabs/lumaai-python/commit/adda4e42e705f849c2c73e6ebb61f0753bd23745))
* **parsing:** correctly handle nested discriminated unions ([d97d872](https://github.com/lumalabs/lumaai-python/commit/d97d872c579e363844a941cc8318d5e54de342c5))


### Chores

* **ci:** change upload type ([351a0e8](https://github.com/lumalabs/lumaai-python/commit/351a0e8c979c206a8f94a5b68f1fdd5793bcb278))
* **ci:** only run for pushes and fork pull requests ([50b8ecb](https://github.com/lumalabs/lumaai-python/commit/50b8ecb28a5e6c65e681467b9787b7bc23661556))
* **internal:** bump pinned h11 dep ([2f98b9a](https://github.com/lumalabs/lumaai-python/commit/2f98b9a4afdcb76c12221c660d43dbdaff9741af))
* **internal:** codegen related update ([b89b147](https://github.com/lumalabs/lumaai-python/commit/b89b1470c88c4825b3b52ab15fccd8a1587334ba))
* **package:** mark python 3.13 as supported ([7f37491](https://github.com/lumalabs/lumaai-python/commit/7f374916e24833705e85f06788ea24c5eec15b43))
* **readme:** fix version rendering on pypi ([24f04ae](https://github.com/lumalabs/lumaai-python/commit/24f04aeeca03973aece5756f563cb48b4fd0e8a1))

## 1.15.0 (2025-06-25)

Full Changelog: [v1.14.0...v1.15.0](https://github.com/lumalabs/lumaai-python/compare/v1.14.0...v1.15.0)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# LumaAI Python API library

[![PyPI version](<https://img.shields.io/pypi/v/lumaai.svg?label=pypi%20(stable)>)](https://pypi.org/project/lumaai/)
<!-- prettier-ignore -->
[![PyPI version](https://img.shields.io/pypi/v/lumaai.svg?label=pypi%20(stable))](https://pypi.org/project/lumaai/)

The LumaAI Python library provides convenient access to the LumaAI REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
Expand Down
2 changes: 1 addition & 1 deletion bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
errors=()

if [ -z "${PYPI_TOKEN}" ]; then
errors+=("The LUMAAI_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
errors+=("The PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
fi

lenErrors=${#errors[@]}
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "lumaai"
version = "1.15.0"
version = "1.15.1"
description = "The official Python library for the lumaai API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand All @@ -24,6 +24,7 @@ classifiers = [
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Operating System :: OS Independent",
"Operating System :: POSIX",
"Operating System :: MacOS",
Expand Down
6 changes: 3 additions & 3 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ filelock==3.12.4
frozenlist==1.6.2
# via aiohttp
# via aiosignal
h11==0.14.0
h11==0.16.0
# via httpcore
httpcore==1.0.2
httpcore==1.0.9
# via httpx
httpx==0.28.1
# via httpx-aiohttp
# via lumaai
# via respx
httpx-aiohttp==0.1.6
httpx-aiohttp==0.1.8
# via lumaai
idna==3.4
# via anyio
Expand Down
6 changes: 3 additions & 3 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ exceptiongroup==1.2.2
frozenlist==1.6.2
# via aiohttp
# via aiosignal
h11==0.14.0
h11==0.16.0
# via httpcore
httpcore==1.0.2
httpcore==1.0.9
# via httpx
httpx==0.28.1
# via httpx-aiohttp
# via lumaai
httpx-aiohttp==0.1.6
httpx-aiohttp==0.1.8
# via lumaai
idna==3.4
# via anyio
Expand Down
12 changes: 7 additions & 5 deletions scripts/utils/upload-artifact.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env bash
set -exuo pipefail

RESPONSE=$(curl -X POST "$URL" \
FILENAME=$(basename dist/*.whl)

RESPONSE=$(curl -X POST "$URL?filename=$FILENAME" \
-H "Authorization: Bearer $AUTH" \
-H "Content-Type: application/json")

Expand All @@ -12,13 +14,13 @@ if [[ "$SIGNED_URL" == "null" ]]; then
exit 1
fi

UPLOAD_RESPONSE=$(tar -cz . | curl -v -X PUT \
-H "Content-Type: application/gzip" \
--data-binary @- "$SIGNED_URL" 2>&1)
UPLOAD_RESPONSE=$(curl -v -X PUT \
-H "Content-Type: binary/octet-stream" \
--data-binary "@dist/$FILENAME" "$SIGNED_URL" 2>&1)

if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then
echo -e "\033[32mUploaded build to Stainless storage.\033[0m"
echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/luma_ai-python/$SHA'\033[0m"
echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/luma_ai-python/$SHA/$FILENAME'\033[0m"
else
echo -e "\033[31mFailed to upload artifact.\033[0m"
exit 1
Expand Down
13 changes: 8 additions & 5 deletions src/lumaai/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import os
import inspect
from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast
from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, Optional, cast
from datetime import date, datetime
from typing_extensions import (
List,
Unpack,
Literal,
ClassVar,
Expand Down Expand Up @@ -366,7 +367,7 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
if type_ is None:
raise RuntimeError(f"Unexpected field type is None for {key}")

return construct_type(value=value, type_=type_)
return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))


def is_basemodel(type_: type) -> bool:
Expand Down Expand Up @@ -420,7 +421,7 @@ def construct_type_unchecked(*, value: object, type_: type[_T]) -> _T:
return cast(_T, construct_type(value=value, type_=type_))


def construct_type(*, value: object, type_: object) -> object:
def construct_type(*, value: object, type_: object, metadata: Optional[List[Any]] = None) -> object:
"""Loose coercion to the expected type with construction of nested values.

If the given value does not match the expected type then it is returned as-is.
Expand All @@ -438,8 +439,10 @@ def construct_type(*, value: object, type_: object) -> object:
type_ = type_.__value__ # type: ignore[unreachable]

# unwrap `Annotated[T, ...]` -> `T`
if is_annotated_type(type_):
meta: tuple[Any, ...] = get_args(type_)[1:]
if metadata is not None:
meta: tuple[Any, ...] = tuple(metadata)
elif is_annotated_type(type_):
meta = get_args(type_)[1:]
type_ = extract_type_arg(type_, 0)
else:
meta = tuple()
Expand Down
2 changes: 1 addition & 1 deletion src/lumaai/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "lumaai"
__version__ = "1.15.0" # x-release-please-version
__version__ = "1.15.1" # x-release-please-version
45 changes: 45 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,3 +889,48 @@ class ModelB(BaseModel):
)

assert isinstance(m, ModelB)


def test_nested_discriminated_union() -> None:
class InnerType1(BaseModel):
type: Literal["type_1"]

class InnerModel(BaseModel):
inner_value: str

class InnerType2(BaseModel):
type: Literal["type_2"]
some_inner_model: InnerModel

class Type1(BaseModel):
base_type: Literal["base_type_1"]
value: Annotated[
Union[
InnerType1,
InnerType2,
],
PropertyInfo(discriminator="type"),
]

class Type2(BaseModel):
base_type: Literal["base_type_2"]

T = Annotated[
Union[
Type1,
Type2,
],
PropertyInfo(discriminator="base_type"),
]

model = construct_type(
type_=T,
value={
"base_type": "base_type_1",
"value": {
"type": "type_2",
},
},
)
assert isinstance(model, Type1)
assert isinstance(model.value, InnerType2)