Skip to content

Conversation

@kristinchang3
Copy link
Collaborator

Hi @lee1043 - I added the following CDP scripts to PMP Utils and PMP io:

utils:

  • cdp_parameter.py
  • cdp_parser.py
  • cdp_run.py

io:

  • cdp_io.py

These scripts are not dependent on the esgf_output_viewer package that is no longer maintained and have been tested with higher versions of python (3.11-3.13).

I also moved the following existing PMP scripts from ./mean_climate/lib to utils:

  • pmp_parameter.py
  • pmp_parser.py

Metrics' driver scripts have been updated accordingly to reference the local versions of these script updates. Additionally the cdp library import has been removed from both conda environments.

Please test by running Demo notebooks 0, 1a, 1b, 2a, 2b, 3, 4, 5, 7, 7b, and 8. Thanks!

@kristinchang3 kristinchang3 requested a review from lee1043 October 29, 2025 22:04
@kristinchang3 kristinchang3 self-assigned this Oct 29, 2025
@kristinchang3
Copy link
Collaborator Author

@lee1043 it looks like this PR is failing 2 tests - could you help me figure out what the issue is? Thanks!

@lee1043
Copy link
Contributor

lee1043 commented Oct 29, 2025

Hi @kristinchang3, thanks for the PR. I see the following messages from the failing tests. Can you try tackling them? I think one of them is circular import error.

==================================== ERRORS ====================================
______________________ ERROR collecting tests/test_qc.py _______________________
ImportError while importing test module '/home/runner/work/pcmdi_metrics/pcmdi_metrics/tests/test_qc.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../miniconda3/envs/pcmdi_metrics_ci/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_qc.py:5: in <module>
    from pcmdi_metrics.utils import (
pcmdi_metrics/utils/__init__.py:26: in <module>
    from .pmp_parameter import PMPMetricsParameter, PMPParameter
pcmdi_metrics/utils/pmp_parameter.py:6: in <module>
    from pcmdi_metrics.utils import StringConstructor
E   ImportError: cannot import name 'StringConstructor' from partially initialized module 'pcmdi_metrics.utils' (most likely due to a circular import) (/home/runner/work/pcmdi_metrics/pcmdi_metrics/pcmdi_metrics/utils/__init__.py)
____________________ ERROR collecting tests/test_sea_ice.py ____________________
ImportError while importing test module '/home/runner/work/pcmdi_metrics/pcmdi_metrics/tests/test_sea_ice.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../miniconda3/envs/pcmdi_metrics_ci/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_sea_ice.py:4: in <module>
    from pcmdi_metrics.sea_ice.lib import sea_ice_lib as lib
pcmdi_metrics/sea_ice/lib/__init__.py:1: in <module>
    from .sea_ice_parser import create_sea_ice_parser
pcmdi_metrics/sea_ice/lib/sea_ice_parser.py:2: in <module>
    from pcmdi_metrics.utils import pmp_parser
pcmdi_metrics/utils/__init__.py:26: in <module>
    from .pmp_parameter import PMPMetricsParameter, PMPParameter
pcmdi_metrics/utils/pmp_parameter.py:6: in <module>
    from pcmdi_metrics.utils import StringConstructor
E   ImportError: cannot import name 'StringConstructor' from partially initialized module 'pcmdi_metrics.utils' (most likely due to a circular import) (/home/runner/work/pcmdi_metrics/pcmdi_metrics/pcmdi_metrics/utils/__init__.py)
=============================== warnings summary ===============================
../../../miniconda3/envs/pcmdi_metrics_ci/lib/python3.10/site-packages/pyogrio/__init__.py:7
  /home/runner/miniconda3/envs/pcmdi_metrics_ci/lib/python3.10/site-packages/pyogrio/__init__.py:7: DeprecationWarning: The 'shapely.geos' module is deprecated, and will be removed in a future version. All attributes of 'shapely.geos' are available directly from the top-level 'shapely' namespace (since shapely 2.0.0).
    import shapely.geos  # noqa: F401

@kristinchang3
Copy link
Collaborator Author

@lee1043 just fixed!

Copy link
Contributor

@lee1043 lee1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kristinchang3 great job, the changes are looking good to me!

@kristinchang3 kristinchang3 merged commit 0fbb014 into main Oct 29, 2025
7 checks passed
@kristinchang3 kristinchang3 deleted the 1339_kristinchang3_refactorCDP branch October 29, 2025 23:36
@lee1043 lee1043 linked an issue Nov 6, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Refactor PMP CDP usage to remove ESGF output viewer package

3 participants