Skip to content

Commit ebd5166

Browse files
feat: Add optimization package stub (#109)
**Requirements** - [x] I have added test coverage for new or changed functionality - [x] I have followed the repository's [pull request submission guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests) - [x] I have validated my changes against all supported platform versions **Describe the solution you've provided** implements the package stub for the optimization package. Raises a NotImplemented error at the moment. Version set to 0.0.0 **Describe alternatives you've considered** This is the first commit for this package; no alternatives considered. **Additional context** This package will be augmented with the optimization method for AI Config agents. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk: introduces a new stub package and CI/release plumbing without changing existing runtime behavior, but it does add new publish/release jobs that could affect release automation if misconfigured. > > **Overview** > Adds a new `packages/optimization` Python package scaffold (`launchdarkly-server-sdk-ai-optimization`) with basic project metadata, build/lint/test `Makefile` targets, a placeholder `ApiAgentOptimizationClient.optimize()` that raises `NotImplementedError`, and a minimal smoke test. > > Wires the new package into the monorepo and automation by adding it to the uv workspace, expanding CI to run/build it on Linux and Windows across Python 3.9–3.13, and updating `release-please` config/workflow to version, publish to PyPI, and generate SLSA provenance for `packages/optimization`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit b9a5601. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
2 parents e6e4907 + b9a5601 commit ebd5166

13 files changed

Lines changed: 277 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,45 @@ jobs:
138138

139139
- name: Run tests
140140
run: make -C packages/ai-providers/server-ai-openai test
141+
142+
server-ai-optimization-linux:
143+
runs-on: ubuntu-latest
144+
strategy:
145+
matrix:
146+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
147+
148+
steps:
149+
- uses: actions/checkout@v4
150+
151+
- uses: ./.github/actions/ci
152+
with:
153+
workspace_path: packages/optimization
154+
python_version: ${{ matrix.python-version }}
155+
156+
- uses: ./.github/actions/build
157+
with:
158+
workspace_path: packages/optimization
159+
160+
server-ai-optimization-windows:
161+
runs-on: windows-latest
162+
defaults:
163+
run:
164+
shell: powershell
165+
166+
strategy:
167+
matrix:
168+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
169+
170+
steps:
171+
- uses: actions/checkout@v4
172+
173+
- name: Set up uv
174+
uses: astral-sh/setup-uv@6ee6290f1cbc4156c0bdd66691b2c144ef8df19a # v7.4
175+
with:
176+
python-version: ${{ matrix.python-version }}
177+
178+
- name: Install dependencies
179+
run: make -C packages/optimization install
180+
181+
- name: Run tests
182+
run: make -C packages/optimization test

.github/workflows/release-please.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ on:
2727
- packages/sdk/server-ai
2828
- packages/ai-providers/server-ai-langchain
2929
- packages/ai-providers/server-ai-openai
30+
- packages/optimization
3031
dry_run:
3132
description: 'Is this a dry run. If so no package will be published.'
3233
type: boolean
@@ -46,6 +47,8 @@ jobs:
4647
package-server-ai-langchain-tag-name: ${{ steps.release.outputs['packages/ai-providers/server-ai-langchain--tag_name'] }}
4748
package-server-ai-openai-released: ${{ steps.release.outputs['packages/ai-providers/server-ai-openai--release_created'] }}
4849
package-server-ai-openai-tag-name: ${{ steps.release.outputs['packages/ai-providers/server-ai-openai--tag_name'] }}
50+
package-server-ai-optimization-released: ${{ steps.release.outputs['packages/optimization--release_created'] }}
51+
package-server-ai-optimization-tag-name: ${{ steps.release.outputs['packages/optimization--tag_name'] }}
4952
steps:
5053
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4
5154
id: release
@@ -222,3 +225,50 @@ jobs:
222225
base64-subjects: "${{ needs.release-server-ai-openai.outputs.package-hashes }}"
223226
upload-assets: true
224227
upload-tag-name: ${{ needs.release-please.outputs.package-server-ai-openai-tag-name }}
228+
229+
release-server-ai-optimization:
230+
runs-on: ubuntu-latest
231+
needs: ['release-please']
232+
permissions:
233+
id-token: write # Needed for OIDC to get release secrets from AWS.
234+
if: ${{ needs.release-please.outputs.package-server-ai-optimization-released == 'true' }}
235+
outputs:
236+
package-hashes: ${{ steps.build.outputs.package-hashes }}
237+
steps:
238+
- uses: actions/checkout@v4
239+
with:
240+
fetch-depth: 0
241+
242+
- uses: ./.github/actions/ci
243+
with:
244+
workspace_path: packages/optimization
245+
246+
- uses: ./.github/actions/build
247+
id: build
248+
with:
249+
workspace_path: packages/optimization
250+
251+
- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1.2.0
252+
name: 'Get PyPI token'
253+
with:
254+
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
255+
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
256+
257+
- name: Publish to PyPI
258+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
259+
with:
260+
password: ${{ env.PYPI_AUTH_TOKEN }}
261+
packages-dir: packages/optimization/dist/
262+
263+
release-server-ai-optimization-provenance:
264+
needs: ['release-please', 'release-server-ai-optimization']
265+
if: ${{ needs.release-please.outputs.package-server-ai-optimization-released == 'true' }}
266+
permissions:
267+
actions: read # Needed for detecting the GitHub Actions environment.
268+
id-token: write # Needed for provenance signing.
269+
contents: write # Needed for uploading assets to the release.
270+
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v2.0.0
271+
with:
272+
base64-subjects: "${{ needs.release-server-ai-optimization.outputs.package-hashes }}"
273+
upload-assets: true
274+
upload-tag-name: ${{ needs.release-please.outputs.package-server-ai-optimization-tag-name }}

packages/optimization/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
## 0.0.0 (2026-03-24)
4+
5+
### Features
6+
7+
* Initial package scaffolding for optimization helpers.

packages/optimization/Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
PYTEST_FLAGS=-W error::SyntaxWarning
2+
3+
.PHONY: help
4+
help: #! Show this help message
5+
@echo 'Usage: make [target] ... '
6+
@echo ''
7+
@echo 'Targets:'
8+
@grep -h -F '#!' $(MAKEFILE_LIST) | grep -v grep | sed 's/:.*#!/:/' | column -t -s":"
9+
10+
.PHONY: install
11+
install: #! Install package dependencies
12+
uv sync --all-groups
13+
14+
.PHONY: test
15+
test: #! Run unit tests
16+
test: install
17+
uv run pytest $(PYTEST_FLAGS)
18+
19+
.PHONY: lint
20+
lint: #! Run type analysis and linting checks
21+
lint: install
22+
uv run mypy src/ldai_optimization
23+
uv run isort --check --atomic src/ldai_optimization
24+
uv run pycodestyle src/ldai_optimization
25+
26+
.PHONY: build
27+
build: #! Build distribution files
28+
build: install
29+
uv build --out-dir dist

packages/optimization/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# LaunchDarkly AI SDK — optimization
2+
3+
[![PyPI](https://img.shields.io/pypi/v/launchdarkly-server-sdk-ai-optimization.svg?style=flat-square)](https://pypi.org/project/launchdarkly-server-sdk-ai-optimization/)
4+
5+
> [!CAUTION]
6+
> This package is in pre-release and not subject to backwards compatibility
7+
> guarantees. The API may change based on feedback.
8+
>
9+
> Pin to a specific minor version and review the [changelog](CHANGELOG.md) before upgrading.
10+
11+
This package will provide helpers to run selected tools against the [LaunchDarkly API](https://apidocs.launchdarkly.com/) from SDK-based workflows. The public surface is not yet finalized; see [CHANGELOG.md](CHANGELOG.md) for updates.
12+
13+
## Installation
14+
15+
```bash
16+
pip install launchdarkly-server-sdk-ai-optimization
17+
```
18+
19+
## Status
20+
21+
- 3/24/26: Initial package creation
22+
23+
## License
24+
25+
Apache-2.0
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
[project]
2+
name = "launchdarkly-server-sdk-ai-optimization"
3+
version = "0.0.0" # x-release-please-version
4+
description = "LaunchDarkly AI SDK optimization helpers"
5+
authors = [{name = "LaunchDarkly", email = "dev@launchdarkly.com"}]
6+
license = {text = "Apache-2.0"}
7+
readme = "README.md"
8+
requires-python = ">=3.9,<4"
9+
classifiers = [
10+
"Intended Audience :: Developers",
11+
"License :: OSI Approved :: Apache Software License",
12+
"Operating System :: OS Independent",
13+
"Programming Language :: Python :: 3",
14+
"Programming Language :: Python :: 3.9",
15+
"Programming Language :: Python :: 3.10",
16+
"Programming Language :: Python :: 3.11",
17+
"Programming Language :: Python :: 3.12",
18+
"Programming Language :: Python :: 3.13",
19+
"Topic :: Software Development",
20+
"Topic :: Software Development :: Libraries",
21+
]
22+
dependencies = [
23+
"launchdarkly-server-sdk-ai>=0.16.0",
24+
]
25+
26+
[project.urls]
27+
Homepage = "https://docs.launchdarkly.com/sdk/ai/python"
28+
Repository = "https://github.com/launchdarkly/python-server-sdk-ai"
29+
30+
[dependency-groups]
31+
dev = [
32+
"pytest>=2.8",
33+
"pytest-cov>=2.4.0",
34+
"pytest-asyncio>=0.21.0,<1.0.0",
35+
"mypy==1.18.2",
36+
"pycodestyle>=2.11.0",
37+
"isort>=5.12.0",
38+
]
39+
40+
[build-system]
41+
requires = ["hatchling"]
42+
build-backend = "hatchling.build"
43+
44+
[tool.hatch.build.targets.wheel]
45+
packages = ["src/ldai_optimization"]
46+
47+
[tool.mypy]
48+
python_version = "3.9"
49+
ignore_missing_imports = true
50+
install_types = true
51+
non_interactive = true
52+
53+
[tool.isort]
54+
profile = "black"
55+
known_third_party = ["ldai"]
56+
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
57+
58+
[tool.pytest.ini_options]
59+
addopts = ["-ra"]
60+
testpaths = ["tests"]
61+
asyncio_mode = "auto"

packages/optimization/setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pycodestyle]
2+
max-line-length = 120
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"""LaunchDarkly AI SDK — optimization.
2+
3+
This package will provide helpers to run selected tools against the LaunchDarkly API from SDK-based workflows.
4+
"""
5+
6+
from ldai_optimization.client import ApiAgentOptimizationClient
7+
8+
__version__ = "0.0.0"
9+
10+
__all__ = [
11+
'__version__',
12+
'ApiAgentOptimizationClient',
13+
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Client placeholder for LaunchDarkly API tool execution."""
2+
3+
from typing import Any, Dict
4+
5+
6+
class ApiAgentOptimizationClient:
7+
"""Coordinates running supported tools against the LaunchDarkly API.
8+
9+
This type is scaffolding; concrete behavior will be added in a future release.
10+
"""
11+
12+
def optimize(self, tool_name: str, parameters: Dict[str, Any]) -> Any:
13+
"""Execute a supported LaunchDarkly API tool by name.
14+
15+
:param tool_name: Identifier of the tool to invoke.
16+
:param parameters: Tool-specific request parameters.
17+
:return: Tool-specific response data.
18+
:raises NotImplementedError: Until the API integration is implemented.
19+
"""
20+
raise NotImplementedError

packages/optimization/tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)