Skip to content
This repository was archived by the owner on Aug 18, 2025. It is now read-only.

Commit 684fb12

Browse files
authored
Update versioning system (#252)
* Draft for new versioning scheme * Update build system * Testing file * Fix build error * Use build * Python version * Importlib in Python 3.8 * Add back requirements_test.txt * Rename * Bad torch version * Delete version file * Ignore version * No need to build * Delete test requirements * Apply isort * Fix Python version
1 parent 265c565 commit 684fb12

50 files changed

Lines changed: 211 additions & 178 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.flake8

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/build-and-test.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
max-parallel: 4
1616
matrix:
1717
platform: [ubuntu-latest]
18-
python-version: [3.7, 3.8]
18+
python-version: [3.8]
1919

2020
runs-on: ${{ matrix.platform }}
2121

@@ -28,8 +28,9 @@ jobs:
2828
- name: Install
2929
run: |
3030
python -m pip install --upgrade pip
31-
pip install --upgrade wheel
32-
pip install -e .
31+
pip install --upgrade wheel build setuptools
32+
python -m build .
33+
pip install dist/*.whl
3334
- name: Test Import
3435
run: |
3536
python -c 'import fastmri'
@@ -40,7 +41,7 @@ jobs:
4041
max-parallel: 4
4142
matrix:
4243
platform: [ubuntu-latest]
43-
python-version: [3.7, 3.8]
44+
python-version: [3.8]
4445

4546
runs-on: ${{ matrix.platform }}
4647

@@ -65,7 +66,7 @@ jobs:
6566
run: |
6667
python -m pip install --upgrade pip
6768
pip install --upgrade wheel
68-
pip install -r dev-requirements.txt
69+
pip install --editable ".[tests]"
6970
- name: Check Formatting and Lint
7071
run: |
7172
python --version
@@ -75,10 +76,8 @@ jobs:
7576
mypy fastmri
7677
flake8 --version
7778
flake8 fastmri_examples fastmri tests
78-
- name: Install fastMRI
79-
run: |
80-
python setup.py bdist_wheel
81-
pip install dist/*.whl
79+
isort --version
80+
isort --check-only fastmri tests fastmri_examples
8281
- name: Run pytest
8382
run: |
8483
echo -e "PyTorch \c" && pip show torch | grep Version

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ lightning_logs/
2020
*.pt
2121
build/
2222
dist/
23+
fastmri/_version.py

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ help(SliceDataset)
5454

5555
**Note:** Contributions to the code are continuously tested via GitHub actions.
5656
If you encounter an issue, the best first thing to do is to try to match the
57-
test environments in `requirements.txt` and `dev-requirements.txt`.
57+
`tests` environment in `setup.cfg`, e.g., `pip install --editable ".[tests]"`
58+
when installing from source.
5859

5960
**Note:** As documented in [Issue 215](https://github.com/facebookresearch/fastMRI/issues/215),
6061
there is currently a memory leak when using `h5py` installed from `pip` and

dev-requirements.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

fastmri/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
LICENSE file in the root directory of this source tree.
66
"""
77

8-
__version__ = "0.1.2a20220121"
9-
__author__ = "Facebook/NYU fastMRI Team"
10-
__author_email__ = "fastmri@fb.com"
11-
__license__ = "MIT"
12-
__homepage__ = "https://fastmri.org/"
8+
from importlib.metadata import PackageNotFoundError, version
9+
10+
try:
11+
__version__ = version("fastmri")
12+
except PackageNotFoundError:
13+
# package is not installed
14+
import warnings
15+
16+
warnings.warn("Could not retrieve fastmri version!")
1317

14-
import torch
15-
from packaging import version
1618

1719
from .coil_combine import rss, rss_complex
1820
from .fftc import fft2c_new as fft2c

fastmri/coil_combine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def rss(data: torch.Tensor, dim: int = 0) -> torch.Tensor:
2323
Returns:
2424
The RSS value.
2525
"""
26-
return torch.sqrt((data ** 2).sum(dim))
26+
return torch.sqrt((data**2).sum(dim))
2727

2828

2929
def rss_complex(data: torch.Tensor, dim: int = 0) -> torch.Tensor:

fastmri/data/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
LICENSE file in the root directory of this source tree.
66
"""
77

8-
from .mri_data import SliceDataset, CombinedSliceDataset
8+
from .mri_data import CombinedSliceDataset, SliceDataset
99
from .volume_sampler import VolumeSampler

fastmri/data/mri_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ def __init__(
276276
if dataset_cache.get(root) is None and use_dataset_cache:
277277
dataset_cache[root] = self.examples
278278
logging.info(f"Saving dataset cache to {self.dataset_cache_file}.")
279-
with open(self.dataset_cache_file, "wb") as f:
280-
pickle.dump(dataset_cache, f)
279+
with open(self.dataset_cache_file, "wb") as cache_f:
280+
pickle.dump(dataset_cache, cache_f)
281281
else:
282282
logging.info(f"Using dataset cache from {self.dataset_cache_file}.")
283283
self.examples = dataset_cache[root]

fastmri/data/transforms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77

88
from typing import Dict, NamedTuple, Optional, Sequence, Tuple, Union
99

10-
import fastmri
1110
import numpy as np
1211
import torch
1312

13+
import fastmri
14+
1415
from .subsample import MaskFunc
1516

1617

0 commit comments

Comments
 (0)