Skip to content

Commit

Permalink
Miscellaneous bug fixes and updates. (#118)
Browse files Browse the repository at this point in the history
* Reorder pre-commits to have correction executed before formatting.
Also move debug detection from pre-commit to ruff.

* Add as many `ruff` rules as seems reasonable.

* Change login shell for Dockerfiles to `zsh` even in non-interactive mode for consistency.

* Reformat files.

* Change PyTest tests according to the new recommendations.
  • Loading branch information
veritas9872 authored Apr 11, 2023
1 parent 8e89d5b commit 61b69bd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
11 changes: 4 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ repos:
- id: check-toml
- id: check-xml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
Expand All @@ -45,23 +44,21 @@ repos:
rev: v0.9.0
hooks:
- id: shellcheck
# args: ["--severity=warning"] # Optionally only show errors and warnings

- repo: https://github.com/google/pyink
rev: 23.3.1
hooks: # Using PyInk, the Google fork of Black, for Python code formatting.
- id: pyink

- repo: https://github.com/psf/black
rev: 23.3.0 # Always use the same version as PyInk.
hooks: # Using black for Jupyter Notebook formatting.
- id: black-jupyter

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
hooks:
- id: nbqa-ruff # Run `ruff` on Jupyter Notebooks.

- repo: https://github.com/psf/black
rev: 23.3.0 # Always use the same version as PyInk.
hooks: # Using black for Jupyter Notebook formatting.
- id: black-jupyter
# - repo: local # Clear Jupyter outputs before committing.
# hooks:
# - id: jupyter-nb-clear-output
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,7 @@ FROM train-base AS train-interactive-exclude

COPY --link --from=train-builds /opt/conda /opt/conda
RUN echo /opt/conda/lib >> /etc/ld.so.conf.d/conda.conf && ldconfig
RUN chsh --shell /bin/zsh

########################################################################
FROM train-interactive-${INTERACTIVE_MODE} AS train
Expand Down
1 change: 1 addition & 0 deletions dockerfiles/simple.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ FROM train-base AS train-interactive-exclude
# container registries such as Docker Hub. No users or interactive settings.
COPY --link --from=install-conda /opt/conda /opt/conda
RUN echo /opt/conda/lib >> /etc/ld.so.conf.d/conda.conf && ldconfig
RUN chsh --shell /bin/zsh

########################################################################
FROM train-base AS train-interactive-include
Expand Down
11 changes: 9 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ testpaths = [
line-length = 100
target-version = 'py38'
select = [
# "A", # flake8-builtins
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C4", # flake8-comprehensions
Expand All @@ -38,10 +39,16 @@ select = [
"E", # pycodestyle errors
"F", # pyflakes
"I", # isort
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
# "N", # PEP8-Naming
"NPY", # NumPy-specific rules
"PLE", # Error
"PLW", # Warning
"PLC", # Pylint Convention
"PLE", # Pylint Error
"PLW", # Pylint Warning
"PT", # flake8-pytest-style
"SIM", # flake8-simplify
"T10", # flake8-debugger
# "UP", # PyUpgrade
"W", # pycodestyle warnings
"YTT", # flake8-2020
Expand Down
8 changes: 4 additions & 4 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@


@pytest.fixture(scope="session", autouse=True)
def enable_cudnn_benchmarking():
def _enable_cudnn_benchmarking():
torch.backends.cudnn.benchmark = True


@pytest.fixture(scope="session", autouse=True)
def allow_tf32():
def _allow_tf32():
torch.backends.cuda.matmul.allow_tf32 = True
torch.backends.cudnn.allow_tf32 = True

Expand Down Expand Up @@ -88,7 +88,7 @@ def num_steps(pytestconfig):
return pytestconfig.getoption("num_steps")


@pytest.mark.parametrize(["name", "network_func", "input_shapes"], _configs)
@pytest.mark.parametrize(("name", "network_func", "input_shapes"), _configs)
def test_inference_run(
name: str,
network_func: Callable[[], nn.Module],
Expand Down Expand Up @@ -150,7 +150,7 @@ def _infer(network: nn.Module, inputs: Sequence[Tensor], num_steps: int) -> floa


@pytest.fixture(scope="session", autouse=True)
def get_cuda_info(device): # Using as a fixture to get device info.
def _get_cuda_info(device): # Using as a fixture to get device info.
logger.info(f"Python Version: {platform.python_version()}")
logger.info(f"PyTorch Version: {torch.__version__}")
if not torch.cuda.is_available():
Expand Down

0 comments on commit 61b69bd

Please sign in to comment.