Skip to main content

Add your description here

Project description

wadoh_raccoon

A Python package for transforming and linking pathogen sequencing/subtyping metadata.

See our github page for function references and docs https://nw-page.github.io/wadoh_raccoon/

How to install the package

Open PowerShell terminal (or Ubuntu bash terminal)

  1. Make a new folder
  2. pip install uv
  3. uv venv --python 3.11
  4. .\.venv\Scripts\activate
  5. uv pip install git+https://github.com/NW-PaGe/wadoh_raccoon.git#egg=wadoh_raccoon

To install a specific version, find the git tag noted in the GitHub Release section (something like v0.2.5) and then put it in the install statement like .git@v0.2.5:

uv pip install git+https://github.com/NW-PaGe/wadoh_raccoon.git@v0.2.5#egg=wadoh_raccoon

here's what it looks like when updating the install version:

image

How to test it

create a script called main.py in your folder and run this code:

from wadoh_raccoon.utils import helpers
import polars as pl


df = pl.DataFrame({
    'date': [
        '2022-01-03',
        '01-02-2020',
        '44115',
        None,
        "2022-12-27 08:26:49",
        # "2022-12-27T08:26:49",
        '01/02/1995',
        '2/3/2022',
        '2/16/2022'
    ]
})

df_output = (
    df
    .with_columns(
        output_date = helpers.date_format('date')
    )
    .select('output_date')
)

print(df_output)

it should give you this output

>>> print(df_output)
shape: (8, 1)
┌─────────────┐
 output_date 
 ---         
 date        
╞═════════════╡
 2022-01-03  
 2020-01-02  
 null        
 null        
 2022-12-27  
 1995-01-02  
 2022-02-03  
 2022-02-16  
└─────────────┘

For Devs

how to create a package with uv

  1. In a new repo, run uv init --package <package_name> It gives you this:
.
├── LICENSE
├── README.md
└── test_package
    ├── README.md
    ├── pyproject.toml
    └── src
        └── test_package
            └── __init__.py

3 directories, 5 files
  1. Create a venv with uv venv a. This creates a venv you can activate (called your package name) b. Creates a uv.lock file c. Uv sync to install and update your venv

  2. Run uv build and it will build your package, adding a dist/ folder with a .tar.gz file of the package. a. Amazing b. follow these docs to publish it to pypi or somewhere else privately

  3. To install from github: uv pip install git+https://github.com/NW-PaGe/wadoh_raccoon.git#egg=wadoh_raccoon If you get python version error, add python version to your .venv with uv python install 3.11 or rebuild the venv with uv venv --python 3.11

  4. for dev packages that you need but aren't package dependencies, like pytest, you can add them to the project with development dependencies like this:

uv add --dev pytest

and that will add pytest to the uv.lock and pyproject.toml but as a separate dependency from the actual packages. In other words, the package won't be dependent on pytest, but it will be installed for devs that want to run the unit tests.

how to build the package automatically with CI/CD

this repo has a github action that automatically runs unit tests, builds the package, and outputs a changelog for a github release.

The github action has two steps:

1. unit-tests

This step will install uv, install python, and then run the unit tests in the tests folder.

unit-tests:
    name: Build and Test Python Package
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v5
        with:
          version: "0.6.5" # pin a specific version is best practice
          enable-cache: true

      # install python in 
      - name: "Set up Python"
        uses: actions/setup-python@v5
        with:
          python-version-file: "pyproject.toml"

      - name: Run tests
        # For example, using `pytest`
        run: uv run pytest tests

2. build-and-release

This step is dependent on the first step above. If any unit-tests fail, then this build/release will not run.

The build step works like this:

  1. Scan the code for conventional commit messages (like fix:, feat:, etc) and render a changelog based on the commits
  2. Create a GitHub Release (git tags) that bump up the version of the codebase (like v1.0.0 to v1.1.0)
  3. Build the python package and have its version match the git tag version. uv currently doesn't have a built in way to do this, but they are currently working on it. In the meantime, that link has a way to link the python package version to the git release like this:
# install uv
- name: Set up uv
  run: curl -LsSf https://astral.sh/uv/install.sh | sh

- name: Build package
  if: ${{ steps.changelog.outputs.skipped == 'false' }}
  run: |
    VERSION=$(uvx dunamai from any --no-metadata --style pep440) # find the version of the git tag for the python package
    echo $VERSION
    uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $VERSION # update the version in the pyproject.toml
    uv build # build the package

so it will update the pyproject.toml to have the most up to date version that matches the git tag version and then build the package with uv build. The build function builds the package and outputs a dist/ folder with a .tar.gz file and a .whl file, both of which are source files for installing the package.

I also wanted to take the .tar.gz and .whl files and add them to the Assets in the changelog for GitHub. That way we can always save copies of our package whenever we make a new release, just to be safe.

# Attach the build assets to the GitHub release (only if changelog creation was successful)
- name: Upload sdist to GitHub release
  run: gh release upload $TAG $FILES --clobber
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    TAG: ${{ steps.changelog.outputs.tag }} # this is pulled from the changelog step where it creates the git tag
    FILES: dist/*.tar.gz dist/*.whl # these files are created in the build step

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wadoh_raccoon-0.4.3.tar.gz (758.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wadoh_raccoon-0.4.3-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file wadoh_raccoon-0.4.3.tar.gz.

File metadata

  • Download URL: wadoh_raccoon-0.4.3.tar.gz
  • Upload date:
  • Size: 758.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wadoh_raccoon-0.4.3.tar.gz
Algorithm Hash digest
SHA256 4b1212c0c44e61a76b210b33a0abbffa8b5a81b00dde997b109380a6e3576c5d
MD5 683c7d971f6f5b2501d0fc3a0103e3d3
BLAKE2b-256 4a6b8899eba5c2d226a39a989deb20ccf93efb16dfd1201d007e8595bc0d3645

See more details on using hashes here.

File details

Details for the file wadoh_raccoon-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: wadoh_raccoon-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for wadoh_raccoon-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4845192251a1c0fddb9ada287a6a3981ab8f563af3f78c1da671a7dcd4024810
MD5 522cc481e2c51c50cedca4d660cf6122
BLAKE2b-256 248ee91223566566759dd80f5f502280526aca799f5631b0aea4c43ace8c4546

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page