Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@geographika
Copy link
Collaborator

What does this PR do?

Adds in a new ctest check to ensure docstub annotations can be correctly generated. If errors are introduced, the docs CI action will fail.

This will prevent invalid annotations being added to the Python docstrings, in preparation for creating stubs as part of the Python bindings.

If the CI fails then the errors will be reported in the logs similar to below:

2025-10-22T19:03:34.7781906Z 1392 matched annotations
2025-10-22T19:03:34.7782232Z 1 syntax errors
2025-10-22T19:03:34.7782538Z 30 unknown type names
2025-10-22T19:03:34.7782851Z   SpatialReference (x10)
..
2025-10-22T19:03:34.7784938Z   Feature (x1)
2025-10-22T19:03:34.7785237Z   datetime.datetime (x1)
2025-10-22T19:03:34.7785575Z   Transformer (x1)
2025-10-22T19:03:34.7785859Z 31 total errors
2025-10-22T19:03:34.7786030Z 
2025-10-22T19:03:34.7786152Z Finished in 11.006 s
2025-10-22T19:03:34.7786345Z 
2025-10-22T19:03:34.7786480Z Errors while running CTest
2025-10-22T19:03:34.7786700Z 
2025-10-22T19:03:34.7786861Z 0% tests passed, 1 tests failed out of 1
2025-10-22T19:03:34.7787144Z 
2025-10-22T19:03:34.7787235Z Total Test time (real) =  11.63 sec
2025-10-22T19:03:34.7787387Z 
2025-10-22T19:03:34.7787471Z The following tests FAILED:
2025-10-22T19:03:34.7787684Z 	  3 - docstub-annotations (Failed)

A few errors were introduced since #13198 was merged, and these have also been fixed.

What are related issues/pull requests?

#13198

@geographika geographika added funded through GSP Work funded through the GDAL Sponsorship Program Continuous integration documentation Issues and contributions to the documentation content labels Oct 22, 2025
@coveralls
Copy link
Collaborator

coveralls commented Oct 22, 2025

Coverage Status

coverage: 71.352% (+0.02%) from 71.33%
when pulling f635b66 on geographika:docstub-checks
into 76318b2 on OSGeo:master.

@geographika
Copy link
Collaborator Author

@dbaston - I've added a new python_stub_files target, and tested it on build-windows-conda in the "Build and test with CMake" action.

Output is:

Run cmake --build $GITHUB_WORKSPACE/build --config Release -j 2 --target python_stub_files
[0/2] Re-checking globbed directories...
[1/2] C:\Windows\system32\cmd.exe /C "cd /D D:\a\gdal\gdal\build\swig\python && C:\Users\runneradmin\miniconda3\envs\gdalenv\python.exe -m docstub run D:/a/gdal/gdal/build/swig/python/osgeo --config D:/a/gdal/gdal/build/swig/python/pyproject.toml"
1423 matched annotations
0 total errors

Finished in 15.446 s

I'll need some guidance on where this should be added in the CI, and default build options.

  • A new CMake option BUILD_PYTHON_STUBS has been added, and set to OFF by default. I presume we don't want to set to ON until the stubs are useful?
  • https://pypi.org/project/docstub/#files - only has docstub-0.4.0.tar.gz available - so there is no Windows option (apart from through conda).

Once finalised, I presume I should remove the ctest code?

@dbaston dbaston added this to the 3.13.0 milestone Oct 27, 2025
Copy link
Member

@dbaston dbaston left a comment

Choose a reason for hiding this comment

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

I'll need some guidance on where this should be added in the CI, and default build options.

I'd add it to one of the Linux builds, maybe Ubuntu 24.04, for faster feedback / easier reproducibility.

A new CMake option BUILD_PYTHON_STUBS has been added, and set to OFF by default. I presume we don't want to set to ON until the stubs are useful?

I'd be inclined to leave it OFF except in one CI configuration, otherwise we have to do test that docstub is actually available, etc.

https://pypi.org/project/docstub/#files - only has docstub-0.4.0.tar.gz available - so there is no Windows option (apart from through conda).

Looks like 0.5.0 is available now.

Once finalised, I presume I should remove the ctest code?

That makes sense to me.

@geographika
Copy link
Collaborator Author

@dbaston - I've tried a few different ways to add the stub building to CI but without success. The

  • adding to ubuntu-22.04 in cmake_build.yml, needs to also install docstub (currently only in the docs/requirements.txt), but this only installs an older version 0.2.1 (I'm assuming to due to an older version of Python. --break-system-packages isn't supported when trying to run PYTHON_CMD=python3 && $PYTHON_CMD -m pip install docstub==0.5.0 --break-system-packages
  • I also tried adding to linux_build.yml but I was unsure where any Python dependencies can / should be installed. .github/ubuntu_24.04/build.sh? I was unable to get a successful build.

IMHO I think it would be useful to keep the doc_checks.yml checks for the stubs. Any errors to stub generation will be caused by modifying the Python docstrings, so it falls into the documentation category. It might also be clearer to keep this failure rather than using a Linux build failure to highlight docstub issues. Ideally we'd have both the docs check and the CI build with docstubs - maybe this could be addressed in a separate PR?

Note - the current CI failure seems unrelated (I rolled back all recent CI changes).

@dbaston
Copy link
Member

dbaston commented Oct 31, 2025

I also tried adding to linux_build.yml but I was unsure where any Python dependencies can / should be installed.

dbaston@641e8e3 updates the Ubuntu 24.04 configuration to build the stubs. But a lot of warnings come out (https://github.com/dbaston/gdal/actions/runs/18979916443/job/54209573643#step:14:5542) which for some reason don't seem to block the build.

Ideally we'd have both the docs check and the CI build with docstubs - maybe this could be addressed in a separate PR?

That makes sense. My only request for the docs check piece would be to remove docstub from doc/requirements.txt and install it in doc_checks.yml.

@geographika
Copy link
Collaborator Author

That makes sense. My only request for the docs check piece would be to remove docstub from doc/requirements.txt and install it in doc_checks.yml.

Done.

But a lot of warnings come out (https://github.com/dbaston/gdal/actions/runs/18979916443/job/54209573643#step:14:5542)

Strange - this wasn't happening with the ctest. docstub 0.5.0 has been released since then - I'll check locally to see if I can recreate.

@rouault
Copy link
Member

rouault commented Nov 3, 2025

are we good to merge this PR or is there still something to be done?

@dbaston
Copy link
Member

dbaston commented Nov 3, 2025

OK to squash/merge as far as I'm concerned, we can sort out the build warnings in a subsequent PR.

@rouault rouault merged commit 738c71b into OSGeo:master Nov 3, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Continuous integration documentation Issues and contributions to the documentation content funded through GSP Work funded through the GDAL Sponsorship Program

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants