Skip to content

Fix unit test warnings and compatibility issues (Python 3.12, Pandas, SQLAlchemy)#3722

Open
jkppr wants to merge 8 commits intogoogle:masterfrom
jkppr:fix-test-warnings
Open

Fix unit test warnings and compatibility issues (Python 3.12, Pandas, SQLAlchemy)#3722
jkppr wants to merge 8 commits intogoogle:masterfrom
jkppr:fix-test-warnings

Conversation

@jkppr
Copy link
Collaborator

@jkppr jkppr commented Feb 13, 2026

This PR resolves multiple warnings and compatibility issues encountered during unit test execution, ensuring full compatibility with Python 3.12. It addresses deprecation warnings from core libraries (Pandas, NetworkX), fixes SQLAlchemy session management in tests, and resolves a circular import dependency.

Key Changes:

  • Test Dependencies:

    • Upgraded pytest to 9.0.2 in test_requirements.txt to fix RuntimeWarning: TestResult has no addDuration method.
    • Upgraded networkx to 3.4.2 in requirements.txt to resolve DeprecationWarning: datetime.datetime.utcfromtimestamp() on Python 3.12.
  • Code Refactoring & Fixes:

    • SQLAlchemy: Fixed SAWarning in timesketch/lib/testlib.py by removing redundant engine recreation in ModelBaseTest, ensuring correct session reuse from BaseTest.
    • Circular Imports: Moved get_yaml_config and get_config_path from analyzers/interface.py to lib/utils.py to break the dependency cycle between interface and ontology.
    • Pandas Compliance:
      • In authentication/utils.py, replaced inplace=True with explicit assignment for fillna and sort_values to fix FutureWarning.
      • In llms/features/nl2q.py, updated groupby().apply() to use include_groups=False (Pandas 2.2+ requirement) and adjusted group name access.

google-labs-jules bot and others added 8 commits February 13, 2026 14:05
- Upgraded `pytest` to 9.0.2 in `test_requirements.txt` to resolve compatibility warnings with Python 3.12 (`TestResult has no addDuration method`).
- Fixed `SAWarning` in `timesketch/lib/testlib.py` by removing redundant engine recreation in `ModelBaseTest`, which conflicted with the existing session.
- Moved `get_yaml_config` and `get_config_path` from `timesketch/lib/analyzers/interface.py` to `timesketch/lib/utils.py` to resolve circular import dependencies between `interface`, `ontology`, and `api/v1/utils`.
- Updated imports in `timesketch/lib/analyzers/interface.py` and `timesketch/lib/ontology.py`.
- Fixed `FutureWarning` in `timesketch/lib/analyzers/authentication/utils.py` by removing `inplace=True` from `fillna` and `sort_values` calls on Pandas DataFrames.
- Fixed `DeprecationWarning` in `timesketch/lib/llms/features/nl2q.py` by using `include_groups=False` in `groupby().apply()` and updating the callback to access the group name correctly.

Co-authored-by: jkppr <99879757+jkppr@users.noreply.github.com>
- Upgraded `pytest` to 9.0.2 in `test_requirements.txt` to fix compatibility with Python 3.12 (resolves `TestResult has no addDuration method`).
- Upgraded `networkx` to 3.4.2 in `requirements.txt` to fix `datetime` deprecation warnings on Python 3.12.
- Fixed `SAWarning` in `timesketch/lib/testlib.py` by removing redundant engine recreation in `ModelBaseTest`, which conflicted with the session from `BaseTest`.
- Moved `get_yaml_config` and `get_config_path` from `timesketch/lib/analyzers/interface.py` to `timesketch/lib/utils.py` to resolve circular import dependencies between `interface` and `ontology`.
- Updated `timesketch/lib/ontology.py` and `timesketch/lib/analyzers/interface.py` to import config functions from `timesketch.lib.utils`.
- Fixed `FutureWarning` in `timesketch/lib/analyzers/authentication/utils.py` by removing `inplace=True` from `fillna` and `sort_values` calls on Pandas DataFrames.
- Fixed `DeprecationWarning` in `timesketch/lib/llms/features/nl2q.py` by using `include_groups=False` in `groupby().apply()` and updating the callback to access the group name correctly.

Co-authored-by: jkppr <99879757+jkppr@users.noreply.github.com>
- Upgraded `pytest` to 9.0.2 in `test_requirements.txt` to fix compatibility with Python 3.12 (resolves `TestResult has no addDuration method`).
- Upgraded `networkx` to 3.4.2 in `requirements.txt` to fix `datetime` deprecation warnings on Python 3.12.
- Fixed `SAWarning` in `timesketch/lib/testlib.py` by removing redundant engine recreation in `ModelBaseTest`, which conflicted with the session from `BaseTest`.
- Moved `get_yaml_config` and `get_config_path` from `timesketch/lib/analyzers/interface.py` to `timesketch/lib/utils.py` to resolve circular import dependencies between `interface` and `ontology`.
- Updated `timesketch/lib/ontology.py` and `timesketch/lib/analyzers/interface.py` to import config functions from `timesketch.lib.utils`.
- Fixed `FutureWarning` in `timesketch/lib/analyzers/authentication/utils.py` by removing `inplace=True` from `fillna` and `sort_values` calls on Pandas DataFrames.
- Fixed `DeprecationWarning` in `timesketch/lib/llms/features/nl2q.py` by using `include_groups=False` in `groupby().apply()` and updating the callback to access the group name correctly.

Co-authored-by: jkppr <99879757+jkppr@users.noreply.github.com>
- Upgraded `pytest` to 9.0.2 in `test_requirements.txt` to fix compatibility with Python 3.12 (resolves `TestResult has no addDuration method`).
- Upgraded `networkx` to 3.4.2 in `requirements.txt` to fix `datetime` deprecation warnings on Python 3.12.
- Fixed `SAWarning` in `timesketch/lib/testlib.py` by removing redundant engine recreation in `ModelBaseTest`, which conflicted with the session from `BaseTest`.
- Moved `get_yaml_config` and `get_config_path` from `timesketch/lib/analyzers/interface.py` to `timesketch/lib/utils.py` to resolve circular import dependencies between `interface` and `ontology`.
- Updated `timesketch/lib/ontology.py` and `timesketch/lib/analyzers/interface.py` to import config functions from `timesketch.lib.utils`.
- Fixed `FutureWarning` in `timesketch/lib/analyzers/authentication/utils.py` by removing `inplace=True` from `fillna` and `sort_values` calls on Pandas DataFrames.
- Fixed `DeprecationWarning` in `timesketch/lib/llms/features/nl2q.py` by using `include_groups=False` in `groupby().apply()` and updating the callback to access the group name correctly.
- Addressed code review feedback: removed unused imports in `interface.py` and fixed logger formatting in `utils.py`.

Co-authored-by: jkppr <99879757+jkppr@users.noreply.github.com>
@jkppr jkppr self-assigned this Feb 13, 2026
@jkppr jkppr added the Code Health Code health improvements label Feb 13, 2026
@jkppr
Copy link
Collaborator Author

jkppr commented Feb 13, 2026

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively addresses a range of compatibility issues and warnings, enhancing the project's robustness and maintainability. The dependency upgrades for pytest and networkx are necessary for Python 3.12 support. The refactoring of Pandas calls to remove inplace=True and update groupby().apply() usage aligns with modern library practices and resolves future warnings. Moving utility functions to lib/utils.py to break a circular dependency is a solid architectural improvement, and the opportunity was taken to fix a minor logging style issue. The fix in testlib.py to remove redundant SQLAlchemy engine creation correctly resolves a warning during test execution. Overall, these are all positive changes that improve code quality. I have no further comments.

@jkppr jkppr requested a review from jaegeral February 13, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Health Code health improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant