pytest-dev / pytest-dev/pytest

Class Paths Have Strange Behavior on 8.3.4

Open
#13,050 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic: collection
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

Hello! We are having an issue in our repo where 8.3.4 pytest (but not 8.3.3) caused our classes to have strange behavior at runtime with errors like:

        if (dest_type, src_type, modifiers) not in self.write:
>           raise IORegistryError._from_write_parts(dest_type, src_type, modifiers)
E           anndata._io.specs.registry.IORegistryError: No method registered for writing <class 'opt.hostedtoolcache.Python.3_12_7.x64.lib.python3_12.site-packages.anndata._core.views.AwkwardArrayView'> into <class 'h5py._hl.group.Group'>
E           Error raised while writing key 'awk_2d_ragged' of <class 'h5py._hl.group.Group'> to /obsm

when in reality, the AwkwardArrayView is in the self.write dictionary, but as
<class 'anndata._core.views.AwkwardArrayView'>:

Screenshot 2024-12-11 at 11 34 41

(This screenshot is from my attempt to fix the issue where I printed out the contents of self.write)

Also weirdly I cannot reproduce this locally. I have tried creating a local reproducer with an src/package/__init__.py file for a dummy package like:

d = {}

class Foo():
    pass

d[Foo] = True

def check(typ: type) -> bool:
    return d[typ]

__all__ = ["Foo", "check"]

with a single pytest

from package import Foo, check

def test_check():
    f = Foo()
    assert check(type(f))

But this seems to work when I run pytest instead of throwing a KeyError. I will continue to try to dig but I wanted to report.

See also my various attempted to fix the issue

Python Env:

anndata 0.11.1.dev18+g6594d93 anyio 4.6.2.post1 array-api-compat 1.9.1 asciitree 0.3.3 scikit-learn 1.5.2 scipy 1.14.1 seaborn 0.13.2 session-info 1.0.0 setuptools 75.6.0 setuptools-scm 8.1.0 six 1.16.0 sniffio 1.3.1 sortedcontainers 2.4.0 statsmodels 0.14.4 stdlib-list 0.11.0 tblib 3.0.0 textual 0.88.1 threadpoolctl 3.5.0 toolz 1.0.0 tornado 6.4.2 towncrier 24.8.0 tqdm 4.67.1 typing-extensions 4.12.2 tzdata 2024.2 uc-micro-py 1.0.3 umap-learn 0.5.7 urllib3 2.2.3 uv 0.5.5 zarr 2.18.3 zict 3.0.0

Compute Env:

Starting: Initialize job Agent name: 'Azure Pipelines 5' Agent machine name: 'fv-az360-809' Current agent version: '4.248.0' Downloading task: PublishPipelineMetadata (0.248.1) Checking job knob settings. Knob: DockerActionRetries = true Source: $(VSTSAGENT_DOCKER_ACTION_RETRIES) Knob: AgentToolsDirectory = /opt/hostedtoolcache Source: ${AGENT_TOOLSDIRECTORY} Knob: UseGitLongPaths = true Source: $(USE_GIT_LONG_PATHS) Knob: AgentPerflog = /home/vsts/perflog Source: ${VSTS_AGENT_PERFLOG} Knob: EnableIssueSourceValidation = true Source: $(ENABLE_ISSUE_SOURCE_VALIDATION) Knob: AgentEnablePipelineArtifactLargeChunkSize = true Source: $(AGENT_ENABLE_PIPELINEARTIFACT_LARGE_CHUNK_SIZE) Knob: ContinueAfterCancelProcessTreeKillAttempt = true Source: $(VSTSAGENT_CONTINUE_AFTER_CANCEL_PROCESSTREEKILL_ATTEMPT) Knob: ProcessHandlerSecureArguments = false Source: $(AZP_75787_ENABLE_NEW_LOGIC) Knob: ProcessHandlerSecureArguments = false Source: $(AZP_75787_ENABLE_NEW_LOGIC_LOG) Knob: ProcessHandlerTelemetry = true Source: $(AZP_75787_ENABLE_COLLECT) Knob: UseNewNodeHandlerTelemetry = True Source: $(DistributedTask.Agent.USENEWNODEHANDLERTELEMETRY) Knob: ProcessHandlerEnableNewLogic = true Source: $(AZP_75787_ENABLE_NEW_PH_LOGIC) Knob: EnableResourceMonitorDebugOutput = true Source: $(AZP_ENABLE_RESOURCE_MONITOR_DEBUG_OUTPUT) Knob: EnableResourceUtilizationWarnings = true Source: $(AZP_ENABLE_RESOURCE_UTILIZATION_WARNINGS) Knob: IgnoreVSTSTaskLib = true Source: $(AZP_AGENT_IGNORE_VSTSTASKLIB) Knob: FailJobWhenAgentDies = true Source: $(FAIL_JOB_WHEN_AGENT_DIES) Knob: CheckForTaskDeprecation = true Source: $(AZP_AGENT_CHECK_FOR_TASK_DEPRECATION) Knob: CheckIfTaskNodeRunnerIsDeprecated246 = True Source: $(DistributedTask.Agent.CheckIfTaskNodeRunnerIsDeprecated246) Knob: UseNode20ToStartContainer = True Source: $(DistributedTask.Agent.UseNode20ToStartContainer) Knob: LogTaskNameInUserAgent = true Source: $(AZP_AGENT_LOG_TASKNAME_IN_USERAGENT) Knob: UseFetchFilterInCheckoutTask = true Source: $(AGENT_USE_FETCH_FILTER_IN_CHECKOUT_TASK) Knob: Rosetta2Warning = true Source: $(ROSETTA2_WARNING) Knob: AddForceCredentialsToGitCheckout = True Source: $(DistributedTask.Agent.AddForceCredentialsToGitCheckout) Finished checking job knob settings. Start tracking orphan processes. Finishing: Initialize job
  • a detailed description of the bug or problem you are having
  • output of pip list from the virtual environment you are using
  • pytest and operating system versions
  • minimal example if possible (attempted)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported anndata failure with pytest 8.3.4 and compare it with 8.3.3, using the environment details and the linked anndata issue. Check the provided minimal package example as well as the failing class lookup, then add a regression test showing the expected class identity behavior. Done means the regression passes on the affected version without breaking the existing test suite.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.