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 pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies = [
"boto3>=1.35.0",
"markdown>=3.6",
"bleach>=6.3.0",
"adcp>=1.2.1", # Official ADCP Python client for schema types
"adcp>=2.2.0", # Official ADCP Python client with semantic type aliases
]

[project.scripts]
Expand Down
6 changes: 3 additions & 3 deletions src/creative_agent/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
from pydantic import AnyUrl, BaseModel

from .data.standard_formats import STANDARD_FORMATS, get_format_by_id

Expand Down Expand Up @@ -65,7 +65,7 @@ async def get_format(format_id: str) -> dict[str, Any]:
from .data.standard_formats import AGENT_URL

# Convert string ID to FormatId object (assume our agent)
fmt_id = FormatId(agent_url=AGENT_URL, id=format_id)
fmt_id = FormatId(agent_url=AnyUrl(AGENT_URL), id=format_id)
fmt = get_format_by_id(fmt_id)
if not fmt:
raise HTTPException(status_code=404, detail=f"Format {format_id} not found")
Expand All @@ -82,7 +82,7 @@ async def preview_creative(request: PreviewRequest) -> dict[str, Any]:
from .data.standard_formats import AGENT_URL

# Convert string ID to FormatId object (assume our agent)
fmt_id = FormatId(agent_url=AGENT_URL, id=request.format_id)
fmt_id = FormatId(agent_url=AnyUrl(AGENT_URL), id=request.format_id)
fmt = get_format_by_id(fmt_id)
if not fmt:
raise HTTPException(status_code=404, detail=f"Format {request.format_id} not found")
Expand Down
65 changes: 65 additions & 0 deletions src/creative_agent/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
"""DEPRECATED: Compatibility layer for adcp library types.

## Deprecation Notice

As of adcp 2.2.0, semantic type aliases are provided directly by the library.
This module is no longer needed and will be removed in a future version.

**Instead of:**
```python
from creative_agent.compat import UrlPreviewRender
```

**Use:**
```python
from adcp.types import UrlPreviewRender
```

## Migration

All imports from this module should be updated to import directly from `adcp.types`:
- `UrlPreviewRender`, `HtmlPreviewRender`, `BothPreviewRender`
- `UrlVastAsset`, `InlineVastAsset`
- `UrlDaastAsset`, `InlineDaastAsset`
- `MediaSubAsset`, `TextSubAsset`

This module now re-exports from the library for backward compatibility.
"""

import warnings

# Re-export from library for backward compatibility
from adcp.types import (
BothPreviewRender,
HtmlPreviewRender,
InlineDaastAsset,
InlineVastAsset,
MediaSubAsset,
TextSubAsset,
UrlDaastAsset,
UrlPreviewRender,
UrlVastAsset,
)

# Emit deprecation warning on import
warnings.warn(
"creative_agent.compat is deprecated. Import type aliases directly from adcp.types instead. "
"This module will be removed in a future version.",
DeprecationWarning,
stacklevel=2,
)

__all__ = [
# DAAST assets
"BothPreviewRender",
"HtmlPreviewRender",
"InlineDaastAsset",
"InlineVastAsset",
# SubAssets
"MediaSubAsset",
"TextSubAsset",
# VAST assets
"UrlDaastAsset",
"UrlPreviewRender",
"UrlVastAsset",
]
5 changes: 5 additions & 0 deletions src/creative_agent/data/format_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

These types mirror the structure expected by Format.assets_required and Format.renders,
but are defined locally since the adcp library uses flexible Any types for these fields.

Note: While Format (from adcp library v1.6+) inherits from AdCPBaseModel which applies
exclude_none=True by default, that only works for Pydantic model fields. Since
assets_required and renders are typed as Any[], they hold raw dicts. We must apply
exclude_none=True when converting these helper models to dicts before passing them to Format.
"""

from enum import Enum
Expand Down
Loading