dwavesystems / dwave-system

An API for easily incorporating the D-Wave system as a sampler, either directly or through Leap's cloud-based hybrid samplers
https://docs.ocean.dwavesys.com/
Apache License 2.0
87 stars 61 forks source link

Test/support Python 3.11 #492

Closed arcondello closed 1 year ago

arcondello commented 1 year ago

Add Python3.11 to CI tests.

In Python 3.11, accessing a Tempfile after the context has been exited raises a

ValueError: I/O operation on closed file.

This means that when we do something like

class LeapHybridCQMSampler:
    ...
    def sample_cqm(...):
        ...
        with cqm.to_file() as f:
            self.solver.sample_cqm(f, ...)

we get an error because sample_cqm() is non-blocking. To resolve it, we separate out the upload step. E.g.

with cqm.to_file() as f:
    sapi_problem_id = self.solver.upload_problem(f).result()  # blocking
self.solver.sample_cqm(sapi_problem_id, ...)

Also removed some large and slow integration tests.

codecov[bot] commented 1 year ago

Codecov Report

Merging #492 (a90fc12) into master (d37ff69) will decrease coverage by 3.17%. The diff coverage is 65.38%.

@@            Coverage Diff             @@
##           master     #492      +/-   ##
==========================================
- Coverage   90.87%   87.70%   -3.17%     
==========================================
  Files          24       24              
  Lines        1677     1676       -1     
==========================================
- Hits         1524     1470      -54     
- Misses        153      206      +53     
Impacted Files Coverage Δ
dwave/system/samplers/leap_hybrid_sampler.py 72.38% <65.38%> (-5.35%) :arrow_down:

... and 5 files with indirect coverage changes

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

arcondello commented 1 year ago

The big coverage diff is because the integration tests aren't being run on the PR.