Skip to content

Commit

Permalink
Merge pull request #5 from neutrons/precommit
Browse files Browse the repository at this point in the history
Modernize the Repo
  • Loading branch information
jmborr authored May 22, 2024
2 parents 2c0dc48 + 4b45077 commit 12ad8c5
Show file tree
Hide file tree
Showing 45 changed files with 1,472 additions and 863 deletions.
43 changes: 43 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Description of the changes

# Manual test for the reviewer
<!-- Instructions for testing here. -->

# Check list for the reviewer
- [ ] best software practices
+ [ ] clearly named variables (better to be verbose in variable names)
+ [ ] code comments explaining the intent of code blocks
- [ ] All the tests are passing
- [ ] The documentation is up to date
- [ ] code comments added when explaining intent

### Execution of tests requiring the /SNS and /HFIR filesystems
It is strongly encouraged that the reviewer runs the following tests in their local machine
because these tests are not run by the GitLab CI. It is assumed that the reviewer has the /SNS and /HFIR filesystems
remotely mounted in their machine.

```bash
cd /path/to/my/local/mr_reduction/repo/
git fetch origin merge-requests/<MERGE_REQUEST_NUMBER>/head:mr<MERGE_REQUEST_NUMBER>
git switch mr<MERGE_REQUEST_NUMBER>
conda activate <my_mr_reduction_environment>
pytest -m mount_eqsans ./tests/unit/ ./tests/integration/
```
In the above code snippet, substitute `<MERGE_REQUEST_NUMBER>` for the actual merge request number. Also substitute
`<my_mr_reduction_environment>` with the name of the conda environment you use for development. It is critical that
you have installed the repo in editable mode with `pip install -e .` or `conda develop .`

# Check list for the author
- [ ] I have added tests for my changes
- [ ] I have updated the documentation accordingly
- [ ] I ran the tests requiring the /SNS and /HFIR filesystems
- [ ] I'm including a link to IBM EWM Story or Defect

# Check list for the pull request
- [ ] source refactored/incremented
- [ ] tests for my changes
- [ ] updated the documentation accordingly

# References
<!-- Links to related issues or pull requests -->
<!-- Links to IBM EWM items if aaplicable -->
12 changes: 5 additions & 7 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@ jobs:
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
channels: conda-forge,defaults
channels: mantid/label/main,conda-forge,defaults
mamba-version: "*"
environment-file: environment.yml
cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }}
cache-downloads-key: ${{ runner.os }}-downloads-${{ hashFiles('**/environment.yml') }}
- name: install additional dependencies
run: |
echo "installing additional dependencies from environment_development.yml"
- name: build conda package
run: |
# set up environment
cd conda.recipe
echo "versioningit $(versioningit ../)"
# build the package
VERSION=$(versioningit ../) conda mambabuild --channel conda-forge --output-folder . .
conda verify noarch/mypackagename*.tar.bz2
CHANNELS="--channel mantid/label/main --channel conda-forge"
VERSION=$(versioningit ../) conda mambabuild $CHANNELS --output-folder . .
conda verify noarch/mr_reduction*.tar.bz2
- name: upload conda package to anaconda
shell: bash -l {0}
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -44,4 +42,4 @@ jobs:
CONDA_LABEL="main"
if [ "${IS_RC}" = "true" ]; then CONDA_LABEL="rc"; fi
echo pushing ${{ github.ref }} with label $CONDA_LABEL
anaconda upload --label $CONDA_LABEL conda.recipe/noarch/mypackagename*.tar.bz2
anaconda upload --label $CONDA_LABEL conda.recipe/noarch/mr_reduction*.tar.bz2
20 changes: 15 additions & 5 deletions .github/workflows/unittest.yml → .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: unit-test
name: testing

on:
workflow_dispatch:
Expand All @@ -18,7 +18,7 @@ jobs:
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
channels: conda-forge,defaults
channels: mantid/label/main,conda-forge,defaults
mamba-version: "*"
environment-file: environment.yml
cache-environment-key: ${{ runner.os }}-env-${{ hashFiles('**/environment.yml') }}
Expand All @@ -29,18 +29,28 @@ jobs:
- name: run unit tests
run: |
echo "running unit tests"
python -m pytest --cov=src --cov-report=xml --cov-report=term-missing tests/
python -m pytest -vv -m "not datarepo and not sns_mounted" --cov=src --cov-report=xml --cov-report=term-missing tests/
mv .coverage .coverage.unit
- name: run integration tests
run: |
echo "running integration tests"
git submodule update --init
python -m pytest -vv -m "datarepo" --cov=src --cov-report=xml --cov-report=term-missing tests/
mv .coverage .coverage.integration
- name: combine coverage reports
run: |
coverage combine # merge all .coverage.* files into .coverage
- name: upload coverage to codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: build conda package
run: |
# test that the conda package builds
# set up environment
cd conda.recipe
echo "versioningit $(versioningit ../)"
# conda channels could have been defined in the conda-incubator, but you can copy/paste the lines
# below to build the conda package in your local machine
CHANNELS="--channel mantid/label/main --channel conda-forge"
VERSION=$(versioningit ../) conda mambabuild $CHANNELS --output-folder . .
conda verify noarch/mypackagename*.tar.bz2
conda verify noarch/mr_reduction*.tar.bz2
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "tests/mr_reduction-data"]
path = tests/mr_reduction-data
url = https://code.ornl.gov/sns-hfir-scse/infrastructure/test-data/mr_reduction-data.git
55 changes: 9 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,20 @@
[![codecov](https://codecov.io/gh/neutrons/MagnetismReflectometer/branch/master/graph/badge.svg)](https://codecov.io/gh/neutrons/MagnetismReflectometer)

# MR automated reduction
Automated reduction code based on Mantid.

- Code under `mr_reduction` is common reduction code.
- Code under `autoreduce` is the top-level code used by the post-processing.
- Code under `livereduce` is the top-level code for live reduction.

# Configuration
The configuration file under `livereduce/livereduce.conf` needs to be place under `/etc` on
the live reduction node.

# python_project_template
This repository is a template repository for Python projects under neutrons.
After you create a new repository using this repo as template, please follow the following steps to adjust it for the new project.

## Codebase Adjustments

1. Adjust the branch protection rules for the new repo. By default, we should protect the `main` (stable), `qa` (release candidate), and `next` (development) branches.

1.1 Go to the `Settings` tab of the new repo.
# Magnetism Reflectometer Automated Reduction
Automated reduction code of magnetic reflectometry data.

1.2 Click on `Branches` on the left side.

1.3 Click on `Add rule` button.

1.4 Follow the instructions from Github.


2. Change the License if MIT license is not suitable for you project. For more information about licenses, please
refer to [Choose an open source license](https://choosealicense.com/).


3. Update the environment dependency file `environment.yml`, which contain both runtime and development dependencies.
For more information about conda environment file, please refer to [Conda environment file](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-file-manually).

3.1 Specify environment 'name' field to match package name
<!-- Badges -->
[![codecov](https://codecov.io/gh/neutrons/MagnetismReflectometer/branch/master/graph/badge.svg)](https://codecov.io/gh/neutrons/MagnetismReflectometer)

3.2 We strongly recommended using a single `environment.yml` file to manage all the dependencies,
including the runtime and development dependencies.

3.3 Please add comments to the `environment.yml` file to explain the dependencies.
# User

3.4 Please prune the dependencies to the minimum when possible,
we would like the solver to figure out the dependency tree for us.
User guide at [readthedocs](https://mr_reduction.readthedocs.io/en/latest)

# Developer

4. Adjust pre-commit configuration file, `.pre-commit-config.yaml` to enable/disable the hooks you need.
For more information about pre-commit, please refer to [pre-commit](https://pre-commit.com/).
Developer documentation at [readthedocs](https://mr_reduction.readthedocs.io/en/latest)

- [contributing to the project](https://mr_reduction.readthedocs.io/en/latest/source/developer/contributing.html)

5. Having code coverage, `codecov.yaml` is **strongly recommended**,
please refer to [Code coverage](https://coverage.readthedocs.io/en/coverage-5.5/) for more information.


6. Adjust the demo Github action yaml files for CI/CD. For more information about Github action,
Expand Down
11 changes: 10 additions & 1 deletion conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% set build_number = 0 %}

package:
name: mypackagename
name: mr_reduction
version: {{ version_number }}

source:
Expand All @@ -35,6 +35,15 @@ requirements:

run:
- python
- mantid=6.9.0
- numpy
- scipy
- pandas
- plotly

tests:
imports:
- mr_reduction

about:
home: {{ url }}
Expand Down
Loading

0 comments on commit 12ad8c5

Please sign in to comment.