From b1d2d64bdc9f672f3df124b3eca24cb73acd298b Mon Sep 17 00:00:00 2001 From: "david.poulter" Date: Thu, 18 Jul 2024 19:30:16 +0100 Subject: [PATCH] Fixed some ruff issues --- esgf-generator/esgf_generator/__init__.py | 4 ++++ esgf-generator/esgf_generator/cli.py | 2 ++ 2 files changed, 6 insertions(+) diff --git a/esgf-generator/esgf_generator/__init__.py b/esgf-generator/esgf_generator/__init__.py index 32ec82b..0382467 100644 --- a/esgf-generator/esgf_generator/__init__.py +++ b/esgf-generator/esgf_generator/__init__.py @@ -1,3 +1,4 @@ +import warnings from datetime import datetime, timezone from random import random from typing import Any, Dict, List, Optional, TypeVar @@ -203,3 +204,6 @@ def post_to_stac(data: ESGFItem) -> None: urljoin(API_URL, f"collections/{data.collection}/items"), content=data.json(), ) + if response.status_code >= 300: + warnings.warn(f"Failed to post {data.json()}") + diff --git a/esgf-generator/esgf_generator/cli.py b/esgf-generator/esgf_generator/cli.py index f9ef10d..e086daa 100644 --- a/esgf-generator/esgf_generator/cli.py +++ b/esgf-generator/esgf_generator/cli.py @@ -40,6 +40,8 @@ def esgf_generator(count: int, publish: bool, delay: bool) -> None: f"http://localhost:9050/{instance.collection}/items", content=instance.model_dump_json(), ) + if result.status_code >= 300: + raise Exception(result.content) click.echo(instance.model_dump_json(indent=2))