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

Update sql_implementation.py to include sqlachemy output in debug logging. #782

Merged
merged 3 commits into from
Jul 31, 2024

Conversation

DnlRKorn
Copy link
Contributor

The current logging scheme for sql_queries directly outputs the sqlachemy query as rendered by what is the following:

q = session.query(...)
logging.info(str(q))

The following is the output from logging.info(f"ECA query: {q}") in function _equivalent_class_relationships.

INFO:root:ECA query: SELECT statements.subject AS statements_subject, statements.predicate AS statements_predicate, statements.object AS statements_object FROM statements
WHERE statements.predicate = ? AND statements.object IN (__[POSTCOMPILE_object_1]) AND statements.object IN (SELECT class_node.id FROM class_node)

With this change, when running at logging level DEBUG, anytime a query is executed sqlachemy will also writes it's logging output, which is the following:

INFO:sqlalchemy.engine.Engine:SELECT statements.subject AS statements_subject, statements.predicate AS statements_predicate, statements.object AS statements_object FROM statements
WHERE statements.predicate = ? AND statements.object IN (?) AND statements.object IN (SELECT class_node.id FROM class_node)
INFO:sqlalchemy.engine.Engine:[generated in 0.00023s] ('owl:equivalentClass', 'MONDO:0000550')

In the Sqlalchemy logging, the ambiguous term "(__[POSTCOMPILE_object_1])" isn't stated and instead replaced with a query parameter, and the query parameters are outputted on a second line.

DnlRKorn added 3 commits July 19, 2024 10:39
…ging.

The current logging scheme directly prints the query as rendered by str(q); the following is the output from logging.info(f"ECA query: {q}") in function _equivalent_class_relationships.

INFO:root:ECA query: SELECT statements.subject AS statements_subject, statements.predicate AS statements_predicate, statements.object AS statements_object
FROM statements
WHERE statements.predicate = ? AND statements.object IN (__[POSTCOMPILE_object_1]) AND statements.object IN (SELECT class_node.id
FROM class_node)

With this change, when running at logging level DEBUG, anytime a query is executed sqlachemy will also writes it's logging output, which is the following:
INFO:sqlalchemy.engine.Engine:SELECT statements.subject AS statements_subject, statements.predicate AS statements_predicate, statements.object AS statements_object
FROM statements
WHERE statements.predicate = ? AND statements.object IN (?) AND statements.object IN (SELECT class_node.id
FROM class_node)
INFO:sqlalchemy.engine.Engine:[generated in 0.00023s] ('owl:equivalentClass', 'MONDO:0000550')

In the Sqlalchemy logging, the ambiguous term "(__[POSTCOMPILE_object_1])" isn't stated and instead replaced with a query parameter, and the query parameters are outputted on a second line.
Corrected lint errors
@DnlRKorn
Copy link
Contributor Author

Updated branch to resolve lint errors.

@cmungall cmungall merged commit a112885 into INCATools:main Jul 31, 2024
9 checks passed
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