Skip to content

Client side tests for analysis-runner - #758

Open
Alexander-Stuckey wants to merge 6 commits into
mainfrom
nextflow-tower-cli
Open

Client side tests for analysis-runner#758
Alexander-Stuckey wants to merge 6 commits into
mainfrom
nextflow-tower-cli

Conversation

@Alexander-Stuckey

@Alexander-Stuckey Alexander-Stuckey commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Adding some client side tests for analysis-runner, before I make any changes to include Nextflow tower as a supported dispatch mode.

ALSO centralise dependency management into pyproject.toml

  • Add tests for both cli.py and cli_analysisrunner.py.
  • Minimal tests to ensure that jobs route correctly to cromwell.
  • Bump version of mypy and ruff, as they were quite outdated.
  • Centralise dependencies into pyproject.toml, delete setup.py etc, update build references.

Alexander-Stuckey and others added 2 commits May 20, 2026 15:27
Planning PR for the analysis-runner tw mode. No implementation yet —
this commit only anchors the branch so reviewers can engage with the
design described in the PR body before any code lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Alexander-Stuckey
Alexander-Stuckey requested a review from a team as a code owner July 5, 2026 22:37
@Alexander-Stuckey
Alexander-Stuckey requested review from violetbrina and removed request for a team July 5, 2026 22:37

@MattWellie MattWellie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good start. You can push the pre-commit versions even higher - pre-commit in general is at 6.0.0+, mypy has a version v2.1.0.

The get_repository_specific_information method is probably running as part of this call, and will pass if this testing branch is currently pushed to github which is a bit meta. Probably worth adding those checks in, as it's something we'll be re-using in TW... unless we exclusively stick with named workflows, I can't remember if we came to a decision on this.

@MattWellie
MattWellie self-requested a review July 5, 2026 23:18
@MattWellie

Copy link
Copy Markdown
Contributor

Confirming a few things from playing locally -

  1. the dev dependencies aren't present, ideally requirements-dev.in should have pytest and pytest-mock listed
  2. the dev dependencies are kinda... distributed at the moment in a couple of requirements files. Might be a nice upgrade to roll these into a extras_require section in the setup.py. The more modern approach would be to roll all the requirements, setup.py, and pyproject.toml into just a pyproject.toml... easier to manage too

in the tests:

  1. the git checks are present and un-mocked, this is doing a real check against the local and remote git history, and will fail if an un-pushed commit it added locally - failing stdout example
The commit "fe7d23eab841cf77619ec6c05270f2a82489d012" was not found on the remote (Github). 
Please confirm if you want to proceed anyway. (y/n): 

--

Feels bad raising these as issues and just... passing them over, lmk if you want to combine on this

@MattWellie MattWellie left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTMatt - doesn't touch functional code, adds tests, updates/modernises requirements and packaging. What's not to love? Maybe a version bump and a second approval from software 👀

@violetbrina violetbrina left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks so much for your work adding tests to the analysis-runner, a much overdue addition for sure. I have some very minor comments, and I'm not sure if @dancoates or anyone else from @populationgenomics/software-team wants eyes on this as well.

But looking good.

Comment thread test/client/test_cli.py Outdated
Comment on lines +17 to +25
mock_run_analysis_runner_from_args = mocker.patch(
'analysis_runner.cli.run_analysis_runner_from_args',
)
mock_run_cromwell_from_args = mocker.patch(
'analysis_runner.cli.run_cromwell_from_args',
)
mock_run_config_from_args = mocker.patch(
'analysis_runner.cli.run_config_from_args',
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd probably make this a fixture given it's used in every test, just to reduce the duplication a little bit.

Comment thread .gitignore Outdated
.idea/
.DS_Store
.vscode/
tmp_review_feedback.md

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably don't need this in the git ignore if it's a temporary artifact? I assume we'd just not commit it in the first place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah I fixed this up in the other PR (I believe), but forgot to clean this up here.

Comment thread test/client/test_cli_analysisrunner.py Outdated
lambda prompt: 'y', # noqa: ARG005
)
run_analysis_runner(**args)
assert len(posted_requests) == 4 # noqa:PLR2004 # headers, json, timeout, url

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think I'd prefer an actual key or name check here rather than length which is a more fragile test.

Comment thread test/client/conftest.py Outdated
Comment on lines +43 to +44
def _perform_version_check() -> None:
pass

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Only runs at import time here, it would be better to use the autouse=True pytest fixture. See _no_outbound_requests.

Comment thread pyproject.toml Outdated
"bump2version",
"pre-commit",
"pylint",
"ruff~=0.11",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm sure you just moved the existing requirements over which is great. But if we've upgraded to ruff 0.15 in the pre-commit, we should do the same in the dev dependencies as well.

Also, we should consider adding mypy here as well and also adding the same version in pre-commit. Just to prevent situations where local runs of ruff/mypy are different from the version the pre-commit tool uses.

@Alexander-Stuckey

Copy link
Copy Markdown
Contributor Author

@violetbrina , I believe I've addressed everything, thanks for the feedback.

Comment thread requirements-dev.txt
# via hail
aiosignal==1.4.0
# via aiohttp
analysis-runner[test] @ file:///opt/deps

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
analysis-runner[test] @ file:///opt/deps
analysis-runner[test]

This is breaking CI

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've made a side PR stacked on this branch - it un-nests the analysis-runner [dev] and [test] optional dependencies, and changes how the package is installed in CI.

It also rebuilds the requirements-dev file with uv instead of pip - it should be equivalent, but the file header is explicit about being created with UV Which we may not want

#760

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.

3 participants