Skip to content

Commit b4d8043

Browse files
happyhumantommywagz
andcommitted
chore: Reformatted the short-movie-agents sample by ensuring black, isort, and flake8 pass (#767)
Co-authored-by: tommywagz <tow7304@gmail.com> Co-authored-by: tommywagz <64981171+tommywagz@users.noreply.github.com>
1 parent 5b27085 commit b4d8043

File tree

12 files changed

+1109
-1171
lines changed

12 files changed

+1109
-1171
lines changed

pyproject.toml

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
1-
[tool.black]
2-
line-length = 88
3-
target-version = ['py38', 'py39', 'py310']
4-
include = '\.pyi?$'
5-
exclude = '''
6-
/(
7-
\.git
8-
| \.hg
9-
| \.mypy_cache
10-
| \.tox
11-
| \.venv
12-
| _build
13-
| buck-out
14-
| build
15-
)/
16-
'''
1+
[project]
2+
name = "google-adk-samples"
3+
version = "0.1.0"
4+
requires-python = ">=3.10"
5+
6+
[tool.ruff]
7+
line-length = 80
8+
target-version = "py310"
9+
10+
[tool.ruff.lint]
11+
select = [
12+
"E", # pycodestyle
13+
"F", # pyflakes
14+
"I", # isort
15+
"C", # flake8-comprehension
16+
"PL", # Pylint rules
17+
"B", # flake8-bugbear
18+
"UP", # pyupgrade
19+
"RUF" # ruff specific rules
20+
]
21+
ignore = [
22+
"E501", # Ignore line length for long LLM prompts
23+
"PLR0913" # Allow agents to have many arguments if needed
24+
]
25+
26+
[tool.ruff.lint.per-file-ignores]
27+
# Global rule: ADK agents use __init__.py to expose their logic
28+
"__init__.py" = ["F401"]
29+
30+
[tool.ruff.format]
31+
quote-style = "double"
32+
indent-style = "space"
33+
34+
[tool.codespell]
35+
ignore-words-list = "rouge"
36+
skip = "./locust_env/*,uv.lock,.venv,./frontend,**/*.ipynb"
1737

18-
[tool.isort]
19-
profile = "black"
20-
multi_line_output = 3
21-
include_trailing_comma = true
22-
force_grid_wrap = 0
23-
use_parentheses = true
24-
ensure_newline_before_comments = true
25-
line_length = 88

python/agents/short-movie-agents/app/agent.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@
3737
model=MODEL,
3838
description=(DESCRIPTION),
3939
instruction=load_prompt_from_file("director_agent.txt"),
40-
sub_agents=[story_agent, screenplay_agent, storyboard_agent, video_agent],
40+
sub_agents=[
41+
story_agent,
42+
screenplay_agent,
43+
storyboard_agent,
44+
video_agent,
45+
],
4146
)
4247
logger.info(f"✅ Agent '{root_agent.name}' created using model '{MODEL}'.")
4348
else:

python/agents/short-movie-agents/app/screenplay_agent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
instruction=load_prompt_from_file("screenplay_agent.txt"),
3737
output_key="screenplay",
3838
)
39-
logger.info(f"✅ Agent '{screenplay_agent.name}' created using model '{MODEL}'.")
39+
logger.info(
40+
f"✅ Agent '{screenplay_agent.name}' created using model '{MODEL}'."
41+
)
4042
except Exception as e:
4143
logger.error(
4244
f"❌ Could not create Screenplay agent. Check API Key ({MODEL}). Error: {e}"

python/agents/short-movie-agents/app/server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
logging_client = google_cloud_logging.Client()
3030
logger = logging_client.logger(__name__)
3131
allow_origins = (
32-
os.getenv("ALLOW_ORIGINS", "").split(",") if os.getenv("ALLOW_ORIGINS") else None
32+
os.getenv("ALLOW_ORIGINS", "").split(",")
33+
if os.getenv("ALLOW_ORIGINS")
34+
else None
3335
)
3436

3537
bucket_name = f"gs://{project_id}-short-movie-agents-logs-data"

python/agents/short-movie-agents/app/story_agent.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,19 @@
2626

2727
try:
2828
MODEL = "gemini-2.5-flash"
29-
DESCRIPTION = "An agent that generates a short, engaging campfire story for scouts."
29+
DESCRIPTION = (
30+
"An agent that generates a short, engaging campfire story for scouts."
31+
)
3032
story_agent = Agent(
3133
model=MODEL,
3234
name="story_agent",
3335
description=load_prompt_from_file("story_agent_desc.txt"),
3436
instruction=load_prompt_from_file("story_agent.txt"),
3537
output_key="story",
3638
)
37-
logging.info(f"✅ Agent '{story_agent.name}' created using model '{MODEL}'.")
39+
logging.info(
40+
f"✅ Agent '{story_agent.name}' created using model '{MODEL}'."
41+
)
3842
except Exception as e:
3943
logging.error(
4044
f"❌ Could not create Story agent. Check API Key ({MODEL}). Error: {e}"

python/agents/short-movie-agents/app/storyboard_agent.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ def storyboard_generate(
6868
AUTHORIZED_URI = "https://storage.mtls.cloud.google.com/"
6969

7070
# Actual image generation
71-
logger.info(f"Generating image for scene {scene_number} with prompt: {prompt}")
71+
logger.info(
72+
f"Generating image for scene {scene_number} with prompt: {prompt}"
73+
)
7274
response = generation_model.generate_images(
7375
prompt=prompt,
7476
number_of_images=1,
@@ -108,7 +110,9 @@ def storyboard_generate(
108110
output_key="storyboard",
109111
tools=[storyboard_generate],
110112
)
111-
logger.info(f"✅ Agent '{storyboard_agent.name}' created using model '{MODEL}'.")
113+
logger.info(
114+
f"✅ Agent '{storyboard_agent.name}' created using model '{MODEL}'."
115+
)
112116
except Exception as e:
113117
logger.error(
114118
f"❌ Could not create Storyboard agent. Check API Key ({MODEL}). Error: {e}"

python/agents/short-movie-agents/app/utils/gcs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414

1515
import logging
1616

17-
import google.cloud.storage as storage
1817
from google.api_core import exceptions
18+
from google.cloud import storage
1919

2020

21-
def create_bucket_if_not_exists(bucket_name: str, project: str, location: str) -> None:
21+
def create_bucket_if_not_exists(
22+
bucket_name: str, project: str, location: str
23+
) -> None:
2224
"""Creates a new bucket if it doesn't already exist.
2325
2426
Args:

python/agents/short-movie-agents/app/utils/tracing.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
from collections.abc import Sequence
1818
from typing import Any
1919

20-
import google.cloud.storage as storage
2120
from google.cloud import logging as google_cloud_logging
21+
from google.cloud import storage
2222
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
2323
from opentelemetry.sdk.trace import ReadableSpan
2424
from opentelemetry.sdk.trace.export import SpanExportResult
@@ -56,8 +56,12 @@ def __init__(
5656
project=self.project_id
5757
)
5858
self.logger = self.logging_client.logger(__name__)
59-
self.storage_client = storage_client or storage.Client(project=self.project_id)
60-
self.bucket_name = bucket_name or f"{self.project_id}-test-agent-logs-data"
59+
self.storage_client = storage_client or storage.Client(
60+
project=self.project_id
61+
)
62+
self.bucket_name = (
63+
bucket_name or f"{self.project_id}-test-agent-logs-data"
64+
)
6165
self.bucket = self.storage_client.bucket(self.bucket_name)
6266

6367
def export(self, spans: Sequence[ReadableSpan]) -> SpanExportResult:

python/agents/short-movie-agents/app/utils/utils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def load_prompt_from_file(
2727
instruction = default_instruction
2828
try:
2929
# Construct path relative to the current script file (__file__)
30-
filepath = os.path.join(os.path.dirname(__file__), PROMPTS_PATH, filename)
30+
filepath = os.path.join(
31+
os.path.dirname(__file__), PROMPTS_PATH, filename
32+
)
3133
with open(filepath, encoding="utf-8") as f:
3234
instruction = f.read()
3335
logger.info(f"Successfully loaded instruction from {filename}")
@@ -36,5 +38,7 @@ def load_prompt_from_file(
3638
f"WARNING: Instruction file not found: {filepath}. Using default."
3739
)
3840
except Exception as e:
39-
logger.error(f"ERROR loading instruction file {filepath}: {e}. Using default.")
41+
logger.error(
42+
f"ERROR loading instruction file {filepath}: {e}. Using default."
43+
)
4044
return instruction

python/agents/short-movie-agents/app/video_agent.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
MODEL = "gemini-2.5-flash"
3333
VIDEO_MODEL = "veo-3.0-generate-preview"
3434
VIDEO_MODEL_LOCATION = "us-central1"
35-
DESCRIPTION = (
36-
"Agent responsible for creating videos based on a screenplay and storyboards"
37-
)
35+
DESCRIPTION = "Agent responsible for creating videos based on a screenplay and storyboards"
3836
ASPECT_RATIO = "16:9"
3937

4038
client = genai.Client(
@@ -73,14 +71,20 @@ def video_generate(
7371
AUTHORIZED_URI = "https://storage.mtls.cloud.google.com/"
7472

7573
# Extract dialogue from screenplay
76-
dialogue = "\n".join(re.findall(r"^\w+\s*\(.+\)\s*$", screenplay, re.MULTILINE))
77-
dialogue += "\n".join(re.findall(r"^\s{2,}.+$", screenplay, re.MULTILINE))
74+
dialogue = "\n".join(
75+
re.findall(r"^\w+\s*\(.+\)\s*$", screenplay, re.MULTILINE)
76+
)
77+
dialogue += "\n".join(
78+
re.findall(r"^\s{2,}.+$", screenplay, re.MULTILINE)
79+
)
7880

7981
if dialogue:
8082
prompt += f"\n\nAudio:\n{dialogue}"
8183

8284
# Actual video generation
83-
logger.info(f"Generating video for prompt '{prompt}' and image '{image_link}'")
85+
logger.info(
86+
f"Generating video for prompt '{prompt}' and image '{image_link}'"
87+
)
8488

8589
operation = client.models.generate_videos(
8690
model=VIDEO_MODEL,

0 commit comments

Comments
 (0)