Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyproj 3+ logs PROJ_ERROR at debug level #822

Closed
djhoese opened this issue Apr 8, 2021 · 3 comments · Fixed by #823
Closed

Pyproj 3+ logs PROJ_ERROR at debug level #822

djhoese opened this issue Apr 8, 2021 · 3 comments · Fixed by #823
Labels

Comments

@djhoese
Copy link
Contributor

djhoese commented Apr 8, 2021

Code Sample, a copy-pastable example if possible

A "Minimal, Complete and Verifiable Example" will make it much easier for maintainers to help you:
http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports

import logging
logging.basicConfig(level=logging.DEBUG)

from pyproj import Proj
p = Proj("+proj=stere +a=6370000 +b=6370000 +lat_0=90 +lat_ts=60 +lon_0=10 +units=m +no_defs")
p.crs.is_geographic
# DEBUG:pyproj:PROJ_ERROR: proj_crs_get_sub_crs: Object is not a CompoundCRS

Note: The message doesn't show up with the creation of CRS, only is_geographic. There are likely other cases that cause the message but this was the simplest I could find.

Problem description

I use pyproj in a lot of applications that include logging. I often write a log file with DEBUG level logging. Starting with pyproj 3, I'm seeing a lot of the following error messages that are logged as DEBUG messages and are filling up my log file. I'm hoping for more information on what these mean, if they are meant to be logged, and what the right course of action might be to reducing them.

DEBUG:pyproj:PROJ_ERROR: proj_crs_get_sub_crs: Object is not a CompoundCRS

Expected Output

No log message or at least not a DEBUG message with a PROJ_ERROR.

Environment Information

  • Output from: pyproj -v
pyproj info:
    pyproj: 3.0.1
      PROJ: 8.0.0
  data dir: /home/davidh/miniconda3/envs/polar2grid_py38/share/proj
user_data_dir: /home/davidh/.local/share/proj

System:
    python: 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 16:22:27)  [GCC 9.3.0]
executable: /home/davidh/miniconda3/envs/polar2grid_py38/bin/python
   machine: Linux-5.11.0-7612-generic-x86_64-with-glibc2.10

Python deps:
       pip: 20.2.3
setuptools: 49.6.0.post20200814
    Cython: None

Installation method

  • conda-forge

Conda environment information (if you installed with conda):


Environment (conda list):
$ conda list proj


Details about conda and system ( conda info ):
$ conda info

@djhoese djhoese added the bug label Apr 8, 2021
@snowman2
Copy link
Member

snowman2 commented Apr 9, 2021

This is actually something that has been there for a while, but isn't really a bug. It is related to the design for how things work. The method sub_crs_list calls proj_crs_get_sub_crs for any of the CRS types and if it returns NULL if it is isn't compound and lets PROJ do the work comparing the CRS type ref. But, that comes with the random error log message in debug mode.

To prevent having the error message:

Option 1: Disable logger or change level:

pyproj_logger = logging.getLogger("pyproj")
pyproj_logger.disabled = True
# or
pyproj_logger = logging.getLogger("pyproj")
pyproj_logger.setLevel(logging.WARN)

Option 2: Modify pyproj:

  1. Add the is_compound property to the _CRS class similar to is_bound that instead compares against PJ_TYPE_COMPOUND_CRS:

pyproj/pyproj/_crs.pyx

Lines 2918 to 2926 in 9669f62

@property
def is_bound(self):
"""
Returns
-------
bool:
True if CRS is bound.
"""
return self._type == PJ_TYPE_BOUND_CRS

2. Modify sub_crs_list to return [] if it is not a compound CRS using the is_compound property.

@djhoese
Copy link
Contributor Author

djhoese commented Apr 9, 2021

Do you see an is_compound property being useful besides for this use case?

And I should have figured this has been here for a while. I only started looking at the actual logs for my stuff. 🤦

@snowman2
Copy link
Member

snowman2 commented Apr 9, 2021

Do you see an is_compound property being useful besides for this use case?

I think that it would be useful to have.

Side note: #696 is why you see the error in the logs with pyproj 3+ and didn't see it with previous versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants