Skip to content

Commit

Permalink
Putting trajectory calculation into separate repo
Browse files Browse the repository at this point in the history
  • Loading branch information
aaschwanden committed Nov 21, 2023
1 parent c4790ab commit 45060b7
Show file tree
Hide file tree
Showing 10 changed files with 1,237 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: pism-ragis

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
python -m pytest
72 changes: 72 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
exclude: "docs|node_modules|migrations|.git|.tox"
default_stages: [commit]
fail_fast: true

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
exclude: conda/meta.yaml

# Can run individually with `pre-commit run black --all-files`
- repo: https://github.com/psf/black
rev: 23.11.0
hooks:
- id: black

# Can run individually with `pre-commit run isort --all-files`
- repo: https://github.com/timothycrosley/isort
rev: 5.12.0
hooks:
- id: isort
args:
- --profile
- black

# Can run individually with `pre-commit run flake8 --all-files`
# Need to use flake8 GitHub mirror due to CentOS git issue with GitLab
# https://github.com/pre-commit/pre-commit/issues/1206
- repo: https://github.com/pycqa/flake8
rev: 6.1.0
hooks:
- id: flake8
entry: pflake8
additional_dependencies: [flake8-isort, pyproject-flake8]

# Can run individually with `pre-commit run mypy --all-files`
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.7.0
hooks:
- id: mypy

- repo: local
hooks:
- id: pylint
name: pylint
entry: pylint
language: system
types: [python]
args:
[
"-rn", # Only display messages
"-sn", # Don't display the score
]

# - repo: https://github.com/srstevenson/nb-clean
# rev: 3.1.0
# hooks:
# - id: nb-clean

- repo: local
hooks:
- id: pytest # pytest is a pre-commit hook
name: pytest
entry: pytest tests
language: system
types: [python]
exclude: ^venv/ ^.git/ ^.vscode/ ^.DS_Store ^uq/ ^hindcasts/
always_run: true
pass_filenames: false
6 changes: 6 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[MASTER]
jobs=4 #number of processes to use
[BASIC]
good-names=nameOfYourProject #names to be considered ok
[pre-commit-hook]
disable=E0401, C0301, C0103, R0903, R0913, R0914, W0102, E1126, C0302, R0911, R1705, W0702, R0912, R0915
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# trajectory
# trajectory
135 changes: 135 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
[project]
name = "trajectory"
version = "0.1.0"
maintainers = [{name = "Andy Aschwanden", email = "[email protected]"}]
description = """Calculate trajectories for a static flow field"""
readme = "README.md"
requires-python = ">3.8"
license = {text = "GPL 3.0"}
classifiers = [
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering :: Postprocessing",
]
dynamic = ["dependencies"]

[tool.setuptools.packages.find]
include = ["trajectory"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
py-modules = ["trajectory"]

[tool.poetry]
name = "trajectory"
version = "0.1.0"
description = """Calculate trajectories"""
authors = ["Andy Aschwanden <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.9,<3.13"
gdal = ">=3.7.2"
geopandas = ">=0.14.0"
joblib = ">=1.3.2"
matplotlib = ">=3.8.0"
pandas = ">=1.5.3"
shapely = ">=2.0.2"
xarray = "^2022.10.0"
pyogrio = "^0.7.2"
pyarrow = "^14.0.0"
tqdm = "^4.66.1"

[tool.poetry.urls]

"homepage" = "https://github.com/pism/trajectory"
"repository" = "https://github.com/pism/trajectory"
"bug tracker" = "https://github.com/pism/trajectory/issues"

[tool.flake8]
# https://pep8.readthedocs.io/en/latest/intro.html#error-codes
ignore = """
E203,
E501,
W503,
W605,
C901,
F841,
E722,
E402,
F722,
"""
# Max width of Github code review is 119 characters
max-line-length = 119
max-complexity = 18
exclude = [
".tox",
".git",
"*/migrations/*",
".mypy_cache",
".pytest_cache",
"*__init__.py",
"venv"
]

[tool.isort]
multi_line_output = 3
include_trailing_comma = "True"
force_grid_wrap = 0
use_parentheses = "True"
line_length = 88

[tool.pycodestyle]
max-line-length = 119
exclude = [
".tox",
".git",
"*/migrations/*",
".mypy_cache",
".pytest_cache",
"*__init__.py",
"venv"
]

[tool.mypy]
python_version = 3.11
check_untyped_defs = "True"
ignore_missing_imports = "True"
warn_unused_ignores = "True"
warn_redundant_casts = "True"
warn_unused_configs = "True"

[tool.black]
line-length = 88
target-version = ['py311']
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.mypy_cache
| _build
| conda
| docs
)/
'''

[tool.pylint.messages_control]
disable = """
too-many-lines,
no-else-return,
bare-except
"""

[tool.pylint.format]
max-line-length = 120
16 changes: 16 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
dask>=2023.10.1
joblib>=1.3.2
matplotlib>=3.8.0
pandas>=2.0.3
pydoe>=0.3.8
salib>=1.4.7
scipy>=1.10.1
shapely>=2.0.2
h5netcdf
xarray>=2023.10.1
pyogrio>=0.7.2
pyarrow>=14.0.0
tqdm>=4.66.1
openpyxl>=3.1.2
toml
types-toml
Loading

0 comments on commit 45060b7

Please sign in to comment.