Skip to content
Closed

0.9.0 #787

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions .github/workflows/test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@ name: Test installation
on:
pull_request:
branches:
- master
- master
workflow_dispatch:

jobs:

# -----------------------------------------
# Use a module from local source
# -----------------------------------------
use_as_local_module:

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: ${{ github.event_name == 'workflow_dispatch' && fromJson('["ubuntu-latest","macos-latest","windows-latest"]') || fromJson('["ubuntu-latest"]') }}
python-version: [3.9, '3.10', 3.11, 3.12, 3.13]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -47,15 +45,12 @@ jobs:
# Install with pip
# -----------------------------------------
install_with_pip:

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: ${{ github.event_name == 'workflow_dispatch' && fromJson('["ubuntu-latest","macos-latest","windows-latest"]') || fromJson('["ubuntu-latest"]') }}
python-version: [3.9, '3.10', 3.11, 3.12, 3.13]

runs-on: ${{ matrix.os }}

steps:
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v4
Expand All @@ -82,15 +77,12 @@ jobs:
# Install with poetry
# -----------------------------------------
install_with_poetry:

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: ${{ github.event_name == 'workflow_dispatch' && fromJson('["ubuntu-latest","macos-latest","windows-latest"]') || fromJson('["ubuntu-latest"]') }}
python-version: [3.9, '3.10', 3.11, 3.12, 3.13]

runs-on: ${{ matrix.os }}

steps:
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v4
Expand Down Expand Up @@ -146,15 +138,12 @@ jobs:
# Install with uv
# -----------------------------------------
install_with_uv:

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: ${{ github.event_name == 'workflow_dispatch' && fromJson('["ubuntu-latest","macos-latest","windows-latest"]') || fromJson('["ubuntu-latest"]') }}
python-version: [3.9, '3.10', 3.11, 3.12, 3.13]

runs-on: ${{ matrix.os }}

steps:
- name: Set up Python ${{ matrix.python-version }} on ${{ matrix.os }}
uses: actions/setup-python@v4
Expand Down Expand Up @@ -209,3 +198,11 @@ jobs:
run: |
cd tests
uv run python -m pytest --disable-pytest-warnings -v dataset_test.py filesindex_test.py datasetindex_test.py
- name: Run basic tests
run: |
cd tests
uv run python -m pytest --disable-pytest-warnings -v dataset_test.py filesindex_test.py datasetindex_test.py
- name: Run basic tests
run: |
cd tests
uv run python -m pytest --disable-pytest-warnings -v dataset_test.py filesindex_test.py datasetindex_test.py
Comment on lines +201 to +208
Copy link

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are duplicate 'Run basic tests' steps in the workflow. Consolidate these identical steps to streamline the CI configuration.

Suggested change
- name: Run basic tests
run: |
cd tests
uv run python -m pytest --disable-pytest-warnings -v dataset_test.py filesindex_test.py datasetindex_test.py
- name: Run basic tests
run: |
cd tests
uv run python -m pytest --disable-pytest-warnings -v dataset_test.py filesindex_test.py datasetindex_test.py

Copilot uses AI. Check for mistakes.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![PyTorch](https://img.shields.io/badge/PyTorch-2.0-orange.svg)](https://pytorch.org)
[![codecov](https://codecov.io/gh/analysiscenter/batchflow/branch/master/graph/badge.svg)](https://codecov.io/gh/analysiscenter/batchflow)
[![PyPI](https://badge.fury.io/py/batchflow.svg)](https://badge.fury.io/py/batchflow)
[![Status](https://github.com/analysiscenter/batchflow/workflows/status/badge.svg)](https://github.com/analysiscenter/batchflow/actions?query=workflow%3Astatus)
[![Status](https://github.com/analysiscenter/batchflow/actions/workflows/status.yml/badge.svg?branch=master)](https://github.com/analysiscenter/batchflow/actions?query=workflow%3Astatus)


# BatchFlow
Expand Down
2 changes: 1 addition & 1 deletion batchflow/models/torch/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def make_infrastructure(self):
self.make_loss()
self.make_optimizer()
self.make_decay()
self.scaler = torch.cuda.amp.GradScaler()
self.scaler = torch.GradScaler("cuda")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The instantiation torch.GradScaler("cuda") will cause issues in environments where CUDA is not available. To ensure compatibility with CPU-only environments, initialize the GradScaler with enabled=self.amp.

self.scaler = torch.GradScaler(enabled=self.amp)


self.setup_gradient_clipping()
self.setup_weights_averaging()
Expand Down
2 changes: 1 addition & 1 deletion batchflow/plotter/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,10 +855,10 @@ def clear(self):

self.annotations = {}

self.ax.clear()
for layer in self.layers:
for obj in layer.objects:
obj.remove()
self.ax.clear()
Comment on lines 858 to +861

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The reordering of operations in the clear method, moving self.ax.clear() to after the loop that calls obj.remove() for each layer object, improves robustness. The new order ensures that each layer object's specific remove() method is called first, before the general cleanup of the axes.

self.layers = []


Expand Down