Skip to content

Commit 0b21681

Browse files
Refactor core objects, improve validation, and update API (#106)
* Simplifies branch processing and installs badgery * Adds flag for unit test coverage in .badgery.yaml * Updates dependencies and easydiffraction shortcuts * Adds dashboard build trigger post-tutorial tests * Updates tutorial command names in workflow script * Simplifies installation by using all extras * Adds dashboard build trigger after PyPI tests * Refactors sample model creation architecture * Updates sample model API in tests * Updates sample model API in tutorials * Refactors argument validation and simplifies CIF reading * Update SampleModel API and adjust linked phases check * Increase McCabe complexity limit and add dependency * Fixes dev-install command in pixi.toml * Adds centralized logging utility * Adds function to parse CIF-style numeric strings to ufloat * Refactors core object model for improved structure * Refactors ID attributes to use entry_name consistently * Refactors alias and constraint classes * Refactors core objects to enhance category handling * Refactors core components and structures for enhanced clarity * Adds CIF alias utility functions to enhance data handling * Add test suite for SampleModels components and fix imports * Updates package versions in dependency lock file * Introduce allowed attributes and update collection initialization * Adds allowed attributes to mixins for parameter handling * Refactors CIF conversion by removing method calls * Enhances attribute validation in CryspyCalculator * Allow editing of uncertainty and free attributes * Refines CIF data parsing and handling logic * Modifies model initialization and linking * Refines instrument and peak attribute handling * Fixes bug in parameter setting logic * Refactors parameter attributes and access methods * Enhances background and model flexibility * Rename error handling methods and adjust datablock management * Refactors entry name handling in core classes * Standardizes 'entry_name' to 'category_entry_name' * Enhances sample model and plotting configuration * Enhances item management in CategoryCollection * Adds allowed attributes to SingleCrystalExperiment * Replaces human-readable ID generation with property access * Comments out unit test step from pre-push hook * Disables physical parameter bounds * Refines physical constraints and simplifies code * Refactors method calls to use add_from_args for clarity * Refactors method calls and updates numeric constants * Updates parameter bound handling and method naming * Refactors method calls to improve clarity * Refines attribute access and updates test methods * Refactors item addition in CategoryCollection * Refactors unit tests to use full_cif_names * Refactors parameter access and method calls * Refines attribute naming for clarity in background model * Adjusts default renderer for PyCharm environment * Updates attribute checks, adds data files, renames scripts * Adds extra test configuration and refines unit tests * Refactors attribute access and control logic * Enhances logging and error handling mechanism * Simplifies error handling in logging with 'raise from' * Refactors core objects for modular design * Improves logging behavior during pytest * Simplifies py-format-fix command * Refactors parameter descriptor hierarchy * Enhances logging and documents parameter abstraction * Refactors test cases to align with new API and data structures * Cleans up test imports and simplifies assertions * Refactors singleton tests for consistency * Refines descriptor/parameter handling logic * First attempt to add CifMixin to parameter classes * Updates CifMixin.cif_uid to use full_name * Refactors parameter abstraction layer * Enhances Logger configuration with environment variables * Refactors lazy loading in __init__.py for efficiency * Consolidates attribute guard mixins and refactors logic * Move mixins to guarded base class * Refactors core component architecture * Replace enforce_type with typeguard for runtime type checking * Remove legacy signature from add method and update tests * Enhances category item renaming logic (ugly temporary workaround) * Refactors attribute handling in parameter classes * Enhances Project class with type-checking and encapsulation * Refines __str__ method and fixes super call * Enhances collection handling by implementing AbstractCollection * Enhances type safety with generics for collections * Add SPDX license headers to source files * Initialize base class in CollectionBase constructor * Refactors parameter access for consistency * Removes unnecessary Generic typing * Work in progress * Enhances identity resolution and string representation * Improves parameter retrieval in collections * Adds `full_name` property to multiple classes * Simplifies attribute handling in GuardedBase * Renames full_name property to unique_name * Refines validation logging messages * Adds configurable error reaction in Logger * Enhances type error diagnostics in checktype decorator * Giant refactoring * Refactors parameter handling in FitResults * Refactors descriptor properties and enhances validation * Removes unused TODO comments and corrects assertions * Adds SPDX license headers to source files * Enhances space group validation logic * Refactors validation logic for atom site properties * Adds missing newline in atom_sites.py * Refactors CIF conversion and updates test format * Reformats code for consistency and clarity * Refines parameter handling and improves validation * Refactors tests to improve readability and maintainability * Enhances atom site configuration in tutorials * Enhances x-axis data selection for plotting * Refactors atom site addition for clarity and consistency * Fixes parameter limit handling * Fixes attribute assignment and model access * Refactors data extraction with list comprehensions * Refactors constraint handling and data access methods * Enhances peak profile type handling in experiments * Removes unused public attributes method * Improves logging settings and Python path resolution * Refines validators with enhanced logging * Adds parameter validation and logging enhancements * Replaces diagnostics and validators with an enhanced implementation * Adds Diagnostics for Type Override and Enhances Collections * Enhances validation and logging mechanisms * Refactors validator and identity handling * Replaces RegexValidator with AttributeSpec for validation * Maintain parent linkage for nested objects * Corrects attribute access in identity resolution * Refactors validation types to use DataTypes enum * Refines type validation logic in diagnostics * Replace UUID with secure random UID generation * Refines atom site validations and logging * Enhances validation logic and diagnostics handling * Relocates CifHandler to new IO module for clarity * Refactors experiment enums structure * Updates peak mixin imports for better organization * Refactors instrument setup for improved modularity * Refactors background module implementation * Refactors CIF serialization methods * Refactors CIF serialization to centralized functions * Removes obsolete CIF conversion methods * Restructures experiment type classes for modular design * Refactors instrument handling and restructures sample models * Reorganizes import paths to category_items * Refactors component naming for better clarity * Refactors code to categorize collections * Reorganizes import paths to use category_collections modules * Refactors background type handling for clarity * Refactors background handling and reorganizes enums * Refactors background and instrument modules organization * Refactors instrument and peak base class imports * Refactors argument validation in ExperimentFactory * Refactors import paths for consistency * Refactors datastore architecture for segregation of types * Fixes property getter for uncertainty * Add and update SPDX license headers across files * Adds package structure documentation generator * Renames datastore type modules for clarity * Refactors package structure for clarity * Renames and restructures package directories for clarity * Renames core modules for consistency * New unit tests * Refactors factory method usage in test suite * Add unit tests for various components in easydiffraction * Adds unit test for crystallographic and experimental data * Enables macOS h5py dependency for validation * Replaces scaffold tests with concrete test implementations * Replaces test scaffolds with concrete tests * Adds comprehensive test coverage for core modules * Format tests * Enhances SPDX header update for tests directory * Cleans up tests and refines pytest configuration * Refines config and reorganizes files for tmp exclusion * Adds comprehensive docstrings to Analysis classes and descriptors * Enhances experiment class documentation * Updates .gitignore for test and linter caches * Removes Python cache before packaging artifacts * Updates python_socketio and mkdocs-jupyter dependencies * Adds multiple Python cache removal steps * Adds dev-install step in GitHub workflow * Removes redundant dev-install command from workflow * Reorganizes dependency configuration * Refactors Python cache removal in workflow * Refactors to use Factory classes for model and experiment creation * Enhances enums with descriptive methods * Enhances documentation with docstrings * Add missing documentation for core modules * Adds docstrings for improved code documentation * Updates pytest configuration for test management * Refactors CryspyCalculator and updates SPDX compliance * Remove commented code and add documentation placeholders * Adds environment variable for CI branch
1 parent 93e8534 commit 0b21681

File tree

281 files changed

+23700
-12917
lines changed

Some content is hidden

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

281 files changed

+23700
-12917
lines changed

.badgery.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ cards:
5252
- group: Coverage
5353
type: codecov
5454
title: Unit test coverage (Codecov)
55+
flag: unittests
5556
enabled: true
5657

5758
- group: Coverage

.github/workflows/dashboard.yaml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,33 +41,34 @@ jobs:
4141

4242
- name: Install and setup development dependencies
4343
shell: bash
44-
run: pixi run dev
44+
run: |
45+
pixi run dev
46+
pixi add --pypi --git https://github.com/enhantica/badgery badgery
4547
4648
- name: Run docstring coverage and code complexity/maintainability checks
4749
run: |
4850
for BRANCH in ${{ env.DEFAULT_BRANCH }} ${{ env.DEVELOP_BRANCH }} ${{ env.CI_BRANCH }}; do
4951
echo "=== Processing branch $BRANCH ==="
50-
if [ -d "../worktree-$BRANCH" ]; then
52+
if [ -d "../$BRANCH" ]; then
5153
echo "Branch $BRANCH already processed, skipping"
5254
continue
5355
fi
54-
git worktree add ../worktree-$BRANCH origin/$BRANCH
56+
git worktree add ../$BRANCH origin/$BRANCH
5557
mkdir -p reports/$BRANCH
5658
echo "Docstring coverage for branch $BRANCH"
57-
pixi run interrogate -c pyproject.toml --fail-under=0 ../worktree-$BRANCH/src > reports/$BRANCH/coverage-docstring.txt
59+
pixi run interrogate -c pyproject.toml --fail-under=0 ../$BRANCH/src > reports/$BRANCH/coverage-docstring.txt
5860
echo "Cyclomatic complexity for branch $BRANCH"
59-
pixi run radon cc -s -j ../worktree-$BRANCH/src --exclude ../worktree-$BRANCH/src/easydiffraction/crystallography/space_group_lookup_table.py > reports/$BRANCH/cyclomatic-complexity.json
61+
pixi run radon cc -s -j ../$BRANCH/src > reports/$BRANCH/cyclomatic-complexity.json
6062
echo "Maintainability index for branch $BRANCH"
61-
pixi run radon mi -j ../worktree-$BRANCH/src --exclude ../worktree-$BRANCH/src/easydiffraction/crystallography/space_group_lookup_table.py > reports/$BRANCH/maintainability-index.json
63+
pixi run radon mi -j ../$BRANCH/src > reports/$BRANCH/maintainability-index.json
6264
echo "Raw metrics for branch $BRANCH"
63-
pixi run radon raw -s -j ../worktree-$BRANCH/src --exclude ../worktree-$BRANCH/src/easydiffraction/crystallography/space_group_lookup_table.py > reports/$BRANCH/raw-metrics.json
65+
pixi run radon raw -s -j ../$BRANCH/src > reports/$BRANCH/raw-metrics.json
6466
done
6567
6668
- name: Generate dashboard HTML
67-
run: |
68-
pixi add --pypi --git https://github.com/enhantica/badgery badgery
69-
pixi run pip show badgery
70-
pixi run python -m badgery --config .badgery.yaml --repo ${{ github.repository }} --branch ${{ env.CI_BRANCH }} --output index.html
69+
run: >
70+
pixi run python -m badgery --config .badgery.yaml --repo ${{
71+
github.repository }} --branch ${{ env.CI_BRANCH }} --output index.html
7172
7273
- name: Prepare publish directory
7374
run: |

.github/workflows/pypi-test.yaml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ env:
2020
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
2121

2222
jobs:
23+
# Job 1: Test installation from PyPI on multiple OS
2324
pypi-package-tests:
2425
strategy:
2526
matrix:
@@ -54,10 +55,8 @@ jobs:
5455
- name: Create the environment and install dependencies
5556
run: pixi install
5657

57-
- name: Install package from PyPI with dev and visualization extras
58-
run: |
59-
pixi add --pypi "easydiffraction[dev,visualization]"
60-
pixi run easydiffraction --version
58+
- name: Install package from PyPI with all extras
59+
run: pixi add --pypi "easydiffraction[all]"
6160

6261
- name: Run unit tests to verify the installation
6362
run: pixi run unit-tests
@@ -70,8 +69,31 @@ jobs:
7069
env:
7170
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7271
run: |
73-
pixi run tutorials-list
74-
pixi run tutorials-fetch
72+
pixi run easydiffraction --version
73+
pixi run easydiffraction list-tutorials
74+
pixi run easydiffraction fetch-tutorials
7575
7676
- name: Test tutorials as notebooks
7777
run: pixi run notebook-tests
78+
79+
# Job 2: Trigger dashboard build
80+
dashboard-build-trigger:
81+
needs: pypi-package-tests
82+
83+
runs-on: ubuntu-latest
84+
85+
steps:
86+
- name: Check-out repository
87+
uses: actions/checkout@v5
88+
89+
- name: Trigger dashboard build
90+
uses: actions/github-script@v7
91+
with:
92+
github-token: ${{ secrets.GITHUB_TOKEN }}
93+
script: |
94+
await github.rest.actions.createWorkflowDispatch({
95+
owner: context.repo.owner,
96+
repo: context.repo.repo,
97+
workflow_id: "dashboard.yaml",
98+
ref: "${{ env.CI_BRANCH }}"
99+
});

.github/workflows/test.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ jobs:
147147
shell: bash
148148
run: pixi remove --pypi easydiffraction
149149

150+
- name: Remove Python cache files before uploading
151+
shell: bash
152+
run: pixi run clean-pycache
153+
150154
# More than one file/dir need to be specified in 'path', to preserve the
151155
# structure of the dist/ directory, not only its contents.
152156
- name: Upload Python package for the next job
@@ -156,6 +160,7 @@ jobs:
156160
path: |
157161
dist/
158162
tests/
163+
pytest.ini
159164
pixi.toml
160165
pixi.lock
161166
if-no-files-found: 'error'

.github/workflows/tutorial-tests.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ concurrency:
2222
${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
2323
cancel-in-progress: true
2424

25+
# Set the environment variables to be used in all jobs defined in this workflow
26+
env:
27+
CI_BRANCH: ${{ github.head_ref || github.ref_name }}
28+
2529
jobs:
30+
# Job 1: Test tutorials as scripts and notebooks on multiple OS
2631
tutorial-tests:
2732
strategy:
2833
fail-fast: false
@@ -60,3 +65,25 @@ jobs:
6065
- name: Test tutorials as notebooks
6166
shell: bash
6267
run: pixi run notebook-tests
68+
69+
# Job 2: Trigger dashboard build
70+
dashboard-build-trigger:
71+
needs: tutorial-tests
72+
73+
runs-on: ubuntu-latest
74+
75+
steps:
76+
- name: Check-out repository
77+
uses: actions/checkout@v5
78+
79+
- name: Trigger dashboard build
80+
uses: actions/github-script@v7
81+
with:
82+
github-token: ${{ secrets.GITHUB_TOKEN }}
83+
script: |
84+
await github.rest.actions.createWorkflowDispatch({
85+
owner: context.repo.owner,
86+
repo: context.repo.repo,
87+
workflow_id: "dashboard.yaml",
88+
ref: "${{ env.CI_BRANCH }}"
89+
});

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@ __pycache__
44
.coverage
55
.pyc
66

7+
# PyTest
8+
.pytest_cache
9+
10+
# MyPy
11+
.mypy_cache
12+
713
# Pixi
814
.pixi
915

16+
# Ruff
17+
.ruff_cache
18+
1019
# Jupyter Notebooks
1120
.ipynb_checkpoints
1221

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ repos:
4949
pass_filenames: false
5050
stages: [pre-push]
5151

52-
- id: pixi-unit-tests
53-
name: pixi run unit-tests
54-
entry: pixi run unit-tests
55-
language: system
56-
pass_filenames: false
57-
stages: [pre-push]
52+
#- id: pixi-unit-tests
53+
# name: pixi run unit-tests
54+
# entry: pixi run unit-tests
55+
# language: system
56+
# pass_filenames: false
57+
# stages: [pre-push]

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
# Pixi
2+
.pixi
23
pixi.lock
4+
5+
# MyPy
6+
.mypy_cache

0 commit comments

Comments
 (0)