Skip to content

Conversation

@conradhaupt
Copy link
Contributor

@conradhaupt conradhaupt commented Oct 30, 2025

Summary

Tests in test/training/models/ were not running with stestr (CI and Tox) as it is missing an __init__.py file (see #33). Running these tests showed that RandomRegularDepthOneFit was abstract, and thus tests failed. This PR also fixes this by implementing RandomRegularDepthOneFit.minimization(), raising an error as minimization is not defined for the trainer (see below for details).

Details and comments

stestr requires the test folder to be importable as a module, and thus __init__.py files are needed in every folder with test_*.py files. An __init__.py file was missing in test/training/models/ up until now and thus test_random_regular_fit.py was never run with CI unit-tests. As an example, see the latest commit as of this PR (ab7eaea) and associated Linux tests. We would expect there to be a line printed by stestr containing the string test.training.models.test_random_regular_fit.TestRandomRegularModel, but there is not, showing that these tests were never run.

⚠️ Important Note: The now-included tests are failing because of a separate issue which needs to be resolved. Fix to follow soon.

The tests for RandomRegularDepthOneFit were failing because it was missing minimization() and was abstract. The fix in this PR defines the method but with a raised error, as minimization() is not defined for this type of trainer. The class maps a problem instance to the closest known optimised parameters for a regular graph, based on average degree. There is no minimization carried out in this scenario.

Version updated

Not currently necessary.

@ElePT
Copy link
Collaborator

ElePT commented Oct 30, 2025

Thanks a lot for taking a look into the CI, as you can see, it's a bit of a pandora box...

@conradhaupt conradhaupt changed the title [wip] Fix test_random_regular_fit.py not running with stestr Fix abstract RandomRegularDepthOneFit and test_random_regular.py not running Nov 4, 2025
@conradhaupt
Copy link
Contributor Author

I've updated the PR with fixes for RandomRegularDepthOneFit so the now-running tests pass.

stestr may be failing on CI because of DeprecationWarnings raised by
tarfile on python3.12. Juliacall will download Julia as a tar file on
Ubuntu runners, extract the file, and install Julia. Other platform
runners get different files. With python3.12, tarfile raised a
DeprecationWarning about a change in the interface. It appears that
stestr will fail on test discovery if a warning is raised. Therefore,
only the Python3.12 tests appeared to fail on Linux devices where Julia
was not already installed. Locally, an installed version of Julia meant
that tests passed as juliacall didn't have to install it from a Tar
file.
It appears stestr does not pass PYTHONWARNINGS to subunit calls to
tests. This means that warnings are still raised by tests, which fail
stestr. This is useful if we're testing for warnings; however,
installing Julia appears to raise some deprecation warnings which we
do not want to fail on. Here we import from *.pauli_propagation to force
Julia installation and print a message if this succeeds. Failure
indicates that Julia installation failed too.
Copy link
Collaborator

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

Thanks a lot @conradhaupt, all changes look good, and your effort in fixing the CI is really appreciated.

@ElePT ElePT merged commit 9e5ffce into qiskit-community:main Nov 5, 2025
8 checks passed
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.

2 participants