Skip to content

Commit

Permalink
Merge pull request #71 from KevinMusgrave/github-workflows
Browse files Browse the repository at this point in the history
Added .github/workflows
  • Loading branch information
KevinMusgrave authored May 30, 2022
2 parents 7fe4441 + 1e80cf3 commit 97afa6d
Show file tree
Hide file tree
Showing 52 changed files with 387 additions and 46 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/base_test_workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: base_test_workflow

on:
workflow_call:
inputs:
module-to-test:
required: true
type: string

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install .[ignite,lightning,record-keeper,timm]
pip install --upgrade protobuf==3.20.1
- name: Run unit tests
run: |
TEST_DTYPES=float32,float64 TEST_DEVICE=cpu python -m unittest discover -t . -s tests/${{ inputs.module-to-test }}
28 changes: 28 additions & 0 deletions .github/workflows/run_linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: run_linter

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
pip install flake8
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --per-file-ignores="__init__.py:F401"
15 changes: 15 additions & 0 deletions .github/workflows/test_adapters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: adapters

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
call-base-test-workflow:
uses: ./.github/workflows/base_test_workflow.yml
with:
module-to-test: adapters
15 changes: 15 additions & 0 deletions .github/workflows/test_containers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: containers

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
call-base-test-workflow:
uses: ./.github/workflows/base_test_workflow.yml
with:
module-to-test: containers
15 changes: 15 additions & 0 deletions .github/workflows/test_datasets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: datasets

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
call-base-test-workflow:
uses: ./.github/workflows/base_test_workflow.yml
with:
module-to-test: datasets
15 changes: 15 additions & 0 deletions .github/workflows/test_frameworks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: frameworks

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
call-base-test-workflow:
uses: ./.github/workflows/base_test_workflow.yml
with:
module-to-test: frameworks
15 changes: 15 additions & 0 deletions .github/workflows/test_hooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: hooks

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
call-base-test-workflow:
uses: ./.github/workflows/base_test_workflow.yml
with:
module-to-test: hooks
15 changes: 15 additions & 0 deletions .github/workflows/test_inference.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: inference

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
call-base-test-workflow:
uses: ./.github/workflows/base_test_workflow.yml
with:
module-to-test: inference
15 changes: 15 additions & 0 deletions .github/workflows/test_layers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: layers

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
call-base-test-workflow:
uses: ./.github/workflows/base_test_workflow.yml
with:
module-to-test: layers
15 changes: 15 additions & 0 deletions .github/workflows/test_meta_validators.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: meta_validators

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
call-base-test-workflow:
uses: ./.github/workflows/base_test_workflow.yml
with:
module-to-test: meta_validators
15 changes: 15 additions & 0 deletions .github/workflows/test_models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: models

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
call-base-test-workflow:
uses: ./.github/workflows/base_test_workflow.yml
with:
module-to-test: models
15 changes: 15 additions & 0 deletions .github/workflows/test_utils.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: utils

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
call-base-test-workflow:
uses: ./.github/workflows/base_test_workflow.yml
with:
module-to-test: utils
15 changes: 15 additions & 0 deletions .github/workflows/test_validators.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: validators

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
call-base-test-workflow:
uses: ./.github/workflows/base_test_workflow.yml
with:
module-to-test: validators
15 changes: 15 additions & 0 deletions .github/workflows/test_weighters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: weighters

on:
pull_request:
branches: [ main, dev ]
paths:
- 'src/**'
- 'tests/**'
- '.github/workflows/**'

jobs:
call-base-test-workflow:
uses: ./.github/workflows/base_test_workflow.yml
with:
module-to-test: weighters
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
extras_require_ignite = ["pytorch-ignite == 0.5.0.dev20220221"]
extras_require_lightning = ["pytorch-lightning"]
extras_require_record_keeper = ["record-keeper >= 0.9.31"]
extras_require_timm = ["timm"]


setuptools.setup(
Expand Down Expand Up @@ -41,5 +42,6 @@
"ignite": extras_require_ignite,
"lightning": extras_require_lightning,
"record-keeper": extras_require_record_keeper,
"timm": extras_require_timm,
},
)
2 changes: 1 addition & 1 deletion src/pytorch_adapt/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.73"
__version__ = "0.0.74"
54 changes: 39 additions & 15 deletions src/pytorch_adapt/models/pretrained.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .utils import download_weights


def mnistG(pretrained=False, progress=True):
def mnistG(pretrained=False, progress=True, **kwargs):
"""
Returns:
An [```MNISTFeatures```][pytorch_adapt.models.MNISTFeatures] model
Expand All @@ -12,11 +12,15 @@ def mnistG(pretrained=False, progress=True):
model = MNISTFeatures()
url = "https://cornell.box.com/shared/static/tdx0ts24e273j7mf3r2ox7a12xh4fdfy"
h = "68ee79452f1d5301be2329dfa542ac6fa18de99e09d6540838606d9d700b09c8"
filename = f"mnistG-{h[:8]}.pth"
return download_weights(model, url, pretrained, progress, filename)
file_name = f"mnistG-{h[:8]}.pth"
return download_weights(
model, url, pretrained, progress=progress, file_name=file_name, **kwargs
)


def mnistC(num_classes=10, in_size=1200, h=256, pretrained=False, progress=True):
def mnistC(
num_classes=10, in_size=1200, h=256, pretrained=False, progress=True, **kwargs
):
"""
Returns:
A [```Classifier```][pytorch_adapt.models.Classifier] model
Expand All @@ -25,11 +29,13 @@ def mnistC(num_classes=10, in_size=1200, h=256, pretrained=False, progress=True)
model = Classifier(num_classes=num_classes, in_size=in_size, h=h)
url = "https://cornell.box.com/shared/static/j4zrogronmievq1csulrkai7zjm27gcq"
h = "ac7b5a13df2ef3522b6550a147eb44dde8ff4fead3ddedc540d9fe63c9d597c1"
filename = f"mnistC-{h[:8]}.pth"
return download_weights(model, url, pretrained, progress, filename)
file_name = f"mnistC-{h[:8]}.pth"
return download_weights(
model, url, pretrained, progress=progress, file_name=file_name, **kwargs
)


def resnet50(pretrained=False, progress=True):
def resnet50(pretrained=False, progress=True, **kwargs):
import timm

model = timm.create_model("resnet50", pretrained=False, num_classes=0)
Expand All @@ -38,8 +44,10 @@ def resnet50(pretrained=False, progress=True):
# So the model for all 3 domains is the same
url = "https://cornell.box.com/shared/static/1oxb5xk5dq3od1d3gprigznxmqb3wgr1"
h = "a567ecd6ea5addf29ccfa8bf706be78a35adff7cd5cf5a3a99d89b19807454ae"
filename = f"resnet50MusgraveUDA-{h[:8]}.pth"
return download_weights(model, url, pretrained, progress, filename)
file_name = f"resnet50MusgraveUDA-{h[:8]}.pth"
return download_weights(
model, url, pretrained, progress=progress, file_name=file_name, **kwargs
)


def office31G(*args, **kwargs):
Expand All @@ -51,7 +59,13 @@ def office31G(*args, **kwargs):


def office31C(
domain=None, num_classes=31, in_size=2048, h=256, pretrained=False, progress=True
domain=None,
num_classes=31,
in_size=2048,
h=256,
pretrained=False,
progress=True,
**kwargs,
):
"""
Returns:
Expand Down Expand Up @@ -79,8 +93,10 @@ def office31C(
"dslr": "fc0acd7a71eb5f12d4af619e5c63bcc42e5a23441bbd105fe0f7a37c26f37d80",
"webcam": "b2bb55978380fa9ca6452cba30e0ac2a19b7166d8348bcc1554fdabd185e4cdd",
}[domain]
filename = f"office31C{domain}-{h[:8]}.pth"
return download_weights(model, url, pretrained, progress, filename)
file_name = f"office31C{domain}-{h[:8]}.pth"
return download_weights(
model, url, pretrained, progress=progress, file_name=file_name, **kwargs
)


def officehomeG(*args, **kwargs):
Expand All @@ -92,7 +108,13 @@ def officehomeG(*args, **kwargs):


def officehomeC(
domain=None, num_classes=65, in_size=2048, h=256, pretrained=False, progress=True
domain=None,
num_classes=65,
in_size=2048,
h=256,
pretrained=False,
progress=True,
**kwargs,
):
"""
Returns:
Expand Down Expand Up @@ -122,5 +144,7 @@ def officehomeC(
"product": "472ff36fdf13ec6c1fa1236d1d0800e2a5cf2e3d366b6b63ff5807dff6a761d8",
"real": "f0c8d6e941d4f488ff2438eb5cccdc59e78f35961e48f03d2186752e5878c697",
}[domain]
filename = f"officehomeC{domain}-{h[:8]}.pth"
return download_weights(model, url, pretrained, progress, filename)
file_name = f"officehomeC{domain}-{h[:8]}.pth"
return download_weights(
model, url, pretrained, progress=progress, file_name=file_name, **kwargs
)
Loading

0 comments on commit 97afa6d

Please sign in to comment.