Skip to content

refactor: switch to uv for dependency management and build - #240

Merged
coatet merged 13 commits into
ONSdigital:developmentfrom
humnabaa:uv_installation
Aug 25, 2026
Merged

refactor: switch to uv for dependency management and build#240
coatet merged 13 commits into
ONSdigital:developmentfrom
humnabaa:uv_installation

Conversation

@humnabaa

@humnabaa humnabaa commented May 8, 2026

Copy link
Copy Markdown
Collaborator

Description

Please include a summary of the changes.
  • Switches the project from setuptools/pip to uv for dependency management, builds, and CI.
  • Consolidates 6 config files (setup.cfg, setup.py, .bumpversion.cfg, .ruff.toml, .isort.cfg, old pyproject.toml) into a single pyproject.toml.
  • Updates all three GitHub Actions workflows to use uv.
  • Replaces black + isort pre-commit hooks with ruff-format.
  • Updates contribution_guide.md and branch_and_deploy_guide.md.
  • This is a breaking change for the developer workflow (uv replaces pip) but does NOT break any end-user functionality.
  • Tested locally: all non-Spark tests pass, ruff reports no issues.

Closes #238

Type of change

  • Breaking change - backwards incompatible change, changes expected behaviour
  • Non-user facing change, structural change, dev functionality, docs ...

Checklist:

  • I have performed a self-review of my own code.
  • I have commented my code appropriately, focusing on explaining my design decisions (explain why, not how).
  • I have made corresponding changes to the documentation (comments, docstring, etc.. )
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have updated the change log.

@nclarkz nclarkz 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.

Couple of updates due to failing github checks

Comment thread pyproject.toml Outdated
Comment thread .github/workflows/pull_request_workflow.yaml Outdated
@nclarkz

nclarkz commented May 12, 2026

Copy link
Copy Markdown
Collaborator

Code review

Documentation

Any new code includes all the following forms of documentation:

  • Function Documentation as docstrings within the function definition.
  • Examples demonstrating major functionality, which runs successfully locally.
  • Changelog Ticket added to changelog in correct place.

Functionality

  • Pipeline success: Pipeline can be successfully run for all expected instances of the pipeline.
  • Functionality: Any functional claims of new code have been confirmed.
  • Parameters: Parameters adhere to a parsimonious principle, without redundancy or unnecessary dynamism.
  • Automated tests: Unit tests cover essential functions for a reasonable range
    of inputs and edge case conditions. All tests pass on your local machine.
  • Packaging guidelines: New code conforms to the project contribution
    guidelines.

Final approval (post-review)

The author has responded to my review and made changes to my satisfaction.

  • I recommend merging this request.

Review comments

Currently not passing github actions checks, that needs to be rectified prior to merging. Work is forked rather than branched, so need to clone the separate repo to test it works my end once it is passing the checks, would be worth branching rather than forking in the future for ease of peer review.

Will need to update some of the documentation to reflect differing instructions for uv:

  • docs/branch_and_deploy_guide.md needs to change bump2version to uv version instructions
  • docs/contribution_guide.md update virtual environment section, setup dev environment change to pip install uv, uv init, installation of pre-commit needs to be checked whether the uv install captures it all
  • Don't think the readme needs updating as the installation instructions are for the package, so it's ran at the user's end?
  • Does a uv.lock file need to be added?

Comment thread rdsa_utils/helpers/pyspark_log_parser/parser.py
Comment thread .github/workflows/pull_request_workflow.yaml Outdated
Comment thread .github/workflows/deploy_pypi.yaml Outdated
Comment thread .github/workflows/deploy_pypi.yaml Outdated
Comment thread .github/workflows/pull_request_workflow.yaml Outdated
Comment thread rdsa_utils/test_utils.py
Comment thread .pre-commit-config.yaml
@coatet

coatet commented May 20, 2026

Copy link
Copy Markdown
Collaborator

Something that's occurred to me because I've been looking at pandas versions for something else: your uv.lock has pegged a fairly old version of pandas, and I'm concerned that this change will force anyone who installs rdsa-utils to use pandas 2.0. Version 3.0 is available and has some useful updates, so we need to test what uv does when you list rdsa-utils as a dependency. The pyproject file doesn't specify a pandas version, so I'd like to know whether uv forces you onto 2.0 or lets the pandas version vary up to 3.0+.

For reference, the big difference in pandas 3.0 is that it uses a string dtype instead of Object for non-numerical columns by default (which was causing validation issues on my current pipeline) and you can use pd.col() to create new columns in a more Pyspark-like way rather than using lambda functions. I think these are important changes so I don't want to force anyone to use pandas 2.0 just to use rdsa-utils.

- Add PD901 to ruff ignore list (fixes failing precommit checks)
- Switched PR workflow to use uv sync/uv run pytest
- Switched deploy workflow to use uv publish
- Reverted ruff-suggested code changes in parser.py and test_utils.py
- Restored isort in pre-commit-config.yaml
- Update docs: branch_and_deploy_guide.md and contribution_guide.md for uv
@humnabaa

humnabaa commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

@nclarkz Updated branch_and_deploy_guide.md (bump2version is updated to manual version update in init.py] and contribution_guide.md (done a full rewrite of setup section to use uv sync --group dev, uv run pytest, uv run pre-commit install)

@humnabaa

humnabaa commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator Author

@coatet checked the uv.lock and it resolves correctly per Python version: pandas 2.0.3 only for Python <3.9, pandas 2.3.3 for 3.9–3.10, and pandas 3.0.2 for Python ≥3.11. Since the pyproject.toml has no version pin on pandas, uv.lock won't constrain downstream users. they willl resolve their own pandas version when they pip install rdsa-utils. The lock file only applies to development.

@coatet coatet 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.

@humnabaa Looks all good now! The CI/CD is failing for two reasons which should be quick to fix:

  • The ruff-format pre-commit check is failing on helpers/pyspark_log_parser/parser.py because of some odd reformatting. I've pointed it out below and think it should just be reverted.
  • All the builds are failing because Github Actions can't access our Artifactory, since that's where the uv.lock says to find the packages. This is correct for users but won't work for CI/CD. The solution I've used for this is to tell Github Actions to re-solve the dependencies using PyPi just before the sync. Adding uv lock --default-index https://pypi.org/simple just before the uv sync step should fix it.

Comment thread rdsa_utils/helpers/pyspark_log_parser/parser.py Outdated
Comment thread rdsa_utils/test_utils.py Outdated

@coatet coatet 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.

All looking good now!

@coatet
coatet merged commit 8819137 into ONSdigital:development Aug 25, 2026
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.

3 participants