Skip to content

Refactor task buffer type declarations and improve type checking - #878

Merged
tmaeno merged 3 commits into
PanDAWMS:masterfrom
tmaeno:master
Nov 19, 2026
Merged

tmaeno merged 3 commits into
PanDAWMS:masterfrom
tmaeno:master

Conversation

@tmaeno

@tmaeno tmaeno commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

This pull request improves type safety across several modules by replacing generic Any types with more specific "TaskBuffer" type annotations. This helps clarify function signatures and class constructors, making the codebase easier to understand and maintain. Additionally, minor updates were made to the test suite to ensure compatibility with these type changes.

Type annotation improvements:

  • Updated function and variable signatures in pandaserver/api/v1/common.py to use "TaskBuffer" instead of Any, including the _command_logging_modules dictionary and related functions. [1] [2]
  • Changed the taskBufferIF parameter in the get_params_to_get_tasks function in pandajedi/jediorder/JobGenerator.py to use a more precise type annotation: "JediTaskBufferInterface | JediTaskBuffer".

Test suite adjustments:

  • In pandaserver/api/v1/tests/task_command_log_tests.py, used TYPE_CHECKING and cast to ensure that the fake task buffer is treated as a "TaskBuffer" for type checking purposes. [1] [2] [3]

Daemon script updates:

  • Updated the constructor signatures of the EvpThr thread classes in pandaserver/daemons/scripts/evpPD2P.py and pandaserver/daemons/scripts/recover_lost_files_daemon.py to require a "TaskBuffer" instead of Any. [1] [2]

tmaeno and others added 3 commits November 19, 2026 16:55
run_logged_task_command, log_task_commands and _command_logging_modules took the
task buffer as Any, though their docstrings say TaskBuffer and common.py already
imports it for type checking. They now declare it, so the calls to
insert_task_command and set_task_command_response are checked against the DB
proxy's signatures. They match.

The test registers a fake that implements only what run_logged_task_command uses,
and now casts it.
The EvpThr threads of recover_lost_files_daemon and evpPD2P are given the server's
TaskBuffer, as each daemon's main already declares. get_params_to_get_tasks is
given a JediTaskBufferInterface by JobGenerator and a JediTaskBuffer by the job
generator message processor, so it takes either, as JobGeneratorThread already
does.

After this no task buffer in pandaserver or pandajedi is declared Any.
@tmaeno
tmaeno merged commit 203cb99 into PanDAWMS:master Nov 19, 2026
1 check 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.

1 participant