Skip to content

Commit

Permalink
Merge pull request #255 from FrandsenGroup/Issue-252
Browse files Browse the repository at this point in the history
Issue 252 - Update installation instructions
  • Loading branch information
aPeter1 authored Mar 31, 2023
2 parents a1741a1 + eb2b420 commit 8eab102
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 41 deletions.
46 changes: 37 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,53 @@
name: Tests
on:
push:
branches:
- master
pull_request:
branches:
- master
- Issue

jobs:
build:
runs-on: windows-latest
build-and-test-python:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ '3.11' ]
steps:
- uses: actions/checkout@v2
- name: Install Python 3
uses: actions/setup-python@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r python_requirements.txt
- name: Run tests with pytest
- name: Run tests
run: cd beams && pytest -ra

build-and-test-anaconda:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ '3.11' ]
steps:
- uses: actions/checkout@v2
- name: Set up Anaconda with Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
activate-environment: test
python-version: ${{ matrix.python-version }}
- name: Install dependencies
shell: bash -el {0}
run: |
python -m pip install --upgrade pip
conda install -c anaconda -c conda-forge --file conda_requirements.txt
conda install -c conda-forge pytest
python -m pip install musr2py
- name: Run tests with PyTest
shell: bash -el {0}
run: |
cd beams
pytest -ra
52 changes: 52 additions & 0 deletions .github/workflows/ci_main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Tests
on:
push:
branches:
- master

jobs:
build-and-test-python:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
python-version: [ '3.11' ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r python_requirements.txt
- name: Run tests
run: cd beams && pytest -ra

build-and-test-anaconda:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest, macos-latest, ubuntu-latest ]
python-version: [ '3.11' ]
steps:
- uses: actions/checkout@v2
- name: Set up Anaconda with Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
activate-environment: test
python-version: ${{ matrix.python-version }}
- name: Install dependencies
shell: bash -el {0}
run: |
python -m pip install --upgrade pip
conda install -c anaconda -c conda-forge --file conda_requirements.txt
conda install -c conda-forge pytest
python -m pip install musr2py
- name: Run tests with PyTest
shell: bash -el {0}
run: |
cd beams
pytest -ra
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![beams logo](beams/app/resources/icons/logo.png)
[![Release](https://img.shields.io/github/release/FrandsenGroup/beams.svg?style=plastic&colorB=68B7EB)](https://github.com/FrandsenGroup/beams/releases)
[![Tests](https://github.com/FrandsenGroup/beams/actions/workflows/ci.yml/badge.svg)](https://github.com/FrandsenGroup/beams/actions/workflows/ci.yml)
[![Tests](https://github.com/FrandsenGroup/beams/actions/workflows/ci.yml/badge.svg)](https://github.com/FrandsenGroup/beams/actions/workflows/ci_main.yml)
[![Build](https://github.com/FrandsenGroup/beams/actions/workflows/build.yml/badge.svg)](https://github.com/FrandsenGroup/beams/actions/workflows/build.yml)
[![CodeQL](https://github.com/FrandsenGroup/beams/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/FrandsenGroup/beams/actions/workflows/codeql-analysis.yml)

Expand Down Expand Up @@ -53,17 +53,18 @@
#### Without Anaconda
- Run the following command to install the package requirements for BEAMS (note that you may need to use `python3` instead of `python`, you can use `python --version` to make sure it is referencing the correct version)
```shell
$ python -m pip install -r python_requirements.txt
python -m pip install -r python_requirements.txt
```
#### Anaconda
- Run the following command in the anaconda prompt to install requirements.
```shell
$ conda install -c anaconda -c conda-forge --file conda_requirements.txt
conda install -c anaconda -c conda-forge --file conda_requirements.txt
python -m pip install musr2py
```

Start BEAMS for either, once you have navigated to the directory with the following
```shell
$ python beams
python beams
```

## User Guide
Expand Down
29 changes: 18 additions & 11 deletions beams/app/resources/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ def resource_path(relative_path, creating=False) -> str:
if not creating and not os.path.exists(path):
path = os.path.join(os.getcwd(), "beams", relative_path)

return str(Path(path))
if not os.path.exists(path) and os.getcwd().endswith("test"):
path = os.path.join(os.getcwd().removesuffix("test"), relative_path)

final_path = str(Path(path))
if not creating and not os.path.exists(final_path):
raise Exception(f"Could not create a valid resource path for {relative_path} (final was {final_path})")

return final_path


# Using Path from pathlib is an easy way to fix the slash direction issue when switch between windows and unix systems.
Expand All @@ -48,16 +55,16 @@ def resource_path(relative_path, creating=False) -> str:
LIGHT_LOADING_GIF = resource_path('app/resources/icons/light_loading.gif')
DARK_LOADING_GIF = resource_path('app/resources/icons/dark_loading.gif')

LATO_BLACK_FONT = resource_path('app/resources/fonts/fonts-Black.ttf')
LATO_BLACK_ITALIC_FONT = resource_path('app/resources/fonts/fonts-BlackItalic.ttf')
LATO_BOLD_FONT = resource_path('app/resources/fonts/fonts-Bold.ttf')
LATO_BOLD_ITALIC_FONT = resource_path('app/resources/fonts/fonts-BoldItalic.ttf')
LATO_ITALIC_FONT = resource_path('app/resources/fonts/fonts-Italic.ttf')
LATO_LIGHT_FONT = resource_path('app/resources/fonts/fonts-Light.ttf')
LATO_LIGHT_ITALIC_FONT = resource_path('app/resources/fonts/fonts-LightItalic.ttf')
LATO_REGULAR_FONT = resource_path('app/resources/fonts/fonts-Regular.ttf')
LATO_THIN_FONT = resource_path('app/resources/fonts/fonts-Thin.ttf')
LATO_THIN_ITALIC_FONT = resource_path('app/resources/fonts/fonts-ThinItalic.ttf')
LATO_BLACK_FONT = resource_path('app/resources/fonts/Lato-Black.ttf')
LATO_BLACK_ITALIC_FONT = resource_path('app/resources/fonts/Lato-BlackItalic.ttf')
LATO_BOLD_FONT = resource_path('app/resources/fonts/Lato-Bold.ttf')
LATO_BOLD_ITALIC_FONT = resource_path('app/resources/fonts/Lato-BoldItalic.ttf')
LATO_ITALIC_FONT = resource_path('app/resources/fonts/Lato-Italic.ttf')
LATO_LIGHT_FONT = resource_path('app/resources/fonts/Lato-Light.ttf')
LATO_LIGHT_ITALIC_FONT = resource_path('app/resources/fonts/Lato-LightItalic.ttf')
LATO_REGULAR_FONT = resource_path('app/resources/fonts/Lato-Regular.ttf')
LATO_THIN_FONT = resource_path('app/resources/fonts/Lato-Thin.ttf')
LATO_THIN_ITALIC_FONT = resource_path('app/resources/fonts/Lato-ThinItalic.ttf')

TRIUMF_LINUX_CONVERSION = resource_path('app/resources/binaries/TRIUMF_LINUX')
TRIUMF_MAC_CONVERSION = resource_path('app/resources/binaries/TRIUMF_MAC')
Expand Down
6 changes: 4 additions & 2 deletions beams/test/test_files.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
import os
import sys

import numpy as np

Expand Down Expand Up @@ -114,11 +115,12 @@ def test_convert_on_good_file(self, filename, out_file, expected_out_file):

@pytest.mark.skipif(SKIP_EXECUTABLE_TESTS, reason=SKIP_REASON)
def test_convert_on_bad_file(self):
msr_file = files.TRIUMFMuonFile(resources.resource_path(r"test/examples/psi_convert_test_1.mdu"))
msr_file = files.TRIUMFMuonFile(resources.resource_path(r"test/examples/psi_convert_test_mdu_1.mdu"))
with pytest.raises(files.BeamsFileConversionError):
msr_file.convert(r"_triumf_convert_test_2.dat")


@pytest.mark.skipif(sys.platform == 'darwin', reason="PSI file conversion is failing on mac due to a dependency")
class TestPsiMuonFile:
@pytest.mark.parametrize("filename, out_file, expected_out_file",
[
Expand Down Expand Up @@ -238,7 +240,7 @@ def test_convert_on_good_file_with_format(self, filename, starts, ends, names, o
def test_convert_on_bad_file(self):
msr_file = files.ISISMuonFile(resources.resource_path(r"test/examples/triumf_convert_test_1.msr"))
with pytest.raises(files.BeamsFileConversionError):
msr_file.convert(resources.resource_path(r"_triumf_convert_test_2.dat"))
msr_file.convert(r"_triumf_convert_test_1.dat")

@pytest.mark.parametrize("filename, histograms",
[
Expand Down
3 changes: 1 addition & 2 deletions conda_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pyqt
qtpy
requests
numpy
sympy
Expand All @@ -9,6 +10,4 @@ darkdetect
h5py
sentry-sdk
pyinstaller
pytest
musr2py
regex
26 changes: 13 additions & 13 deletions python_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
pyqt5==5.15.4
requests==2.25.1
numpy==1.22.0
sympy==1.8
scipy==1.6.3
matplotlib==3.4.2
pytest==6.2.5
qdarkstyle==3.1
darkdetect==0.5.1
h5py==3.6.0
sentry-sdk==1.14.0
pyinstaller==4.9
musr2py==0.0.1
pyqt5
requests
numpy
sympy
scipy
matplotlib
pytest
qdarkstyle
darkdetect
h5py
sentry-sdk
pyinstaller
musr2py
regex

0 comments on commit 8eab102

Please sign in to comment.