Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload scrublet scores on test failure #3069

Merged
merged 15 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ jobs:
testResultsFormat: NUnit
testRunTitle: 'Publish test results for $(Agent.JobName)'

- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '.pytest_cache/d/debug'
artifactName: debug-data
condition: eq(variables['TEST_TYPE'], 'coverage')

- script: bash <(curl -s https://codecov.io/bash)
displayName: 'Upload to codecov.io'
condition: eq(variables['TEST_TYPE'], 'coverage')
Expand Down
2 changes: 2 additions & 0 deletions src/testing/scanpy/_pytest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def _global_test_context(
sc.settings.logfile = sys.stderr
sc.settings.verbosity = "hint"
sc.settings.autoshow = True
# create directory for debug data
cache.mkdir("debug")
# reuse data files between test runs (unless overwritten in the test)
sc.settings.datasetdir = cache.mkdir("scanpy-data")
# create new writedir for each test run
Expand Down
36 changes: 27 additions & 9 deletions tests/test_scrublet.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _create_sim_from_parents(adata: AnnData, parents: np.ndarray) -> AnnData:
)


def test_scrublet_data():
def test_scrublet_data(cache: pytest.Cache):
"""
Test that Scrublet processing is arranged correctly.

Expand Down Expand Up @@ -156,14 +156,32 @@ def test_scrublet_data():
random_state=random_state,
)

# Require that the doublet scores are the same whether simulation is via
# the main function or manually provided
assert_allclose(
adata_scrublet_manual_sim.obs["doublet_score"],
adata_scrublet_auto_sim.obs["doublet_score"],
atol=1e-15,
rtol=1e-15,
)
try:
# Require that the doublet scores are the same whether simulation is via
# the main function or manually provided
assert_allclose(
adata_scrublet_manual_sim.obs["doublet_score"],
adata_scrublet_auto_sim.obs["doublet_score"],
atol=1e-15,
rtol=1e-15,
)
except AssertionError:
import zarr

# try debugging https://github.com/scverse/scanpy/issues/3068
cache_path = cache.mkdir("debug")
store_manual = zarr.ZipStore(cache_path / "scrublet-manual.zip", mode="w")
store_auto = zarr.ZipStore(cache_path / "scrublet-auto.zip", mode="w")
z_manual = zarr.zeros(
adata_scrublet_manual_sim.shape[0], chunks=10, store=store_manual
)
z_auto = zarr.zeros(
adata_scrublet_auto_sim.shape[0], chunks=10, store=store_auto
)
z_manual[...] = adata_scrublet_manual_sim.obs["doublet_score"].values
z_auto[...] = adata_scrublet_auto_sim.obs["doublet_score"].values

raise


@pytest.fixture(scope="module")
Expand Down
Loading