Closed imnotdev25 closed 3 days ago
Hi @imnotdev25, thanks for the report. The two messages refer to very different and unrelated types of inspection, so this is actually two bugs. Please can you share some of the code and/or other details? What version of sqlalchemy is this? What is the UserFormCreate
class? Where was the original warning raised from?
Hi @imnotdev25, thanks for the report. The two messages refer to very different and unrelated types of inspection, so this is actually two bugs. Please can you share some of the code and/or other details? What version of sqlalchemy is this? What is the
UserFormCreate
class? Where was the original warning raised from?
Hello @alexmojaki, I'm having the same issue. In an SQLModel project based on my boilerplate FastAPI Async SQLModel Boilerplate. Here is how I am implementing it:
backend/src/core/utils/observability.py
# Third-Party Dependencies
import logfire
# Local Dependencies
from src.core.config import settings
# Set up observability on FastAPI application
if settings.LOGFIRE_TOKEN:
logfire.configure(
project_name=settings.PROJECT_NAME,
service_name=f"{settings.PROJECT_NAME} ({str(settings.ENVIRONMENT.value).upper()})",
token=settings.LOGFIRE_TOKEN,
pydantic_plugin=logfire.PydanticPlugin(record="all" if settings.PYDANTIC_TRACE else "off"),
console=False,
)
backend/src/main.py
# Local Dependencies
from src.core.setup import create_application
from src.core.config import settings
from src.core.api import router
# Set up FastAPI application
app = create_application(router=router, settings=settings)
# Set up observability on FastAPI application
if settings.LOGFIRE_TOKEN and settings.ASGI_TRACE:
from src.core.utils.observability import logfire
logfire.instrument_fastapi(app)
However, I receive the following exception in the console during the data deserialization process (one for each record to be deserialized by SQLModel):
INFO: 127.0.0.1:46430 - "GET /api/v1/system/users?page=1&items_per_page=10 HTTP/1.1" 200 OK
2024-06-29 01:23:33,609 - logfire - ERROR - Internal error in Logfire
Traceback (most recent call last):
File "/home/ubuntu/Example/Server/backend/.venv/lib/python3.11/site-packages/logfire/_internal/utils.py", line 236, in handle_internal_errors
yield
File "/usr/lib/python3.11/contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/Example/Server/backend/.venv/lib/python3.11/site-packages/logfire/_internal/main.py", line 1613, in set_attribute
self._json_schema_properties[key] = create_json_schema(value, set())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/Example/Server/backend/.venv/lib/python3.11/site-packages/logfire/_internal/json_schema.py", line 120, in create_json_schema
return _sqlalchemy_schema(obj, seen)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/Example/Server/backend/.venv/lib/python3.11/site-packages/logfire/_internal/json_schema.py", line 329, in _sqlalchemy_schema
state = sa_inspect(obj)
^^^^^^^^^^^^^^^
File "/home/ubuntu/Example/Server/backend/.venv/lib/python3.11/site-packages/sqlalchemy/inspection.py", line 147, in inspect
raise exc.NoInspectionAvailable(
sqlalchemy.exc.NoInspectionAvailable: No inspection system is available for object of type <class 'src.apps.shared.system.users.schemas.UserRead'>
The strangest thing is that the Pydantic tracing is being exported correctly, appearing in the Web UI as 'Pydantic UserRead validate_python succeeded'.
Below are the current dependencies:
logfire = {extras = ["fastapi", "sqlalchemy", "system-metrics"], version = "^0.44.0"}
I am using SQLModel with Logfire because on the page 'https://docs.pydantic.dev/logfire/integrations/sqlalchemy/#usage' you included a note that this is possible: 'If you use SQLModel, you can use the same SQLAlchemyInstrumentor to instrument it.'
Thank you very much, and this tool is becoming amazing!! 🪵🔥🚀"
Released a fix, please pip install -U logfire
and try again!
For the Failed to introspect calling code
warning, if you see it again please open a new issue with more details.
Released a fix, please
pip install -U logfire
and try again!For the
Failed to introspect calling code
warning, if you see it again please open a new issue with more details.
Hello again @alexmojaki!
I tested it here, and now it works correctly.
I am impressed with the speed at which this bug/issue was resolved. I am confident that Pydantic Logfire will soon become a reference tool for Python in terms of observability.
Thank you for the fix! I wish you all success!
Description
Failed to introspect calling code. Please report this issue to Logfire. Falling back to normal message formatting which may result in loss of information if using an f-string. Set inspect_arguments=False in logfire.configure() to suppress this warning. The problem was:
executing
failed to find a node.I tried to set parameter but still same.
Traceback:
Traceback (most recent call last): File "/root/PycharmProjects/backend-user-form-api/.venv/lib/python3.11/site-packages/logfire/_internal/utils.py", line 236, in handle_internal_errors yield File "/usr/lib/python3.11/contextlib.py", line 81, in inner return func(*args, kwds) ^^^^^^^^^^^^^^^^^^^ File "/root/PycharmProjects/backend-user-form-api/.venv/lib/python3.11/site-packages/logfire/_internal/main.py", line 1613, in set_attribute self._json_schema_properties[key] = create_json_schema(value, set()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/PycharmProjects/backend-user-form-api/.venv/lib/python3.11/site-packages/logfire/_internal/json_schema.py", line 118, in create_json_schema return _mapping_schema(obj, seen) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/PycharmProjects/backend-user-form-api/.venv/lib/python3.11/site-packages/logfire/_internal/json_schema.py", line 212, in _mapping_schema _properties({(k if isinstance(k, str) else safe_repr(k)): v for k, v in obj.items()}, seen), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/PycharmProjects/backend-user-form-api/.venv/lib/python3.11/site-packages/logfire/_internal/json_schema.py", line 337, in _properties if (value_schema := create_json_schema(value, seen)) not in PLAIN_SCHEMAS: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/PycharmProjects/backend-user-form-api/.venv/lib/python3.11/site-packages/logfire/_internal/json_schema.py", line 120, in create_json_schema return _sqlalchemy_schema(obj, seen) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/root/PycharmProjects/backend-user-form-api/.venv/lib/python3.11/site-packages/logfire/_internal/json_schema.py", line 329, in _sqlalchemy_schema state = sa_inspect(obj) ^^^^^^^^^^^^^^^ File "/root/PycharmProjects/backend-user-form-api/.venv/lib/python3.11/site-packages/sqlalchemy/inspection.py", line 147, in inspect raise exc.NoInspectionAvailable( sqlalchemy.exc.NoInspectionAvailable: No inspection system is available for object of type <class 'form_api.schema.user_details.UserFormCreate'>
Python, Logfire & OS Versions, related packages (not required)