Skip to content

Commit

Permalink
make style
Browse files Browse the repository at this point in the history
  • Loading branch information
OUCyf committed Jul 18, 2023
1 parent 3958e55 commit b03546a
Show file tree
Hide file tree
Showing 28 changed files with 3,415 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
ignore = E203, E266, E501, W503, F403, F401, E402
max-line-length = 88
max-complexity = 60
select = B,C,E,F,W,T4,B9
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
67 changes: 67 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Publish to PyPI
on:
release:
types: [published]

jobs:
pypi:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11']
include:
- os: ubuntu-latest
cc: gcc
cxx: g++
label: linux-64
- os: macos-latest
cc: clang
cxx: clang++
label: osx-64
- os: windows-latest
cc: cl
cxx: cl
label: win-64

name: ${{ matrix.label }}-Python-${{ matrix.python-version }}
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Setup Poetry in Conda Environment
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Cache Poetry Env
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: poetry-${{ runner.os }}-python${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Poetry Dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction

- name: Build and Publish
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" && "${{ matrix.python-version }}" == "3.11" ]]; then
poetry build
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
poetry build -f wheel
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
poetry build -f wheel
fi
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN_SEISOPT }}
poetry publish
69 changes: 69 additions & 0 deletions .github/workflows/publish-to-test-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Publish to Test PyPI

on:
push:
branches:
- 'test/**'

jobs:
testpypi:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11']
include:
- os: ubuntu-latest
cc: gcc
cxx: g++
label: linux-64
- os: macos-latest
cc: clang
cxx: clang++
label: osx-64
- os: windows-latest
cc: cl
cxx: cl
label: win-64

name: ${{ matrix.label }}-Python-${{ matrix.python-version }}
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Setup Poetry in Conda Environment
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Cache Poetry Env
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: poetry-${{ runner.os }}-python${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Poetry Dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction

- name: Build and Publish
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" && "${{ matrix.python-version }}" == "3.11" ]]; then
poetry build
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
poetry build -f wheel
elif [[ "${{ matrix.os }}" == "windows-latest" ]]; then
poetry build -f wheel
fi
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry publish --repository test-pypi --username __token__ --password ${{ secrets.TEST_PYPI_TOKEN_SEISOPT }}
32 changes: 32 additions & 0 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Sphinx
on:
push:
branches:
- main
jobs:
sphinx:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: 3.11
- name: run doc
run: |
pip install poetry-core@https://github.com/python-poetry/poetry-core/archive/refs/tags/1.6.1.zip
pip install numpy obspy scipy matplotlib
pip install . --no-build-isolation
pip install sphinx pydata-sphinx-theme sphinx-autoapi jupyter-sphinx sphinx-copybutton
cd docs
make html
echo "yinfu.info" > _build/html/CNAME
cd ..
- name: push to github page
if: ${{ !env.ACT }}
uses: peaceiris/actions-gh-pages@v3.9.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html
user_name: "github-actions[bot]"
user_email: "github-actions[bot]@users.noreply.github.com"
54 changes: 54 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: seisopt
on:
push:
branches:
- main

jobs:
code-coverage:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install Poetry
uses: snok/install-poetry@v1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

- name: Load Cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root

- name: build and publish
run: poetry build

- name: Generate Coverage Report
run: |
pip install pytest
pip install pytest-cov
pytest --cov=./seisopt --cov-report=xml
- name: Upload Coverage Reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN_SEISOPT }}
env_vars: OS
fail_ci_if_error: false
verbose: true
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# ShakeFlow
.DS_Store
.vscode/*
setup.py

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
args: ['--fix=lf']
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 3.8.3
hooks:
- id: flake8
additional_dependencies:
- flake8-black
- flake8-breakpoint
- flake8-docstrings
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black"]
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
hooks:
- id: nbstripout
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# seisopt
Seismology optimize approaches

[![Actions Status](https://github.com/shakeflow/seisopt/actions/workflows/workflow.yml/badge.svg)](https://github.com/shakeflow/seisopt/actions)
[![coverage](https://codecov.io/gh/shakeflow/seisopt/branch/main/graph/badge.svg)](https://codecov.io/gh/shakeflow/seisopt)
[![docs](https://img.shields.io/badge/docs-stable-blue.svg)](https://shakeflow.github.io/seisopt/)
[![supported versions](https://img.shields.io/pypi/pyversions/seisopt.svg?label=python_versions)](https://pypi.python.org/pypi/seisopt)
[![docs](https://badge.fury.io/py/seisopt.svg)](https://badge.fury.io/py/seisopt)


Seismology optimize approaches.

## License
1 change: 1 addition & 0 deletions benchmarks/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import numpy as np
9 changes: 9 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
coverage:
status:
project: off
patch: off

ignore:
- "seisopt/tests/*"

comment: true
Loading

0 comments on commit b03546a

Please sign in to comment.