Skip to content

Commit cf66a25

Browse files
mhuckagemini-code-assist[bot]pavoljuhas
authored
Skip Pubchem live API test in CI (#1288)
Even with many retries and long delays, the test fails for almost every PR. I don't know why this has been happening lately; perhaps Pubchem's servers have become overloaded lately (possibly due to an increase in the use of AI agents?). In any case, there seems to be no good solution to stop flaky failures in CI except to simply skip the test in CI. The approach implemented here tests an environment variable set by GitHub in their runner environments. If that variable is set, the live API test is skipped; otherwise, it's run as usual. This means that developers in their normal local environments will run the tests as usual, and don't have to do anything special. In addition, our CI workflows don't need to change either. --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Pavol Juhas <pavol.juhas@gmail.com>
1 parent b30baca commit cf66a25

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/openfermion/chem/pubchem_test.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212

1313
"""Tests for pubchem.py."""
1414

15+
import os
16+
1517
import numpy
16-
import pytest
1718
import pubchempy
19+
import pytest
1820

1921
from openfermion.chem.pubchem import geometry_from_pubchem
2022
from openfermion.testing.testing_utils import module_importable
@@ -149,6 +151,11 @@ def test_water_2d(self, monkeypatch):
149151
with pytest.raises(ValueError, match='Incorrect value for the argument structure'):
150152
_ = geometry_from_pubchem('water', structure='foo')
151153

154+
# Skip if running in a CI environment.
155+
@pytest.mark.skipif(
156+
'CI' in os.environ,
157+
reason='Skipping Pubchem API tests in CI to avoid failures due to busy servers.',
158+
)
152159
@pytest.mark.flaky(retries=8, delay=30, only_on=[pubchempy.ServerBusyError])
153160
def test_geometry_from_pubchem_live_api(self):
154161
water_geometry = geometry_from_pubchem('water')

0 commit comments

Comments
 (0)