Skip to content

Conversation

RajaMuhammadAwais
Copy link

…coped model loading fixture

Copy link

github-actions bot commented Aug 7, 2025


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@@ -0,0 +1,70 @@
# This workflow will upload a Python Package to PyPI when a release is created
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a publish.yml workflow, no need for this one.

@@ -0,0 +1,10 @@
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Editor specific config shouldn't be added to the repo.

(I have .vscode in my user level ~/.gitignore, but perhaps we should add it to the repo level one as well).

@@ -8,7 +8,7 @@

from lmstudio import AsyncClient, EmbeddingLoadModelConfig, LMStudioModelNotFoundError

from ..support import (
from tests.support import (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use of relative imports is intentional and shouldn't be changed.

@sdk_public_type
class LMStudioPredictionError(LMStudioServerError):
"""Problems reported by the LM Studio instance during a model prediction."""

@sdk_public_type
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more granular subclasses and the session scoped fixture loading would be easier to follow if placed in different PRs.

from tests.load_models import reload_models
asyncio.run(reload_models())
except Exception as e:
print(f"[Fixture] Skipping model loading: {e}", file=sys.stderr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some environments consider printing anything to stderr to be a test failure in its own right, so ideally we wouldn't even try to load the models when not lmstudio is part of the test marker filtering (or all the other model using test cases are otherwise filtered out).

This suggests that rather than autouse=True, we want something along the lines of the "marker to fixture usage" approach suggested in the this pytest issue comment:

def pytest_itemcollected(item):
    if item.get_closest_marker("lmstudio") is not None:
        item.applymarker(pytest.mark.usefixtures("load_required_models"))

Comment on lines +421 to +422
@sdk_public_type

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@sdk_public_type

Duplicated decorator

@@ -92,7 +92,8 @@ addopts = "--strict-markers"
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"lmstudio: marks tests as needing LM Studio (deselect with '-m \"not lmstudio\"')",
"wip: marks tests as a work-in-progress (select with '-m \"wip\"')"
"wip: marks tests as a work-in-progress (select with '-m \"wip\"')",
"asyncio: marks tests as asyncio-based",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"asyncio: marks tests as asyncio-based",

pytest.mark.asyncio is considered a standard marker (as long as pytest-asyncio is installed in the test execution environment), so it's allowed without needing to be explicitly listed even when strict markers are enabled.

Comment on lines +20 to +27
from .json_api import (
LMStudioPredictionError,
LMStudioModelLoadError,
LMStudioInputValidationError,
LMStudioPredictionTimeoutError,
LMStudioPredictionCancelledError,
LMStudioPredictionRuntimeError,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from .json_api import (
LMStudioPredictionError,
LMStudioModelLoadError,
LMStudioInputValidationError,
LMStudioPredictionTimeoutError,
LMStudioPredictionCancelledError,
LMStudioPredictionRuntimeError,
)

Exporting symbols at the top level is handled by listing them in the relevant __all__ list (the one in json_api in this case)

Copy link
Collaborator

@ncoghlan ncoghlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a first pass at this. Three big items:

  • the session scoped test fixture and the more detailed exceptions should be separate PRs
  • defining the more detailed exceptions is only the first step, the more significant step is raising them from the relevant locations (potentially narrowing the expected exception type in affected test cases)
  • there are several cosmetic changes which should be omitted entirely

Additional details on those points inline.

The CLA will also need to be signed before a PR can be accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants