Skip to content

Commit

Permalink
Lazy logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
ways committed Jan 2, 2024
1 parent 7b8fe0a commit 600f61a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions app/initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ def open_grib():
dataset = xr.open_dataset(filename, engine="cfgrib")
except ValueError as err:
logger.error(
"Unable to open file %s. Check installation of modules cfgrib, eccodes.\n%s"
% (filename, err)
"Unable to open file %s. Check installation of modules cfgrib, eccodes.\n%s",
filename, err
)
logger.info("xarray versions:", xr.show_versions())
logger.info("xarray versions: %s", xr.show_versions())
sys.exit(1)
if not validate_grib(dataset):
sys.exit(1)
Expand Down Expand Up @@ -145,10 +145,10 @@ def download_gribfile(data_path: str, api_url: str = API_URL) -> str:
)

if os.path.exists(fname):
logger.info(f"Latest file is {fname}, already have that. Skipping download.")
logger.info("Latest file is %s, already have that. Skipping download.", fname)
return fname

logger.info(f"Downloading {api_url} to path {fname}")
logger.info("Downloading %s to path %s.", api_url, fname)
with open(fname, "wb") as fd:
for chunk in response.iter_content(chunk_size=524288):
fd.write(chunk)
Expand Down
2 changes: 1 addition & 1 deletion app/routes/collections_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def create_point(coords: str = "") -> dict:
logger.error(errmsg)
return Response(status_code=status.HTTP_400_BAD_REQUEST, content=errmsg)

logger.info("create_data for coord", point.y, point.x)
logger.info("create_data for coord %s, %s", point.y, point.x)
dataset = get_dataset()

# Sanity checks on coordinates
Expand Down

0 comments on commit 600f61a

Please sign in to comment.