quantumlib / OpenFermion

The electronic structure package for quantum computers.
Apache License 2.0
1.51k stars 372 forks source link

Enable testing for resource estimates #828

Closed fdmalone closed 1 year ago

fdmalone commented 1 year ago

Previously the resource estimation code was not being tested as part of the CI (#825) . This PR enables it, I've marked a few tests as slow and will open an issue to track the fact that one dependency (btas/pybtas) doesn't have any tests. I think we should add a weekly workflow which will run the slow tests and run a yet to be written pybtas unit test.

I'm only testing the resource estimate code for linux and mac as I don't think pyscf works on windows.

fdmalone commented 1 year ago

@mpharrigan PTAL

mpharrigan commented 1 year ago

the output from the ci job looks like the desired tests aren't being run (??)

Run check/pytest -m 'not slow' src/openfermion/resource_estimates
============================= test session starts ==============================
platform linux -- Python 3.10.12, pytest-[7](https://github.com/quantumlib/OpenFermion/actions/runs/5735347442/job/15542949189?pr=828#step:5:8).3.1, pluggy-1.0.0
rootdir: /home/runner/work/OpenFermion/OpenFermion/dev_tools/conf
configfile: pytest.ini
plugins: cov-4.0.0, asyncio-0.21.0, xdist-3.3.1
asyncio: mode=strict
collected 25 items / 7 deselected / 1[8](https://github.com/quantumlib/OpenFermion/actions/runs/5735347442/job/15542949189?pr=828#step:5:9) selected

dev_tools/conf/utils_test.py .....                                       [ 27%]
dev_tools/conf/df/compute_cost_df_test.py ..                             [ 38%]
dev_tools/conf/df/compute_lambda_df_test.py .                            [ 44%]
dev_tools/conf/sf/compute_cost_sf_test.py ..                             [ 55%]
dev_tools/conf/sf/compute_lambda_sf_test.py .                            [ 61%]
dev_tools/conf/sparse/costing_sparse_test.py ..                          [ 72%]
dev_tools/conf/thc/compute_cost_thc_test.py ..                           [ 83%]
dev_tools/conf/thc/compute_lambda_thc_test.py .                          [ 88%]
dev_tools/conf/thc/spacetime_test.py ..                                  [[10](https://github.com/quantumlib/OpenFermion/actions/runs/5735347442/job/15542949189?pr=828#step:5:11)0%]

=============================== warnings summary ===============================
mpharrigan commented 1 year ago

or is that a weird artifact of the runner? those test files aren't in dev_tools/conf and are indeed the correct tests

fdmalone commented 1 year ago

very odd, I have no idea why it's giving those paths...

fdmalone commented 1 year ago

Maybe to do with pytest saying the root_dir is dev_tools/conf, maybe I used the wrong command to specify the pytest.ini file.

mpharrigan commented 1 year ago

maybe that grep expression is doing something weird

fdmalone commented 1 year ago

Nah the grep is quieting the output I think. I needed to pass --rootdir through to pytest, somehow specifying the pytest.ini file sets the rootdir to where the ini file is (dev_tools/conf). Should be fixed now.

fdmalone commented 1 year ago

Seems like it needed a re-review. Thanks!