Repository navigation
fix(experiments): reject nonpositive concurrency limits - #1980
Draft
linjiaye929 wants to merge 1 commit into
Draft
linjiaye929 wants to merge 1 commit into
linjiaye929 wants to merge 1 commit into
Conversation
|
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Reject nonpositive
max_concurrencyvalues before scheduling an experiment.With nonempty data,
max_concurrency=0creates a zero-permit semaphore and every item waits indefinitely. No task can enter the semaphore and release a permit. Negative values already raiseValueErrorfromasyncio.Semaphore; they retain that exception type with a more actionable message.The validation runs before experiment IDs, item tasks, or observations are created. The client and dataset docstrings explicitly require a value greater than zero, including for empty datasets. Positive limits and empty datasets with positive limits retain their behavior.
Type of change
Verification
Python 3.12.14; dependencies installed from the frozen lockfile.
socksio==1.0.0was added only to the local test environment so httpx could initialize with the execution environment's SOCKS proxy; dependency files are unchanged. Proxy settings were preserved for the final verification. Test commands useOTEL_TRACES_SAMPLER=always_onbecause the execution environment otherwise samples only 1% of spans; this only affects the test process and its in-memory exporter.OTEL_TRACES_SAMPLER=always_on .venv/bin/pytest tests/unit/test_experiment.py::TestExperimentConcurrency -q: 10 passed. Uses local asyncio scheduling and the repository's in-memory Langfuse fixture, with dummy credentials and no real provider or Langfuse requests.asyncio.wait_fortimeout and was cancelled. Empty data with zero concurrency did not raise, and negative inputs raised the old semaphoreValueErrormessage.OTEL_TRACES_SAMPLER=always_on .venv/bin/pytest tests/unit/test_experiment.py -q: 30 passed. The pristine base atbf11ec121479145923ff27b32ec2ad1d06fd2d51passes its 20 existing experiment tests with the same test-only sampler setting. Initial runs had four missing-span failures on both base and fixed source because of the inherited 1% sampler; those failures disappear with deterministic test sampling. This is not a full-suite or CI pass..venv/bin/ruff check .: passed..venv/bin/ruff format --check langfuse/_client/client.py langfuse/_client/datasets.py tests/unit/test_experiment.py: passed..venv/bin/mypy langfuse --no-error-summary: passed.git diff --check: passed.The full unit suite, E2E suite, and live-provider tests were not run.
Checklist
code_review.md.AI assistance: OpenAI Codex inspected the source, implemented the change, and ran the local checks described above.