forked from beneisner/python_pkg_template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first attempt to get the github actions to run
- Loading branch information
Showing
9 changed files
with
149 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# A github action that builds a container image for the project. | ||
|
||
name: Build Container | ||
|
||
on: | ||
push: | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
paths: | ||
# This is the entire list of files that will trigger the workflow. | ||
- Dockerfile | ||
- pyproject.toml | ||
- requirements-gpu.txt | ||
- .github/workflows/build-container.yaml | ||
- .github/workflows/compute-tag.yaml | ||
|
||
jobs: | ||
compute_tag: | ||
uses: ./.github/workflows/compute-tag.yaml | ||
|
||
docker: | ||
runs-on: ubuntu-latest | ||
needs: compute_tag | ||
steps: | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
# This is the name of the image that will be pushed to Docker Hub. If the branch is main, the image will be tagged as latest. Else, it will be tagged as the branch name. | ||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/python_ml_project_template:${{ needs.compute_tag.outputs.image_tag }} | ||
cache-from: type=registry,ref=${{ secrets.DOCKERHUB_USERNAME }}/python_ml_project_template:${{ needs.compute_tag.outputs.image_tag }} | ||
cache-to: type=inline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Compute the docker tag for this branch | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
# description: 'If true, the tag will be latest if the docker image tag does not exist' | ||
latest_on_noexist: | ||
required: false | ||
type: string | ||
default: 'false' | ||
outputs: | ||
image_tag: | ||
description: 'The tag to use for the docker image' | ||
value: ${{ jobs.compute_tag.outputs.image_tag }} | ||
|
||
|
||
jobs: | ||
compute_tag: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
image_tag: ${{ steps.set_tag.outputs.tag }} | ||
steps: | ||
- id: set_tag | ||
run: | | ||
branch_name="${{ github.head_ref }}" | ||
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | ||
echo "tag=latest" >> $GITHUB_OUTPUT | ||
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then | ||
sanitized_branch_name="${branch_name//\//-}" | ||
# If latest_on_noexist is true, set the tag to latest if the tag does not exist. | ||
if [[ "${{ inputs.latest_on_noexist }}" == "true" ]]; then | ||
# Check if the tag exists using docker manifest. | ||
if ! docker manifest inspect ${{ secrets.DOCKERHUB_USERNAME }}/python_ml_project_template:${sanitized_branch_name} > /dev/null 2>&1; then | ||
echo "tag=latest" >> $GITHUB_OUTPUT | ||
else | ||
echo "tag=${sanitized_branch_name}" >> $GITHUB_OUTPUT | ||
fi | ||
else | ||
echo "tag=${sanitized_branch_name}" >> $GITHUB_OUTPUT | ||
fi | ||
else | ||
sanitized_branch_name="${GITHUB_REF#refs/heads/}" | ||
sanitized_branch_name="${sanitized_branch_name//\//-}" | ||
echo "tag=${sanitized_branch_name}" >> $GITHUB_OUTPUT | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,27 +4,21 @@ version = "0.1.0" | |
description = "A Python Package Template" | ||
readme = "README.md" | ||
requires-python = ">=3.6" | ||
license = {file = "LICENSE.txt"} | ||
authors = [ | ||
{email = "[email protected]", name = "Ben Eisner"} | ||
] | ||
license = { file = "LICENSE.txt" } | ||
authors = [{ email = "[email protected]", name = "Ben Eisner" }] | ||
dependencies = [ | ||
"hydra-core == 1.3.2", | ||
"lightning == 2.0.3", | ||
"omegaconf == 2.3.0", | ||
"pandas", | ||
"torch == 2.0.1", # CUDA 11.8 | ||
"torch == 2.0.1", # CUDA 11.8 | ||
"torchmetrics", | ||
"torchvision == 0.15.2", # CUDA 11.8 | ||
"wandb == 0.15.4", | ||
] | ||
|
||
[build-system] | ||
requires = [ | ||
"setuptools >= 62.3.2", | ||
"setuptools-scm", | ||
"wheel", | ||
] | ||
requires = ["setuptools >= 62.3.2", "setuptools-scm", "wheel"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project.optional-dependencies] | ||
|
@@ -38,13 +32,8 @@ develop = [ | |
"pytest == 7.3.2", | ||
"pre-commit == 3.3.3", | ||
] | ||
notebooks = [ | ||
"jupyter", | ||
] | ||
build_docs = [ | ||
"mkdocs-material", | ||
"mkdocstrings[python]", | ||
] | ||
notebooks = ["jupyter"] | ||
build_docs = ["mkdocs-material", "mkdocstrings[python]"] | ||
|
||
# This is required to allow us to have notebooks/ at the top level. | ||
[tool.setuptools.packages.find] | ||
|
@@ -58,17 +47,15 @@ profile = "black" | |
known_third_party = "wandb" | ||
|
||
[tool.mypy] | ||
python_version = 3.8 | ||
python_version = "3.10" | ||
warn_return_any = true | ||
warn_unused_configs = true | ||
mypy_path = "src" | ||
namespace_packages = true | ||
explicit_package_bases = true | ||
|
||
[[tool.mypy.overrides]] | ||
module = [ | ||
"torchvision.*", | ||
] | ||
module = ["torchvision.*"] | ||
ignore_missing_imports = true | ||
|
||
[tool.pylint] | ||
|