Skip to content

Commit

Permalink
Public release of cfspopcon
Browse files Browse the repository at this point in the history
  • Loading branch information
hassec committed Oct 30, 2023
0 parents commit 6f0e5c8
Show file tree
Hide file tree
Showing 123 changed files with 17,688 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/make_radas_data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set -ex

git clone https://github.com/cfs-energy/radas.git

pushd radas

git checkout d9e23824f2edc46ef35e2fd54cf26438a3180733

poetry install --only main

poetry run python adas_data/fetch_adas_data.py

poetry run python run_radas.py all

popd
113 changes: 113 additions & 0 deletions .github/workflows/workflow_actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: workflow_actions

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
pull_request: []
push:
branches:
- 'main'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
tag: "Manual run"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
radas:
runs-on: ubuntu-22.04
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python - --version 1.6.1

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'poetry'

- name: Cache radas results
id: radas
uses: actions/cache@v3
with:
path: radas
key: radas-${{ hashFiles('.github/workflows/make_radas_data.sh')}}

- name: Make radas data
if: steps.radas.outputs.cache-hit != 'true'
run: bash .github/workflows/make_radas_data.sh

build:
needs: radas
# The type of runner that the job will run on
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11'] # should test the versions we allow for in pyproject.toml

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Install pandoc
run: sudo apt-get update && sudo apt-get install pandoc

- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python - --version 1.6.1

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'poetry'

- name: Setup
run: poetry install

- uses: actions/cache/restore@v3
id: radas
with:
path: radas
key: radas-${{ hashFiles('.github/workflows/make_radas_data.sh')}}

- name: Check cache hit
if: steps.radas.outputs.cache-hit != 'true'
run: exit 1

- name: Copy radas data
run: cp ./radas/cases/*/output/*.nc cfspopcon/atomic_data/

- name: Tests
run: MPLBACKEND=Agg poetry run pytest tests --nbmake example_cases

- name: Test package
run: |
poetry build -f wheel
python -m venv test_env
source ./test_env/bin/activate
pip install $(find ./dist -name "*.whl")
# enter tempdir so import cfspopcon doesn't find the cfspopcon directory
mkdir tmp_dir && cd tmp_dir
echo $(python -c 'from cfspopcon import atomic_data;from pathlib import Path; print(Path(atomic_data.__file__).parent)')
cp ../radas/cases/*/output/*.nc $(python -c 'from cfspopcon import atomic_data;from pathlib import Path; print(Path(atomic_data.__file__).parent)')
MPLBACKEND=Agg popcon ../example_cases/SPARC_PRD/input.yaml -p ../example_cases/SPARC_PRD/plot_popcon.yaml --show
- name: Run pre-commit checks
run: poetry run pre-commit run --show-diff-on-failure --color=always --all-files

- name: Test docs
# instead of make html we use sphinx-build directly to add more options
run: |
cd docs
poetry run sphinx-build --keep-going -Wnb html . _build/
poetry run make doctest
poetry run make linkcheck
140 changes: 140 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_*

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# vscode
*.vscode

#macOS metadata
.DS_Store

# Mess
example_cases/SPARC_PRD/output/*
# avoid committing nc files
*.nc
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# per default we only run over the files in the python package
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
# but no large files anywhere ;)
files: ''
exclude: ".*getting_started.ipynb"
- repo: local
hooks:
- id: black
name: Black
entry: poetry run black
language: system
types: [python]
- repo: local
hooks:
- id: ruff
name: ruff
entry: poetry run ruff
language: system
types: [python]
files: '^cfspopcon/'
- repo: local
hooks:
- id: mypy
name: mypy
entry: poetry run mypy
language: system
types: [python]
files: '^cfspopcon/'
exclude: ^cfspopcon/plotting
18 changes: 18 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2

build:
os: "ubuntu-20.04"
tools:
python: "3.10"
jobs:
post_create_environment:
# Install poetry
# https://python-poetry.org/docs/#installing-manually
- pip install poetry
# Tell poetry to not use a virtual environment
- poetry config virtualenvs.create false
post_install:
- poetry install

sphinx:
configuration: docs/conf.py
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Please make sure to check out our [Developer's Guide](docs/doc_sources/dev_guide.rst).
It will show you how to setup a development environment for this project and covers our contributing guidelines.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2023 Commonwealth Fusion Systems

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the “Software”), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cfspopcon: 0D Plasma Calculations & Plasma OPerating CONtours
--------------------------------------------------------------

[![Build Status](https://github.com/cfs-energy/cfspopcon/actions/workflows/workflow_actions.yml/badge.svg)](https://github.com/cfs-energy/cfspopcon/actions)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![Documentation Status](https://readthedocs.org/projects/cfspopcon/badge/?version=latest)](https://cfspopcon.readthedocs.io/en/latest/?badge=latest)

For more information please have a look at our [documentation](https://cfspopcon.readthedocs.io/en/latest/).
Loading

0 comments on commit 6f0e5c8

Please sign in to comment.