Skip to content

Commit

Permalink
switch code quality workflow to dev target and smoketest (#2032)
Browse files Browse the repository at this point in the history
  • Loading branch information
dakinggg authored Mar 4, 2023
1 parent a35e32e commit dc5ab48
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- "3.9"
- "3.10"
pip_deps:
- "[all]"
- "[dev]"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/smoketest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Smoketest
on:
push:
branches:
- dev
- main
- release/**
pull_request:
branches:
- dev
- main
- release/**
workflow_call:
workflow_dispatch:
# Cancel old runs when a new commit is pushed to the same branch if not on main or dev
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/dev' }}
defaults:
run:
working-directory: .
jobs:
smoketest:
runs-on: ubuntu-20.04
timeout-minutes: 10
strategy:
matrix:
python_version:
- "3.8"
- "3.9"
- "3.10"
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- name: Setup
run: |
set -ex
python -m pip install --upgrade 'pip<23' wheel
python -m pip install --upgrade .
python -m pip install pytest==7.2.1 pytest_codeblocks==0.16.1
- name: Run checks
run: |
pytest tests/test_smoketest.py
19 changes: 10 additions & 9 deletions composer/models/timm/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ def composer_timm(model_name: str,
except ImportError as e:
raise MissingConditionalImportError(extra_deps_group='timm', conda_package='timm>=0.5.4',
conda_channel=None) from e
model = timm.create_model(model_name=model_name,
pretrained=pretrained,
num_classes=num_classes,
drop_rate=drop_rate,
drop_path_rate=drop_path_rate,
drop_block_rate=drop_block_rate,
global_pool=global_pool,
bn_momentum=bn_momentum,
bn_eps=bn_eps)
model = timm.create_model( # type: ignore (third-party)
model_name=model_name,
pretrained=pretrained,
num_classes=num_classes,
drop_rate=drop_rate,
drop_path_rate=drop_path_rate,
drop_block_rate=drop_block_rate,
global_pool=global_pool,
bn_momentum=bn_momentum,
bn_eps=bn_eps)

composer_model = ComposerClassifier(module=model)
return composer_model
25 changes: 25 additions & 0 deletions tests/test_smoketest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2022 MosaicML Composer authors
# SPDX-License-Identifier: Apache-2.0

from composer import (algorithms, callbacks, core, datasets, devices, functional, loggers, loss, metrics, models, optim,
profiler, trainer, utils)


# This very simple test is just to use the above imports, which check and make sure we can import all the top-level
# modules from composer. This is mainly useful for checking that we have correctly conditionally imported all optional
# dependencies.
def test_smoketest():
assert callbacks
assert algorithms
assert core
assert datasets
assert devices
assert functional
assert loggers
assert loss
assert metrics
assert models
assert optim
assert profiler
assert trainer
assert utils

0 comments on commit dc5ab48

Please sign in to comment.