Skip to content

Commit

Permalink
1.4.3: improve logging & error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
louis030195 committed Dec 11, 2022
1 parent 0342b05 commit c1e6e88
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
6 changes: 3 additions & 3 deletions langame/functions/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ async def generate() -> Tuple[Optional[DocumentSnapshot], Optional[dict]]:
# generate in parallel for "limit"
responses = await asyncio.gather(*[generate() for _ in range(limit)])
conversation_starters, errors = zip(*responses)
# if all are errors, return the first error
if all(errors):
return None, errors[0]
# if any are errors, return the first error
if any(errors):
return None, [e for e in errors if e][0]
one_week_ago = datetime.datetime.now(utc) - datetime.timedelta(days=7)

# Filter out memes already seen X time ago
Expand Down
3 changes: 1 addition & 2 deletions run/collection/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from google.cloud.firestore import Client

initialize_app()
GET_MEMES_URL = os.environ.get("GET_MEMES_URL")
logger = logging.getLogger()
logging.basicConfig(level=logging.INFO)
db: Client = firestore.client()
Expand Down Expand Up @@ -175,7 +174,7 @@ async def create_starter():
span.set_data("conversation_starters", conversation_starters)
span.set_data("error", error)
logger.info(
f"Got conversation starter response: {conversation_starters} error: {error}"
f"Got conversation starter response, error: {error}"
+ f" in {end_time - start_time} seconds"
)

Expand Down
6 changes: 2 additions & 4 deletions run/collection/service.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ spec:
spec:
containerConcurrency: 5
containers:
image: gcr.io/langame-86ac4/collection:1.1.9
image: gcr.io/langame-86ac4/collection:1.2.0
ports:
- containerPort: 8080
name: http1
env:
- name: GET_MEMES_URL
value: "https://us-central1-langame-86ac4.cloudfunctions.net/getMemes"
- name: SENTRY_RELEASE
value: "1.1.9"
value: "1.2.0"
- name: ENVIRONMENT
value: "production"
resources:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
name="langame",
packages=find_packages(),
include_package_data=True,
version="1.4.2",
version="1.4.3",
description="",
install_requires=[
"firebase_admin",
Expand Down

0 comments on commit c1e6e88

Please sign in to comment.