Skip to content

Commit 2d5d675

Browse files
authored
Merge pull request #40 from VisLab/indexing_management
Refactoring the actions
2 parents 6960532 + 1881bf5 commit 2d5d675

61 files changed

Lines changed: 324 additions & 246 deletions

Some content is hidden

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

.github/workflows/black.yaml

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

.github/workflows/codespell.yaml

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,12 @@ jobs:
1818
steps:
1919
- name: Checkout
2020
uses: actions/checkout@v6
21-
22-
- name: Set up Python
23-
uses: actions/setup-python@v6
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v7
2424
with:
25-
python-version: '3.10'
26-
27-
- name: Install dependencies
28-
run: |
29-
python -m pip install --upgrade pip
30-
pip install codespell tomli
31-
25+
enable-cache: true
26+
cache-dependency-glob: "**/pyproject.toml"
27+
3228
- name: Run Codespell
33-
run: codespell .
29+
run: uvx --with tomli codespell .

.github/workflows/docs.yml

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,41 @@ jobs:
1919
build:
2020
runs-on: ubuntu-latest
2121
steps:
22-
- uses: actions/checkout@v6
23-
with:
24-
fetch-depth: 0
22+
- uses: actions/checkout@v6
23+
with:
24+
fetch-depth: 0
2525

26-
- name: Set up Python
27-
uses: actions/setup-python@v6
28-
with:
29-
python-version: '3.10'
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v7
28+
with:
29+
python-version: '3.10'
30+
enable-cache: true
31+
cache-dependency-glob: "**/pyproject.toml"
3032

31-
- name: Cache dependencies
32-
uses: actions/cache@v5
33-
with:
34-
path: ~/.cache/pip
35-
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
36-
restore-keys: |
37-
${{ runner.os }}-pip-
33+
- name: Create virtual environment
34+
run: |
35+
uv venv --clear .venv
36+
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
3837
39-
- name: Install dependencies
40-
run: |
41-
python -m pip install --upgrade pip
42-
pip install -e .[docs]
38+
- name: Install dependencies
39+
run: uv pip install -e ".[docs]"
4340

44-
- name: Configure Git for GitHub Pages
45-
run: |
46-
git config user.name github-actions
47-
git config user.email [email protected]
41+
- name: Configure Git for GitHub Pages
42+
run: |
43+
git config user.name github-actions
44+
git config user.email [email protected]
4845
49-
- name: Build documentation
50-
run: |
51-
cd docs
52-
sphinx-build -b html . _build/html
46+
- name: Build documentation
47+
run: |
48+
sphinx-build -b html docs docs/_build/html
5349
54-
- name: Setup Pages
55-
uses: actions/configure-pages@v5
50+
- name: Setup Pages
51+
uses: actions/configure-pages@v5
5652

57-
- name: Upload artifact
58-
uses: actions/upload-pages-artifact@v4
59-
with:
60-
path: ./docs/_build/html
53+
- name: Upload artifact
54+
uses: actions/upload-pages-artifact@v4
55+
with:
56+
path: ./docs/_build/html
6157

6258
#------------------------------------------------
6359
# Deploy Job: Deploys the built site

.github/workflows/links.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,24 @@ jobs:
1919
- name: Checkout
2020
uses: actions/checkout@v6
2121

22-
- name: Setup Python
23-
uses: actions/setup-python@v6
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v7
2424
with:
2525
python-version: '3.12'
26-
cache: 'pip'
26+
enable-cache: true
27+
cache-dependency-glob: "**/pyproject.toml"
2728

28-
- name: Install dependencies
29+
- name: Create virtual environment
2930
run: |
30-
pip install --upgrade pip
31-
pip install -e .[docs]
31+
uv venv --clear .venv
32+
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
33+
34+
- name: Install dependencies
35+
run: uv pip install -e ".[docs]"
3236

3337
- name: Build documentation with Sphinx
3438
run: |
35-
cd docs
36-
sphinx-build -b html . _build/html
39+
sphinx-build -b html docs docs/_build/html
3740
3841
- name: Link Checker on built documentation
3942
id: lychee

.github/workflows/mdformat.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,13 @@ jobs:
1818
steps:
1919
- name: Checkout
2020
uses: actions/checkout@v6
21-
22-
- name: Set up Python
23-
uses: actions/setup-python@v6
21+
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v7
2424
with:
2525
python-version: '3.12'
26-
27-
- name: Install dependencies
28-
run: |
29-
python -m pip install --upgrade pip
30-
pip install mdformat==0.7.22 mdformat-myst==0.2.2 mdformat-tables==1.0.0
31-
26+
enable-cache: true
27+
cache-dependency-glob: "**/pyproject.toml"
28+
3229
- name: Run mdformat (check only)
33-
run: |
34-
mdformat --check --wrap no --number docs/
35-
mdformat --check --wrap no --number README.md CHANGELOG.md
30+
run: uvx --with mdformat-myst mdformat --check --wrap no --number docs/ *.md

.github/workflows/ruff.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Ruff
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
ruff:
14+
name: Check for style errors and common problems
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v6
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v7
22+
with:
23+
python-version: "3.12"
24+
enable-cache: true
25+
cache-dependency-glob: "**/pyproject.toml"
26+
27+
- name: Run Ruff linter and formatter check
28+
run: uvx ruff check . && uvx ruff format --check .

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ coverage.xml
8585
*.py,cover
8686
.hypothesis/
8787
.pytest_cache/
88+
.ruff_cache/
8889
cover/
8990

9091

@@ -136,5 +137,11 @@ spec_tests/hed-specification/tests
136137
spec_tests/hed-examples
137138
spec_tests/*.json
138139

140+
# Extracted test fixture directories (re-created from zip files during tests)
141+
tests/data/test_root/
142+
tests/data/test_root_back1/
143+
tests/data/test_root_bad/
144+
tests/data/eeg_ds003645s_hed_remodel/
145+
139146
# GitHub Copilot instructions (project-specific)
140147
.github/copilot-instructions.md

pyproject.toml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ dependencies = [
5454
dev = [
5555
"ruff>=0.8.0",
5656
"codespell>=2.2.0",
57-
"black[jupyter]>=26.1.0",
5857
"mdformat>=0.7.0",
5958
"mdformat-myst>=0.1.5",
6059
]
@@ -95,7 +94,7 @@ ignore-words-list = 'te,parms,assertIn'
9594
[tool.ruff]
9695
# Target Python 3.10+
9796
target-version = "py310"
98-
line-length = 127
97+
line-length = 120
9998

10099
# Exclude common directories
101100
exclude = [
@@ -105,6 +104,7 @@ exclude = [
105104
"__pycache__",
106105
"build",
107106
"dist",
107+
".eggs",
108108
"*.egg-info",
109109
".status",
110110
]
@@ -152,19 +152,9 @@ max-complexity = 10
152152
[tool.ruff.lint.isort]
153153
known-first-party = ["remodeler"]
154154

155-
[tool.black]
156-
line-length = 127
157-
target-version = ["py310", "py311", "py312", "py313"]
158-
exclude = '''
159-
/(
160-
\.git
161-
| \.venv
162-
| venv
163-
| __pycache__
164-
| build
165-
| dist
166-
| \.eggs
167-
| .*\.egg-info
168-
| \.status
169-
)/
170-
'''
155+
[tool.ruff.format]
156+
# Match Black defaults
157+
quote-style = "double"
158+
indent-style = "space"
159+
skip-magic-trailing-comma = false
160+
line-ending = "auto"

remodeler/backup_manager.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ def get_backup_path(self, backup_name, file_name) -> str:
137137
str: Full path of the corresponding file in the backup.
138138
139139
"""
140-
return os.path.realpath(os.path.join(self.backups_path, backup_name, self.BACKUP_ROOT, self.get_file_key(file_name)))
140+
return os.path.realpath(
141+
os.path.join(self.backups_path, backup_name, self.BACKUP_ROOT, self.get_file_key(file_name))
142+
)
141143

142144
def get_file_key(self, file_name):
143145
file_comp = io_util.get_path_components(self.data_root, file_name) + [os.path.basename(file_name)]
@@ -183,7 +185,9 @@ def _get_backups(self):
183185
raise HedFileError("BadBackupPath", f"{backup_root} is not a backup directory.", "")
184186
if len(os.listdir(backup_root)) != 2:
185187
raise HedFileError(
186-
"BadBackupFormat", f"Backup {backup_root} must only contain backup_root and backup_lock.json file.", ""
188+
"BadBackupFormat",
189+
f"Backup {backup_root} must only contain backup_root and backup_lock.json file.",
190+
"",
187191
)
188192
backup_dict, files_not_in_backup, backups_not_in_directory = self._check_backup_consistency(backup)
189193
if files_not_in_backup:
@@ -216,19 +220,21 @@ def _check_backup_consistency(self, backup_name):
216220
if not os.path.exists(backup_dict_path):
217221
raise HedFileError(
218222
"BadBackupDictionaryPath",
219-
f"Backup dictionary path {backup_dict_path} for backup " f"{backup_name} does not exist so backup invalid",
223+
f"Backup dictionary path {backup_dict_path} for backup {backup_name} does not exist so backup invalid",
220224
"",
221225
)
222226
backup_root_path = os.path.realpath(os.path.join(self.backups_path, backup_name, self.BACKUP_ROOT))
223227
if not os.path.isdir(backup_root_path):
224228
raise HedFileError(
225229
"BadBackupRootPath",
226-
f"Backup root path {backup_root_path} for {backup_name} " f"does not exist so backup invalid",
230+
f"Backup root path {backup_root_path} for {backup_name} does not exist so backup invalid",
227231
"",
228232
)
229233
with open(backup_dict_path, "r") as fp:
230234
backup_dict = json.load(fp)
231-
backup_paths = {os.path.realpath(os.path.join(backup_root_path, backup_key)) for backup_key in backup_dict.keys()}
235+
backup_paths = {
236+
os.path.realpath(os.path.join(backup_root_path, backup_key)) for backup_key in backup_dict.keys()
237+
}
232238
file_paths = set(io_util.get_file_list(backup_root_path))
233239
files_not_in_backup = list(file_paths.difference(backup_paths))
234240
backups_not_in_directory = list(backup_paths.difference(file_paths))

0 commit comments

Comments
 (0)