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 pre-commit #258

Merged
merged 4 commits into from
Mar 29, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Build the Docker image
run: docker build . --file Dockerfile --tag ${{ github.repository }}:$(date +%s)
2 changes: 1 addition & 1 deletion .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Log in to Docker Hub
uses: docker/login-action@v2
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
- name: Install GDAL
run: |
python -m pip install --upgrade pip
Expand All @@ -26,11 +26,6 @@ jobs:
pip install --no-cache-dir Cython
pip install -r requirements.txt -r requirements_dev.txt -r requirements_docs.txt
pip install .
- name: Discover typos with codespell
run: codespell --skip="*.csv,*.geojson,*.json,*.js,*.html,*cff,*.pdf" --ignore-words-list="aci,acount,acounts,fallow,hart,hist,nd,ned,ois,wqs,pres"
# - name: PKG-TEST
# run: |
# python -m unittest discover tests/
- run: mkdocs build
- name: Deploy to Netlify
uses: nwtgck/actions-netlify@v2.0
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/draft-pdf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
name: Paper Draft
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Build draft PDF
uses: openjournals/openjournals-draft-action@master
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
fail-fast: false
matrix:
config:
- { os: macOS-latest, py: "3.10" }
- { os: macOS-latest, py: "3.11" }
env:
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
steps:
- name: CHECKOUT CODE
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: SETUP PYTHON
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config.py }}
# - name: Install GDAL
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
SDKROOT: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
steps:
- name: CHECKOUT CODE
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: SETUP PYTHON
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.config.py }}
- name: Install GDAL
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jobs:
test-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
auto-activate-base: true
python-version: "3.10"
Expand Down
29 changes: 29 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
types: [python]
- id: trailing-whitespace
- id: requirements-txt-fixer
- id: check-added-large-files
args: ["--maxkb=500"]

- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black-jupyter
language_version: python3.11

- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: [--toml, pyproject-codespell.precommit-toml]

- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
6 changes: 2 additions & 4 deletions docs/examples/arcgis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"sam.show_anns(axis=\"off\", alpha=1, output=\"ag_annotations.tif\")"
Expand Down Expand Up @@ -431,7 +429,7 @@
"metadata": {},
"outputs": [],
"source": [
"sam.generate('agriculture.tif', output=\"ag_masks2.tif\", foreground=True)"
"sam.generate(\"agriculture.tif\", output=\"ag_masks2.tif\", foreground=True)"
]
},
{
Expand Down
12 changes: 9 additions & 3 deletions docs/examples/automatic_mask_generator_hq.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@
"source": [
"import os\n",
"import leafmap\n",
"from samgeo.hq_sam import SamGeo, show_image, download_file, overlay_images, tms_to_geotiff"
"from samgeo.hq_sam import (\n",
" SamGeo,\n",
" show_image,\n",
" download_file,\n",
" overlay_images,\n",
" tms_to_geotiff,\n",
")"
]
},
{
Expand Down Expand Up @@ -147,7 +153,7 @@
"outputs": [],
"source": [
"sam = SamGeo(\n",
" model_type=\"vit_h\", # can be vit_h, vit_b, vit_l, vit_tiny\n",
" model_type=\"vit_h\", # can be vit_h, vit_b, vit_l, vit_tiny\n",
" sam_kwargs=None,\n",
")"
]
Expand Down Expand Up @@ -288,7 +294,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down
7 changes: 3 additions & 4 deletions docs/examples/box_prompts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
"metadata": {},
"outputs": [],
"source": [
"m.add_raster('mask.tif', cmap='viridis', nodata=0, layer_name='Mask')\n",
"m.add_raster(\"mask.tif\", cmap=\"viridis\", nodata=0, layer_name=\"Mask\")\n",
"m"
]
},
Expand All @@ -260,7 +260,7 @@
"metadata": {},
"outputs": [],
"source": [
"url = 'https://opengeos.github.io/data/sam/tree_boxes.geojson'\n",
"url = \"https://opengeos.github.io/data/sam/tree_boxes.geojson\"\n",
"geojson = \"tree_boxes.geojson\"\n",
"leafmap.download_file(url, geojson)"
]
Expand Down Expand Up @@ -350,8 +350,7 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
},
"orig_nbformat": 4
}
},
"nbformat": 4,
"nbformat_minor": 2
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/fast_sam.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
"outputs": [],
"source": [
"from samgeo.fast_sam import SamGeo\n",
"\n",
"sam = SamGeo(model=\"FastSAM-x.pt\")"
]
},
Expand Down Expand Up @@ -259,8 +260,7 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
},
"orig_nbformat": 4
}
},
"nbformat": 4,
"nbformat_minor": 2
Expand Down
7 changes: 3 additions & 4 deletions docs/examples/input_prompts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -147,7 +147,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -260,8 +260,7 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.8"
},
"orig_nbformat": 4
}
},
"nbformat": 4,
"nbformat_minor": 2
Expand Down
3 changes: 1 addition & 2 deletions docs/examples/input_prompts_hq.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
},
"orig_nbformat": 4
}
},
"nbformat": 4,
"nbformat_minor": 2
Expand Down
22 changes: 12 additions & 10 deletions docs/examples/maxar_open_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@
},
"outputs": [],
"source": [
"url = 'https://drive.google.com/file/d/1jIIC5hvSPeJEC0fbDhtxVWk2XV9AxsQD/view?usp=sharing'"
"url = (\n",
" \"https://drive.google.com/file/d/1jIIC5hvSPeJEC0fbDhtxVWk2XV9AxsQD/view?usp=sharing\"\n",
")"
]
},
{
Expand All @@ -74,7 +76,7 @@
},
"outputs": [],
"source": [
"leafmap.download_file(url, output='image.tif')"
"leafmap.download_file(url, output=\"image.tif\")"
]
},
{
Expand All @@ -94,7 +96,7 @@
"source": [
"m = leafmap.Map(height=\"600px\")\n",
"m.add_basemap(\"SATELLITE\")\n",
"m.add_raster('image.tif', layer_name=\"Image\")\n",
"m.add_raster(\"image.tif\", layer_name=\"Image\")\n",
"m.add_layer_manager()\n",
"m"
]
Expand Down Expand Up @@ -160,7 +162,7 @@
},
"outputs": [],
"source": [
"sam.generate('image.tif', output=\"mask.tif\", foreground=True)"
"sam.generate(\"image.tif\", output=\"mask.tif\", foreground=True)"
]
},
{
Expand All @@ -178,7 +180,7 @@
},
"outputs": [],
"source": [
"raster_to_vector('mask.tif', output='mask.shp')"
"raster_to_vector(\"mask.tif\", output=\"mask.shp\")"
]
},
{
Expand Down Expand Up @@ -235,7 +237,7 @@
"outputs": [],
"source": [
"leafmap.image_comparison(\n",
" 'image.tif',\n",
" \"image.tif\",\n",
" \"annotation.tif\",\n",
" label1=\"Image\",\n",
" label2=\"Segmentation\",\n",
Expand All @@ -257,7 +259,7 @@
},
"outputs": [],
"source": [
"overlay_images('image.tif', \"annotation.tif\", backend=\"TkAgg\")"
"overlay_images(\"image.tif\", \"annotation.tif\", backend=\"TkAgg\")"
]
},
{
Expand All @@ -273,8 +275,8 @@
"metadata": {},
"outputs": [],
"source": [
"m.add_raster('mask.tif', layer_name='Mask', nodata=0)\n",
"m.add_raster('annotation.tif', layer_name='Annotation')\n",
"m.add_raster(\"mask.tif\", layer_name=\"Mask\", nodata=0)\n",
"m.add_raster(\"annotation.tif\", layer_name=\"Annotation\")\n",
"m"
]
},
Expand All @@ -286,7 +288,7 @@
},
"outputs": [],
"source": [
"m.add_vector('mask.shp', layer_name='Vector', info_mode=None)"
"m.add_vector(\"mask.shp\", layer_name=\"Vector\", info_mode=None)"
]
},
{
Expand Down
Loading
Loading