Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logging, better exception handling, and update package template #34

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
steps:
- name: Checkout
uses: actions/[email protected]
- name: Python
- name: Python
uses: actions/setup-python@v2
with:
python-version: 3.9
Expand All @@ -22,4 +22,4 @@ jobs:
uses: JamesIves/[email protected]
with:
branch: gh-pages
folder: site
folder: site
28 changes: 0 additions & 28 deletions .github/workflows/release-pypi.yml

This file was deleted.

63 changes: 63 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CI

on:
push:
branches:
- 'main'
- '*.*'
tags:
- 'v*'
pull_request:
workflow_dispatch:

jobs:
test:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
# NOTE: These are purposefully set to meaningless directories where there is no SSW
# or IDL installation so that the relevant tests will be skipped.
posargs: '--ssw-home=/foo/bar --idl-home=/hello/world --log-level=DEBUG'
toxdeps: tox-pypi-filter
envs: |
- macos: py311
- windows: py311
- linux: py39
- linux: py310
- linux: py311
codestyle:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
toxdeps: tox-pypi-filter
envs: |
- linux: codestyle
python-version: '3.11'
docs:
needs: [test]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
with:
toxdeps: tox-pypi-filter
envs: |
- linux: build_docs
python-version: '3.11'
publish:
# Build wheels when pushing to any branch except main
# publish.yml will only publish if tagged ^v.*
if: |
(
github.event_name != 'pull_request' && (
github.ref_name != 'main' ||
github.event_name == 'workflow_dispatch'
)
) || (
github.event_name == 'pull_request' &&
contains(github.event.pull_request.labels.*.name, 'Run publish')
)
needs: [test]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@main
with:
test_extras: 'dev'
test_command: 'pytest -p no:warnings --pyargs hissw'
submodules: false
python-version: '3.11'
secrets:
pypi_token: ${{ secrets.PYPI_TOKEN }}
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.1.5"
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
name: isort
entry: isort
require_serial: true
language: python
types:
- python

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-ast
- id: check-case-conflict
- id: trailing-whitespace
exclude: ".*(.fits|.fts|.fit|.txt|.pro|.asdf|.sh)"
- id: check-yaml
- id: debug-statements
- id: check-added-large-files
- id: end-of-file-fixer
exclude: ".*(.fits|.fts|.fit|.txt|.pro|.asdf|.sh|.bib|tca.*)"
- id: mixed-line-ending
exclude: ".*(.fits|.fts|.fit|.txt|.bib|.asdf|.sh|tca.*)"

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
- tomli
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
include README.md
include LICENSE
include hissw/templates/*
include hissw/templates/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $ pip install hissw
```

which will automatically install the package and its dependencies.
hissw depends on the [Jinja2](http://jinja.pocoo.org/docs/dev/) and [scipy](https://docs.scipy.org/doc/) libraries.
hissw depends on the [Jinja2](http://jinja.pocoo.org/docs/dev/) and [scipy](https://docs.scipy.org/doc/) libraries.
You can also install these manually with [conda](https://www.anaconda.com/download/) or from PyPI, i.e. `pip install <package-name>`.
Additionally, you'll need a local install of IDL and the [Solarsoft library](http://www.lmsal.com/solarsoft/).

Expand Down
6 changes: 3 additions & 3 deletions docs/examples/simple_example.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import hissw
import matplotlib.pyplot as plt
script = '''
n = 5
i = REBIN(LINDGEN(n), n, n)
i = REBIN(LINDGEN(n), n, n)
j = REBIN(TRANSPOSE(LINDGEN(n)), n, n)
mask = (i GE j)
'''
Expand All @@ -22,11 +22,11 @@ But what if we want to input the size of our upper triangular array with Python?
```python
script = '''
n = {{ n }}
i = REBIN(LINDGEN(n), n, n)
i = REBIN(LINDGEN(n), n, n)
j = REBIN(TRANSPOSE(LINDGEN(n)), n, n)
mask = (i GE j)
'''
results = ssw.run(script, args={'n': 100})
plt.imshow(results['mask'])
```
![Example 2](../images/ex2.png)
![Example 2](../images/ex2.png)
5 changes: 4 additions & 1 deletion hissw/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
'''
hissw -- integrate SSW into Python workflows
'''
from .read_config import defaults
from .environment import Environment
from .logger import _init_log
from .read_config import defaults

log = _init_log()
Loading
Loading