Skip to content

Commit

Permalink
Merge pull request #2 from Element84/adeelh/gitlab-changes
Browse files Browse the repository at this point in the history
Refactoring and general improvements
  • Loading branch information
AdeelH authored Dec 6, 2024
2 parents 70b544d + d32e904 commit 1a0f043
Show file tree
Hide file tree
Showing 32 changed files with 1,101 additions and 439 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ jobs:
build:
strategy:
matrix:
python-version:
- "3.10"
python-version: ["3.10", "3.11", "3.12"]
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -38,3 +37,5 @@ jobs:
run: |
. .venv/bin/activate
scripts/test.sh
env:
AWS_DEFAULT_REGION: us-east-1
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,6 @@ cython_debug/
#.idea/

temp/

# directory created by VS Code "local history" extension
.history/
33 changes: 19 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
repos:
- repo: local
hooks:
- id: black_check
name: black check
entry: black
- id: ruff-check
name: Run ruff check
entry: ruff check
args: [--diff]
language: python
'types_or': [python, pyi]
args: [--diff, --check, src/]
types_or: [python, pyi]
pass_filenames: true
require_serial: true
- id: check-added-large-files
name: Check for added large files
Expand All @@ -27,17 +28,21 @@ repos:
entry: end-of-file-fixer
language: system
types: [text]
stages: [commit, push, manual]
stages: [pre-commit, pre-push, manual]
- id: trailing-whitespace
name: Trim Trailing Whitespace
entry: trailing-whitespace-fixer
language: system
types: [text]
stages: [commit, push, manual]
- id: pyright
name: pyright
entry: pyright
language: python
'types_or': [python, pyi]
args: [--verbose, .]
require_serial: true
stages: [pre-commit, pre-push, manual]
# Pre-commit runs pyright-python in its own virtual environment by
# default which means it does not detect installed dependencies. The
# virtual env can be specified in pyrightconfig.json via the "venvPath"
# and "venv" variables. However, this doesn't seem to work with
# conda/mamba environments and is less robust anyway.
# - id: pyright
# name: pyright
# entry: pyright src/ --verbose
# language: python
# 'types_or': [python, pyi]
# require_serial: true
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@ Contains Geospatial AI/ML related code

## Developing

1. Install python and [uv](https://github.com/astral-sh/uv)
2. Checkout the code
3. Run `scripts/recreate_venv.sh`
4. Run `pre-commit install` to install the pre commit changes
5. Make changes
6. Verify linting passes `scripts/lint.sh`
7. Verify tests pass `scripts/test.sh`
8. Commit and push your changes
1. Checkout the code.
1. Create/activate your Python environment of choice.
1. Install uv: `pip install uv`.
1. Install dependencies: `uv pip install -r pyproject.toml`.
1. Install dev dependencies: `uv pip install -r pyproject.toml --extra dev`.
1. Run `pre-commit install` to install pre-commit hooks.
1. Configure your editor for realtime linting:
- For VS Code:
- Set the correct Python environment for the workspace via `ctrl+shift+P` > `Python: Select Interpreter`.
- Install the Pylance and Ruff extensions.
1. Make changes.
1. Verify linting passes `scripts/lint.sh`.
1. Verify tests pass `scripts/test.sh`.
1. Commit and push your changes.
- Note: if using Gitkraken, launch it from the terminal (with `gitkraken`) with the correct python environment activated to ensure that it can use the pre-commit hooks.
77 changes: 68 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,90 @@ dependencies = [
"boto3-stubs[bedrock-runtime]>=1.35.20",
"pydantic>=2.9.1",
"shapely>=2.0.6",
"types-shapely>=2.0.0.20240820"
"types-shapely>=2.0.0.20240820",
"function_schema>=0.4.4",
]
dynamic = ["version"]

[tool.setuptools_scm]

[tool.pytest.ini_options]
pythonpath = "src"
testpaths=[
"tests"
]
testpaths = ["tests"]

[project.urls]
Github = "https://github.com/Element84/e84-geoai-common"

[project.optional-dependencies]
debugging = [
"folium>=0.17.0"
]
debugging = ["folium>=0.17.0"]
dev = [
"pytest>=8.3.3",
"ipykernel>=6.29.5",
"black>=24.8.0",
"ruff>=0.6.8",
"pyright>=1.1.381",
"build>=1.2.2",
"pre-commit>=3.8.0",
"pre-commit-hooks>=4.6.0"
"pre-commit-hooks>=4.6.0",
"moto>=5.0.20",
]


[tool.pyright]
include = ["src/"]
ignore = ["**/tests/**", "**/venv/**", "*.pyc"]
typeCheckingMode = "strict"
reportGeneralTypeIssues = true
reportImplicitStringConcatenation = "none"
reportPropertyTypeMismatch = "error"
reportShadowedImports = "error"
reportTypedDictNotRequiredAccess = "none"
reportUninitializedInstanceVariable = "error"
reportUnknownArgumentType = "error"
reportUnknownMemberType = "error"
reportUnknownVariableType = "error"
reportUnnecessaryComparison = "error"
reportIncompatibleVariableOverride = "none"

[tool.ruff]
line-length = 79

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.lint]
# http://docs.astral.sh/ruff/rules/
select = ['ALL']
ignore = [
# Unnecessary assignment before return statement
'RET504',
# Trailing comma missing
'COM812',
# Missing docstring for module
'D100',
# Missing docstring in magic method
'D105',
# 1 blank line required before class docstring
'D203',
# Multi-line docstring summary should start at the second line
'D213',
]

[tool.ruff.lint.per-file-ignores]
'__init__.py' = [
# Module level import not at top of cell
'E402',
# Imported but unused
'F401',
]
'tests/**/*' = [
# Use of assert detected
'S101',
# Missing return type annotation for public function
'ANN201',
# Missing docstrings
'D1',
# Private member accessed
'SLF001',
# magic values
'PLR2004',
]
17 changes: 0 additions & 17 deletions pyrightconfig.json

This file was deleted.

Loading

0 comments on commit 1a0f043

Please sign in to comment.