Skip to content

Commit 745b51e

Browse files
Add fit functionality to command line interface (#145)
* Update save_as paths to include 'data/' directory and adjust test function to use temporary directory * Add crysfml * Update notebooks * Clean up * Add simple integration test for crysfml * Bump pycrysfml to 0.2.1 * Add pytest marker to neutron_pd_cwl_lbco_crysfml test * Extend package test script by adding pycrysfml * Fix scipp integration test * Move jupyterlab and pixi-kernel out from pyproject.toml * Remove unnecessary libcxx addition for osx-64 in test.yml * Add custom PyPI index support for pycrysfml in test.yml * Update .gitignore to include data directory for tutorial runtime * Apply latest templates * Add temporary rule ignores for docstring and datetime checks in pyproject.toml * Apply new templates * Update index hash for data integrity in utils.py * Add reverse flag to fit_sequential for reverse-order processing * Update tutorials index * Update tutorial * Add initial structure and analysis configuration files * Fix asymmetry and save/restore peak_profile_type in experiment CIF * Refactor switchable-type restore into _restore_switchable_types * Update test example * Update data-index.json known hash in utils.py * Return numpy array from CrysfmlCalculator and adjust pattern length handling * Add aliases and constraints for isotropic displacement parameters refinement * Add fit command to CLI * Update notebooks * Add CLI documentation to User Guide * Update documentation to move Command-Line Interface section * Bump dependencies * Add back the lost doc file * Re-copy templates * Update installation instructions and CI workflow for macOS support
1 parent abf7b63 commit 745b51e

39 files changed

Lines changed: 3843 additions & 426 deletions

File tree

.github/workflows/pypi-test.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ jobs:
4848
- name: Init pixi project
4949
run: pixi init easydiffraction
5050

51+
- name: Set the minimum system requirements
52+
run: pixi project system-requirements add macos 14.0
53+
5154
- name: Add Python 3.14 from Conda
5255
working-directory: easydiffraction
5356
run: pixi add "python=3.14"
@@ -58,22 +61,25 @@ jobs:
5861
pixi add gsl
5962
pixi add --platform osx-arm64 libcxx
6063
61-
- name: Add easydiffraction from PyPI
62-
working-directory: easydiffraction
63-
run: pixi add --pypi "easydiffraction"
64-
65-
- name: Add dev dependencies from PyPI
64+
- name: Add pycrysfml calculator from custom PyPI index
6665
working-directory: easydiffraction
67-
run: pixi add --pypi pytest pytest-xdist
66+
run: |
67+
echo '' >> pixi.toml
68+
echo '[pypi-dependencies]' >> pixi.toml
69+
echo 'pycrysfml = { version = ">=0.2.1", index = "https://easyscience.github.io/pypi/" }' >> pixi.toml
6870
69-
- name: Add Pixi task as a shortcut
71+
- name: Add easydiffraction (with dev dependencies) from PyPI
7072
working-directory: easydiffraction
71-
run: pixi task add easydiffraction "python -m easydiffraction"
73+
run: pixi add --pypi "easydiffraction[dev]"
7274

7375
- name: Run unit tests to verify the installation
7476
working-directory: easydiffraction
7577
run: pixi run python -m pytest ../tests/unit/ --color=yes -v
7678

79+
- name: Run functional tests to verify the installation
80+
working-directory: easydiffraction
81+
run: pixi run python -m pytest ../tests/functional/ --color=yes -v
82+
7783
- name: Run integration tests to verify the installation
7884
working-directory: easydiffraction
7985
run: pixi run python -m pytest ../tests/integration/ --color=yes -n auto

docs/docs/cli/index.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
icon: material/console
3+
---
4+
5+
# :material-console: Command-Line Interface
6+
7+
In addition to the Python API and Jupyter Notebooks, EasyDiffraction
8+
provides a **command-line interface (CLI)**. This is useful for basic
9+
operations without writing Python code.
10+
11+
## Running the CLI
12+
13+
The CLI is invoked as a Python module:
14+
15+
```bash
16+
python -m easydiffraction [COMMAND] [OPTIONS]
17+
```
18+
19+
If you use **Pixi** and have defined the `easydiffraction` task (see
20+
[Installation & Setup](../installation-and-setup/index.md)), you can
21+
use:
22+
23+
```bash
24+
pixi run easydiffraction [COMMAND] [OPTIONS]
25+
```
26+
27+
To see all available commands and options:
28+
29+
```bash
30+
python -m easydiffraction --help
31+
```
32+
33+
## Available Commands
34+
35+
### Show Version
36+
37+
Display the installed EasyDiffraction version:
38+
39+
```bash
40+
python -m easydiffraction --version
41+
```
42+
43+
### List Tutorials
44+
45+
List all available tutorial notebooks:
46+
47+
```bash
48+
python -m easydiffraction list-tutorials
49+
```
50+
51+
### Download Tutorials
52+
53+
Download a specific tutorial by ID:
54+
55+
```bash
56+
python -m easydiffraction download-tutorial 1
57+
```
58+
59+
Download all available tutorials:
60+
61+
```bash
62+
python -m easydiffraction download-all-tutorials
63+
```
64+
65+
Both commands accept `--destination` (`-d`) to specify the output
66+
directory (default: `tutorials/`) and `--overwrite` (`-o`) to replace
67+
existing files.
68+
69+
### Fit a Project
70+
71+
Load a saved project and run structural refinement:
72+
73+
```bash
74+
python -m easydiffraction fit PROJECT_DIR
75+
```
76+
77+
`PROJECT_DIR` is the path to a project directory previously created by
78+
`project.save_as()`. It must contain a `project.cif` file along with the
79+
`structures/`, `experiments/`, and `analysis/` subdirectories.
80+
81+
After fitting, the command displays the fit results and a project
82+
summary. By default, updated parameter values are **saved back** to the
83+
project directory.
84+
85+
Use the `--dry` flag to run the fit **without overwriting** the project
86+
files:
87+
88+
```bash
89+
python -m easydiffraction fit PROJECT_DIR --dry
90+
```

docs/docs/index.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
![](assets/images/logo_dark.svg#gh-dark-mode-only)![](assets/images/logo_light.svg#gh-light-mode-only)
22

3-
# Diffraction data analysis library
3+
# Diffraction data analysis
44

55
Here is a brief overview of the main documentation sections:
66

77
- [:material-information-slab-circle: Introduction](introduction/index.md)
8-
– Provides an overview of EasyDiffraction, including its purpose,
8+
– Provides a description of EasyDiffraction, including its purpose,
99
licensing, latest release details, and contact information.
1010
- [:material-cog-box: Installation & Setup](installation-and-setup/index.md)
1111
– Guides users through system requirements, environment configuration,
@@ -19,3 +19,6 @@ Here is a brief overview of the main documentation sections:
1919
- [:material-code-braces-box: API Reference](api-reference/index.md)
2020
An auto-generated reference detailing the available functions and
2121
modules in EasyDiffraction.
22+
- [:material-console: Command-Line Interface](cli/index.md) – Describes
23+
how to use EasyDiffraction from the terminal for batch fitting and
24+
other tasks.

0 commit comments

Comments
 (0)