Skip to content

Conversation

@jennan
Copy link
Collaborator

@jennan jennan commented Mar 17, 2025

Fixes #53

  • I have added a dev optional dependency group, that could be used to put other non-test related dependencies.
  • In the CI/CD, I have made it install only the dev dependencies as it is not needed to install all to make it work (and also pip install .[all] will not install the current branch but the default branch develop).

@coveralls
Copy link

coveralls commented Mar 17, 2025

Pull Request Test Coverage Report for Build 13910690908

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 50.871%

Totals Coverage Status
Change from base Build 13880952241: 0.0%
Covered Lines: 6715
Relevant Lines: 12658

💛 - Coveralls

@jennan jennan changed the title Add pre-commit dependency [Draft] Add pre-commit dependency Mar 17, 2025
This fixes the issue with the pre-commit CI trying to run isort but not knowing
how.
@jennan jennan changed the title [Draft] Add pre-commit dependency Add pre-commit dependency Mar 17, 2025
@jennan jennan requested a review from tennlee March 17, 2025 22:06
@jennan
Copy link
Collaborator Author

jennan commented Mar 17, 2025

@tennlee The PR is ready. Unfortunately the CI/CD fails due to isort pre-commit doing its job I believe. So let me know if this PR should also fix this issue.

@tennlee
Copy link
Collaborator

tennlee commented Mar 17, 2025

I think yes, just bring isort into the mix. I did do an earlier commit bringing things into compliance at a point in time, so hopefully it won't be a large effort.

@jennan
Copy link
Collaborator Author

jennan commented Mar 17, 2025

I think yes, just bring isort into the mix. I did do an earlier commit bringing things into compliance at a point in time, so hopefully it won't be a large effort.

I have added isort already in the pre-commit config :-).

@tennlee
Copy link
Collaborator

tennlee commented Mar 17, 2025

Sorry, I wasn't clear. I mean, yes, please fix the underlying issues by running isort and adding that to this PR so that we can merge the PR and also set the passing hurdle on CI/CD.

@jennan
Copy link
Collaborator Author

jennan commented Mar 17, 2025

OK, isort broke some imports so I'll try to fix that.

@jennan
Copy link
Collaborator Author

jennan commented Mar 17, 2025

I also suspect that, if my memory is right, some modules from PyEarthTools need to be loaded before others so that the registration mechanism kicks in... that means isort will probably have broken these too.

@tennlee
Copy link
Collaborator

tennlee commented Mar 17, 2025

Fixing this will also help get the codebase ready for ruff integration, which had similar issues.
If you are stuck on specific import-order issues, feel free to let me know and we might be able to introduce a fix.

@jennan
Copy link
Collaborator Author

jennan commented Mar 18, 2025

So, it looks like there are quite a lot of circular imports, some due to subpackages importing their parent packages importing subpackages... The sorting from isort made this more visible.

For example, just looking at pyearthtools.data, I have found the following modules importing the parent module:

$ git grep "^import pyearthtools.data$" packages/data/src/
packages/data/src/pyearthtools/data/archive/extensions.py:import pyearthtools.data
packages/data/src/pyearthtools/data/archive/root.py:import pyearthtools.data
packages/data/src/pyearthtools/data/archive/zarr.py:import pyearthtools.data
packages/data/src/pyearthtools/data/catalog.py:import pyearthtools.data
packages/data/src/pyearthtools/data/download/arco/ERA5.py:import pyearthtools.data
packages/data/src/pyearthtools/data/download/cds/ERA5.py:import pyearthtools.data
packages/data/src/pyearthtools/data/download/ecmwf_opendata/opendata.py:import pyearthtools.data
packages/data/src/pyearthtools/data/indexes/cacheIndex.py:import pyearthtools.data
packages/data/src/pyearthtools/data/indexes/extensions.py:import pyearthtools.data
packages/data/src/pyearthtools/data/indexes/indexes.py:import pyearthtools.data
packages/data/src/pyearthtools/data/indexes/utilities/mixins/index_repr.py:import pyearthtools.data
packages/data/src/pyearthtools/data/load.py:import pyearthtools.data
packages/data/src/pyearthtools/data/modifications/modification.py:import pyearthtools.data
packages/data/src/pyearthtools/data/modifications/register.py:import pyearthtools.data
packages/data/src/pyearthtools/data/operations/index_operations.py:import pyearthtools.data
packages/data/src/pyearthtools/data/operations/index_routines.py:import pyearthtools.data
packages/data/src/pyearthtools/data/operations/interpolation.py:import pyearthtools.data
packages/data/src/pyearthtools/data/patterns/static.py:import pyearthtools.data
packages/data/src/pyearthtools/data/transforms/__init__.py:import pyearthtools.data
packages/data/src/pyearthtools/data/transforms/coordinates.py:import pyearthtools.data
packages/data/src/pyearthtools/data/transforms/default.py:import pyearthtools.data
packages/data/src/pyearthtools/data/transforms/interpolation.py:import pyearthtools.data
packages/data/src/pyearthtools/data/transforms/normalisation/default.py:import pyearthtools.data
packages/data/src/pyearthtools/data/transforms/values.py:import pyearthtools.data

I believe the right way to address these is to go through each of these children modules and ensure they don't import a parent module (e.g. using from pyearthtools.data.time import TimeDelta instead of from pyearthtools.dataimport TimeDelta).

I won't be able to do this now/today, so please @tennlee don't hesitate to have a look/push commits to this PR if you want to start fixing this without waiting for me.

@jennan jennan assigned jennan and unassigned tennlee Mar 18, 2025
@jennan
Copy link
Collaborator Author

jennan commented Mar 25, 2025

Just an update here, I have started to go through every import issue and fixing them one by one. I have made a new branch (to be merged here eventually) to explore if this is a viable solution. See https://github.com/jennan/PyEarthTools/tree/fix_imports.
FYI @tennlee

@jennan jennan mentioned this pull request Mar 25, 2025
@jennan
Copy link
Collaborator Author

jennan commented Mar 25, 2025

I closing this PR in favor of #64. Isort related cyclic import fixes will come as separate PRs.

@jennan jennan closed this Mar 25, 2025
@jennan jennan deleted the pre-commit branch March 25, 2025 09:42
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.

Add pre-commit to the development dependencies

3 participants