Skip to content

Commit 548c16f

Browse files
authored
Merge pull request #61 from atomscale-ai/enhancement/update_cicd_tooling
Modernize CICD tooling with astral packages
2 parents 2a0d9f6 + 7b65e60 commit 548c16f

File tree

9 files changed

+73
-79
lines changed

9 files changed

+73
-79
lines changed

.github/workflows/release.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,21 @@ jobs:
139139
steps:
140140
- uses: actions/checkout@v4
141141

142-
- uses: actions/setup-python@v5
142+
- name: Set up uv
143+
uses: astral-sh/setup-uv@v5
144+
with:
145+
version: "latest"
146+
147+
- name: Set up Python
148+
uses: actions/setup-python@v5
143149
with:
144150
python-version: "3.11"
145151

146152
- name: Install dependencies
147153
run: |
148-
python -m pip install --upgrade pip
149-
pip install -r requirements/requirements-ubuntu-latest_py3.11.txt
150-
pip install -r requirements/requirements-ubuntu-latest_py3.11_extras.txt
151-
pip install sphinx
152-
pip install -e .
154+
uv pip install --system -r requirements/requirements-ubuntu-latest_py3.11.txt
155+
uv pip install --system -r requirements/requirements-ubuntu-latest_py3.11_extras.txt
156+
uv pip install --system -e .
153157
154158
- name: Build docs
155159
run: sphinx-build ./docs ./docs/_build

.github/workflows/testing.yml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,24 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919

20+
- name: Set up uv
21+
uses: astral-sh/setup-uv@v5
22+
with:
23+
version: "latest"
24+
2025
- name: Set up Python
2126
uses: actions/setup-python@v5
2227
with:
2328
python-version: "3.11"
2429

25-
- name: Install Python dependencies
26-
run: |
27-
python -m pip install --upgrade pip
28-
pip install -r requirements/requirements-ubuntu-latest_py3.11.txt
29-
pip install -r requirements/requirements-ubuntu-latest_py3.11_extras.txt
30-
3130
- name: Install dependencies
3231
run: |
33-
pip install pre-commit
32+
uv pip install --system -r requirements/requirements-ubuntu-latest_py3.11.txt
33+
uv pip install --system -r requirements/requirements-ubuntu-latest_py3.11_extras.txt
34+
uv pip install --system pre-commit ty
3435
3536
- name: Run pre-commit
36-
run: |
37-
pre-commit run --all-files --show-diff-on-failure
38-
39-
- name: Run mypy
40-
run: |
41-
mypy --version
42-
rm -rf .mypy_cache
43-
mypy src/atomicds
37+
run: pre-commit run --all-files --show-diff-on-failure
4438

4539
test:
4640
needs: lint
@@ -55,16 +49,20 @@ jobs:
5549
steps:
5650
- uses: actions/checkout@v4
5751

52+
- name: Set up uv
53+
uses: astral-sh/setup-uv@v5
54+
with:
55+
version: "latest"
56+
5857
- name: Set up Python ${{ matrix.python-version }}
5958
uses: actions/setup-python@v5
6059
with:
6160
python-version: ${{ matrix.python-version }}
6261

63-
- name: Install Python dependencies
62+
- name: Install dependencies
6463
run: |
65-
python -m pip install --upgrade pip
66-
pip install -r requirements/requirements-${{ matrix.os }}_py${{ matrix.python-version }}.txt
67-
pip install -r requirements/requirements-${{ matrix.os }}_py${{ matrix.python-version }}_extras.txt
64+
uv pip install --system -r requirements/requirements-${{ matrix.os }}_py${{ matrix.python-version }}.txt
65+
uv pip install --system -r requirements/requirements-${{ matrix.os }}_py${{ matrix.python-version }}_extras.txt
6866
6967
- name: Set SSL_CERT_FILE (Linux/MacOS)
7068
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
@@ -74,13 +72,14 @@ jobs:
7472
if: matrix.os == 'windows-latest'
7573
run: echo "SSL_CERT_FILE=$(python -m certifi)" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
7674

75+
- name: Install package
76+
run: uv pip install --system -e .
77+
7778
- name: Test with pytest
7879
env:
7980
AS_API_KEY: ${{ secrets.AS_API_KEY }}
8081
AS_API_ENDPOINT: "https://api.atomscale.ai"
81-
run: |
82-
pip install -e .
83-
pytest -x
82+
run: pytest -x
8483

8584
auto-gen-release:
8685
needs: test

.pre-commit-config.yaml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,8 @@ ci:
55
autoupdate_commit_msg: "chore: update pre-commit hooks"
66

77
repos:
8-
- repo: https://github.com/psf/black
9-
rev: 23.9.1
10-
hooks:
11-
- id: black
12-
13-
- repo: https://github.com/asottile/blacken-docs
14-
rev: "1.16.0"
15-
hooks:
16-
- id: blacken-docs
17-
additional_dependencies: [black>=23.7.0]
18-
198
- repo: https://github.com/pre-commit/pre-commit-hooks
20-
rev: v4.5.0
9+
rev: v5.0.0
2110
hooks:
2211
- id: check-case-conflict
2312
- id: check-symlinks
@@ -28,15 +17,27 @@ repos:
2817
- id: trailing-whitespace
2918

3019
- repo: https://github.com/astral-sh/ruff-pre-commit
31-
rev: v0.3.4
20+
rev: v0.9.4
3221
hooks:
3322
- id: ruff
3423
args: [--fix, --show-fixes]
24+
exclude: '\.ipynb$'
25+
- id: ruff-format
26+
exclude: '\.ipynb$'
3527

3628
- repo: https://github.com/codespell-project/codespell
37-
rev: v2.2.6
29+
rev: v2.4.1
3830
hooks:
3931
- id: codespell
4032
stages: [pre-commit, commit-msg]
4133
exclude_types: [json, bib, svg]
4234
args: [--ignore-words-list, "mater,fwe,te"]
35+
36+
- repo: local
37+
hooks:
38+
- id: ty
39+
name: ty
40+
entry: ty check src/atomicds
41+
language: system
42+
types: [python]
43+
pass_filenames: false

pyproject.toml

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@ dev = [
4949
"pytest-order",
5050
"pytest-dependency",
5151
"pytest-asyncio",
52-
"ruff",
53-
"mypy",
52+
"ruff>=0.9.0",
53+
"ty",
5454
"types-requests",
5555
"pandas-stubs",
56+
"pre-commit>=4.0.0",
5657
]
5758
docs = ["sphinx>=6.2", "sphinx-autodoc-typehints>=1.24", "alabaster>=0.7"]
5859

@@ -73,29 +74,13 @@ path = "src/atomscale/streaming/Cargo.toml"
7374
binding = "PyO3"
7475

7576

76-
[tool.pyright]
77-
include = ["atomscale", "atomicds"]
78-
exclude = ["**/__pycache__"]
79-
8077
[tool.pytest.ini_options]
8178
minversion = "6.0"
8279
addopts = ["-p no:warnings", "--import-mode=importlib"]
8380
xfail_strict = true
8481
log_cli_level = "warn"
8582
testpaths = ["tests"]
8683

87-
[tool.black]
88-
exclude = '''
89-
/(
90-
\.git
91-
| \.tox
92-
)/
93-
'''
94-
95-
[tool.isort]
96-
profile = 'black'
97-
skip_gitignore = true
98-
9984
[tool.coverage.run]
10085
source = ["src"]
10186

@@ -137,7 +122,6 @@ lint.select = [
137122
lint.extend-ignore = [
138123
"PLR", # Design related pylint codes
139124
"E501", # Line too long
140-
"PT004", # Use underscore for non-returning fixture (use usefixture instead)
141125
"B028", # No explicit stacklevel
142126
"EM101", # Exception must not use a string literal
143127
"EM102", # Exception must not use an f-string literal
@@ -151,20 +135,19 @@ lint.unfixable = [
151135
]
152136
exclude = []
153137
lint.flake8-unused-arguments.ignore-variadic-names = true
154-
extend-exclude = ["tests"]
138+
extend-exclude = ["tests", "examples", "*.ipynb"]
155139
lint.pydocstyle.convention = "google"
156140
lint.isort.known-first-party = ["atomscale"]
157141

158142
[tool.docformatter]
159143
pre-summary-newline = true
160-
black = true
161-
162-
[tool.mypy]
163-
ignore_missing_imports = true
164-
namespace_packages = true
165-
explicit_package_bases = true
166-
no_implicit_optional = false
167-
disable_error_code = "annotation-unchecked"
144+
145+
[tool.ty.environment]
146+
root = ["./src"]
147+
148+
[tool.ty.src]
149+
include = ["src/atomicds"]
150+
exclude = ["tests", "examples", "docs"]
168151

169152
[tool.codespell]
170153
ignore-words-list = "fpr"

src/atomscale/core/client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ def _create_session(api_key: str):
245245
atomscale_info = "atomscale/" + __version__
246246
python_info = f"Python/{sys.version.split()[0]}"
247247
platform_info = f"{platform.system()}/{platform.release()}"
248-
session.headers[
249-
"user-agent"
250-
] = f"{atomscale_info} ({python_info} {platform_info})"
248+
session.headers["user-agent"] = (
249+
f"{atomscale_info} ({python_info} {platform_info})"
250+
)
251251

252252
# TODO: Add retry setting to configuration somewhere
253253
max_retry_num = 3

src/atomscale/results/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"RHEEDImageResult",
1919
"RHEEDVideoResult",
2020
"RamanResult",
21-
"XPSResult",
2221
"UnknownResult",
22+
"XPSResult",
2323
"_get_rheed_image_result",
2424
]

src/atomscale/results/rheed_image.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,7 @@ def merge_overlaps(node_df):
371371
x,
372372
new_df["mask_height"].iloc[0], # type: ignore # noqa: PGH003
373373
new_df["mask_width"].iloc[0], # type: ignore # noqa: PGH003
374-
)[
375-
"counts"
376-
]
374+
)["counts"]
377375

378376
new_df = new_df.groupby("node_id").agg(agg_dict).reset_index(drop=True)
379377

src/atomscale/timeseries/rheed.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@ class RHEEDProvider(TimeseriesProvider[RHEEDVideoResult]):
4141
"first_order_fwhm_1": "First Order FWHM",
4242
"lattice_spacing": "Lattice Spacing",
4343
"tar_metric": "TAR Metric",
44+
"composition_metric": "Composition Metric",
4445
}
45-
DROP_IF_ALL_NA: Sequence[str] = ["reconstruction_intensity", "tar_metric"]
46+
DROP_IF_ALL_NA: Sequence[str] = [
47+
"reconstruction_intensity",
48+
"tar_metric",
49+
"composition_metric",
50+
]
4651
INDEX_COLS: Sequence[str] = ["Angle", "Frame Number"]
4752

4853
def fetch_raw(self, client: BaseClient, data_id: str, **kwargs) -> Any:

tests/test_rheed_video.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def result(client: Client):
2222

2323

2424
def test_get_dataframe(result: RHEEDVideoResult):
25+
# Core columns that should always be present
2526
column_names = set(
2627
[
2728
"Strain",
@@ -38,9 +39,12 @@ def test_get_dataframe(result: RHEEDVideoResult):
3839
"Half Order Intensity R",
3940
"Specular FWHM",
4041
"First Order FWHM",
41-
"Time",
4242
"UNIX Timestamp",
4343
"Relative Time",
44+
# Optional columns (included if data exists)
45+
"Time",
46+
"TAR Metric",
47+
"Composition Metric",
4448
]
4549
)
4650

0 commit comments

Comments
 (0)