logger.partitioning is accessed before definition
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 150
- Forks
- 23
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 2
Description
logger.partitioning is accessed before definition using Python version: Python 3.8.11; cf-python version 3.11.0 from pypi
Using import cf immediately throws an attribute error: 'Logger' object has no attribute 'partitioning'. The expected behaviour is that logger.partitioning is defined before it is called, allowing for the package to be imported.
Following the traceback shows that logger.partitioning is accessed by way of line 194 in cf/.init.py:
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 843, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/X/X_env/lib/python3.8/site-packages/cf/__init__.py", line 194, in <module>
from .mixin import Coordinate
File "/home/X/X_env/lib/python3.8/site-packages/cf/mixin/__init__.py", line 2, in <module>
from .propertiesdata import PropertiesData, Subspace
File "/home/X/X_env/lib/python3.8/site-packages/cf/mixin/propertiesdata.py", line 24, in <module>
from ..timeduration import TimeDuration
File "/home/X/X_env/lib/python3.8/site-packages/cf/timeduration.py", line 28, in <module>
_one_year = Data(1, "calendar_years")
File "/home/X/X_env/lib/python3.8/site-packages/cf/data/data.py", line 750, in __init__
self._set_partition_matrix(
File "/home/X/X_env/lib/python3.8/site-packages/cf/data/data.py", line 832, in _set_partition_matrix
self.to_disk()
File "/home/X/X_env/lib/python3.8/site-packages/cf/data/data.py", line 12125, in to_disk
partition.close()
File "/home/X/X_env/lib/python3.8/site-packages/cf/data/partition.py", line 788, in close
logger.partitioning("Partition.close: original = {}".format(original))
AttributeError: 'Logger' object has no attribute 'partitioning'
logger.partitioning is defined on line 330 in cf/.init.py and is not created before any submodules are imported.
A possible solution is to move the logger definitions to before importing the submodules.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect cf/init.py, especially the logger definitions around line 330 and the submodule import around line 194. Reproduce the failure with import cf using Python 3.8. Confirm that logger.partitioning exists before cf/timeduration.py and cf/data/partition.py use it, and verify that the package imports successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend, data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100