Skip to content
Open
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 composer/workflows/airflow_db_cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def cleanup_function(**context):
dags = session.query(airflow_db_model.dag_id).distinct()
session.commit()

list_dags = [str(list(dag)[0]) for dag in dags] + [None]
list_dags = [str(list(dag)[0]) for dag in dags]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

By removing + [None], any database rows with a NULL dag_id (which are common in tables like Log) will never be cleaned up. Furthermore, converting None to a string (str(None)) results in "None", which causes a useless query for a DAG literally named "None".

Using a list comprehension that preserves None as None and only converts non-null values to strings solves both issues: it correctly cleans up NULL dag_id rows when they exist, avoids querying for the literal string "None", and avoids running redundant None queries for tables that do not contain any NULL dag_ids.

Suggested change
list_dags = [str(list(dag)[0]) for dag in dags]
list_dags = [str(dag[0]) if dag[0] is not None else None for dag in dags]

for dag_id in list_dags:
query = build_query(
session=session,
Expand Down
6 changes: 6 additions & 0 deletions endpoints/bookstore-grpc-transcoding/api_config_auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ authentication:
# Replace SERVICE-ACCOUNT-ID with your service account's email address.
issuer: SERVICE-ACCOUNT-ID
jwks_uri: https://www.googleapis.com/robot/v1/metadata/x509/SERVICE-ACCOUNT-ID
# Optional: if the JWTs you send (e.g. via jwt_token_gen.py's
# --audiences flag) use a custom "aud" claim instead of your Endpoints
# service name, uncomment this and set it to that same value, or ESP
# will reject the token with a JWT validation error. See
# https://cloud.google.com/endpoints/docs/grpc/troubleshoot-jwt
# audiences: YOUR-AUDIENCE-VALUE
rules:
# This auth rule will apply to all methods.
- selector: "*"
Expand Down
6 changes: 6 additions & 0 deletions endpoints/bookstore-grpc/api_config_auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ authentication:
# Replace SERVICE-ACCOUNT-ID with your service account's email address.
issuer: SERVICE-ACCOUNT-ID
jwks_uri: https://www.googleapis.com/robot/v1/metadata/x509/SERVICE-ACCOUNT-ID
# Optional: if the JWTs you send (e.g. via jwt_token_gen.py's
# --audiences flag) use a custom "aud" claim instead of your Endpoints
# service name, uncomment this and set it to that same value, or ESP
# will reject the token with a JWT validation error. See
# https://cloud.google.com/endpoints/docs/grpc/troubleshoot-jwt
# audiences: YOUR-AUDIENCE-VALUE
rules:
# This auth rule will apply to all methods.
- selector: "*"
Expand Down
15 changes: 13 additions & 2 deletions texttospeech/snippets/streaming_tts_quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,19 @@ def request_generator():

streaming_responses = client.streaming_synthesize(request_generator())

for response in streaming_responses:
print(f"Audio content size in bytes is: {len(response.audio_content)}")
# The response stream contains headerless linear PCM (LINEAR16) audio
# sampled at 24000 Hz. Write it to a standard playable .wav file by
# adding a proper WAV header with the stdlib `wave` module, rather than
# a hand-rolled byte header.
import wave

with wave.open("streaming_tts_quickstart_output.wav", "wb") as wav_file:
wav_file.setnchannels(1) # LINEAR16 audio from this API is mono.
wav_file.setsampwidth(2) # 16-bit samples (LINEAR16) = 2 bytes/sample.
wav_file.setframerate(24000) # Sample rate used above.
for response in streaming_responses:
print(f"Audio content size in bytes is: {len(response.audio_content)}")
wav_file.writeframes(response.audio_content)
# [END tts_synthezise_streaming]


Expand Down